From 43d0eb870f5f7f89b24d3d8d6ce0b66783077721 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 19 Feb 2023 22:33:10 +0100 Subject: [PATCH] widget/menu: add member 'type_name' to CMenuItem class This makes it easier to distinguish the object type. Normally, type queries would be done using typeid-operation or dynamic_cast, but we usually have RTTI disabled in the Makefiles. Presumably, this is to avoid unnecessarily increasing the size of the binaries. The type information defined by this member is currently only defined in the CMenuItem class, so all subclasses are also equipped with it. An exception is the CMenuSeparator class. If further definitions are necessary in the subclasses, they can be retrofitted as needed. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/2cd470cd59c102bc310b7af6a98ec5b90b3be752 Author: Thilo Graf Date: 2023-02-19 (Sun, 19 Feb 2023) --- src/gui/widget/menue.cpp | 2 ++ src/gui/widget/menue.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index d0450e1e6..5f5c38c5a 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -68,6 +68,7 @@ CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const I active = current_active = Active; directKey = DirectKey; isStatic = IsStatic; + type_name = "CMenuItem"; if (IconName && *IconName) iconName = IconName; @@ -2512,6 +2513,7 @@ void CMenuSeparator::init(const int& Type, const neutrino_locale_t& lText, const type = Type; name = lText; nameString = sText; + type_name = "CMenuSeparator"; } int CMenuSeparator::getHeight(void) diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index c5beed634..ff90dd333 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -134,6 +134,7 @@ class CMenuItem : public CComponentsSignals void handleOptionIcon(const std::string& str_option); const char* getValName(const neutrino_locale_t& Option, const char* ValName); public: + std::string type_name; int height; bool active, current_active; bool marked;