From c798413b1d6625a94d90f1ef56c067370d93bb9f Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Thu, 16 Nov 2023 16:00:37 -0500 Subject: Initial components UI update. --- binaryninjaapi.h | 2 +- binaryview.cpp | 6 +++++- ui/action.h | 21 +++++++++++++++++++++ ui/uitypes.h | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 0052e3ed..91006bf5 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2825,7 +2825,7 @@ namespace BinaryNinja { SegmentUpdates = SegmentLifetime | SegmentUpdated, SectionLifetime = SectionAdded | SectionRemoved, SectionUpdates = SectionLifetime | SectionUpdated, - ComponentUpdates = ComponentAdded | ComponentRemoved | ComponentMoved | ComponentFunctionAdded | ComponentFunctionRemoved | ComponentDataVariableAdded | ComponentDataVariableRemoved + ComponentUpdates = ComponentNameUpdated | ComponentAdded | ComponentRemoved | ComponentMoved | ComponentFunctionAdded | ComponentFunctionRemoved | ComponentDataVariableAdded | ComponentDataVariableRemoved }; using NotificationTypes = uint64_t; diff --git a/binaryview.cpp b/binaryview.cpp index 7abb01cb..1588d23a 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -3286,7 +3286,11 @@ Ref BinaryView::CreateComponent(std::string parentGUID) Ref BinaryView::CreateComponent(Ref parent) { - auto bnComponent = BNCreateComponentWithParent(m_object, parent->GetGuid().c_str()); + BNComponent* bnComponent; + if (parent) + bnComponent = BNCreateComponentWithParent(m_object, parent->GetGuid().c_str()); + else + bnComponent = BNCreateComponent(m_object); return new Component(bnComponent); } diff --git a/ui/action.h b/ui/action.h index 9deb3a66..49f58b6a 100644 --- a/ui/action.h +++ b/ui/action.h @@ -372,6 +372,27 @@ class BINARYNINJAUIAPI Menu static std::vector getMainMenus(); }; +class BINARYNINJAUIAPI OrderedMenuHelper +{ + Menu* m_menu = nullptr; + uint8_t m_groupOrder = MENU_ORDER_NORMAL; + std::map m_orders; + +public: + OrderedMenuHelper(Menu* menu) : m_menu(menu) { } + + Menu* getMenu() { return m_menu; } + + void addAction(const QString& action, const QString& group) { + if (m_orders.find(group) == m_orders.end()) + { + m_menu->setGroupOrdering(group, m_groupOrder++); + m_orders[group] = MENU_ORDER_NORMAL; + } + m_menu->addAction(action, group, m_orders[group]++); + } +}; + /*! \ingroup action */ diff --git a/ui/uitypes.h b/ui/uitypes.h index bf15cbd6..083c4ac5 100644 --- a/ui/uitypes.h +++ b/ui/uitypes.h @@ -68,6 +68,7 @@ typedef BinaryNinja::Ref BasicBlockRef; typedef BinaryNinja::Ref BinaryDataRef; typedef BinaryNinja::Ref BinaryViewRef; typedef BinaryNinja::Ref BinaryViewTypeRef; +typedef BinaryNinja::Ref ComponentRef; typedef BinaryNinja::Ref DatabaseRef; typedef BinaryNinja::Ref DebugInfoRef; typedef BinaryNinja::Ref DisassemblySettingsRef; -- cgit v1.3.1