diff options
| author | Brian Potchik <brian@vector35.com> | 2020-11-07 17:37:22 -0500 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2020-11-07 17:37:22 -0500 |
| commit | 2c312c8d5bca189241377c564ff5e9fb35fe9de2 (patch) | |
| tree | 217243b0d18bb8650893a5e18b8beb837edd0757 | |
| parent | bbec694624d4d8bb127864f1794c6466746f3aa8 (diff) | |
Improved view location preservation when duplicating existing views in the UI.
| -rw-r--r-- | ui/disassemblyview.h | 11 | ||||
| -rw-r--r-- | ui/linearview.h | 6 | ||||
| -rw-r--r-- | ui/viewframe.h | 35 |
3 files changed, 45 insertions, 7 deletions
diff --git a/ui/disassemblyview.h b/ui/disassemblyview.h index 4a053617..e689ce00 100644 --- a/ui/disassemblyview.h +++ b/ui/disassemblyview.h @@ -46,8 +46,9 @@ public: virtual StatusBarWidget* getStatusBarWidget() override; - void setGraphType(BNFunctionGraphType type); - BNFunctionGraphType getGraphType() { return m_graphType; }; + BNFunctionGraphType getILViewType() { return m_ilViewType; }; + void setILViewType(BNFunctionGraphType ilViewType); + void setOption(BNDisassemblyOption option, bool state = true); void toggleOption(BNDisassemblyOption option); @@ -86,7 +87,7 @@ private: void bindActions(); - BNFunctionGraphType m_graphType; + BNFunctionGraphType m_ilViewType; std::set<BNDisassemblyOption> m_options; DisassemblyContainer* m_container; SettingsRef m_settings; @@ -148,7 +149,7 @@ public: void updateFonts(); void setCurrentFunction(FunctionRef func); - void setGraphType(BNFunctionGraphType graphType); + void setILViewType(BNFunctionGraphType ilViewType); void setHighlightToken(const HighlightTokenState& state); virtual QSize sizeHint() const override; @@ -176,7 +177,7 @@ public: void updateFonts(); void refreshHeader(FunctionRef func); void setCurrentFunction(FunctionRef func); - void setGraphType(BNFunctionGraphType graphType); + void setILViewType(BNFunctionGraphType ilViewType); void setHeaderHighlightToken(const HighlightTokenState& state); protected: diff --git a/ui/linearview.h b/ui/linearview.h index ec3ad3fe..fc91106a 100644 --- a/ui/linearview.h +++ b/ui/linearview.h @@ -126,7 +126,7 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ SettingsRef m_settings; DisassemblySettingsRef m_options; - BNFunctionGraphType m_type; + BNFunctionGraphType m_ilViewType; InstructionEdit* m_instrEdit; @@ -320,8 +320,10 @@ public: virtual HighlightTokenState getHighlightTokenState() override { return m_highlight; } + BNFunctionGraphType getILViewType() { return m_ilViewType; }; + void setILViewType(BNFunctionGraphType ilViewType); + void toggleOption(BNDisassemblyOption option); - void setViewType(BNFunctionGraphType type); virtual bool goToReference(FunctionRef func, uint64_t source, uint64_t target) override; QFont getFont() override { return m_render.getFont(); } diff --git a/ui/viewframe.h b/ui/viewframe.h index b54ec8c0..8d37c23f 100644 --- a/ui/viewframe.h +++ b/ui/viewframe.h @@ -150,6 +150,38 @@ public: ~ViewNavigationMode() { m_view->setNavigationMode(m_mode); } }; + +class BINARYNINJAUIAPI ViewLocation +{ + bool m_valid = false; + QString m_viewType; + uint64_t m_offset = 0; + bool m_hasILViewType = false; + BNFunctionGraphType m_ilViewType = NormalFunctionGraph; + size_t m_instrIndex = BN_INVALID_EXPR; + +public: + ViewLocation() { } + ViewLocation(const QString& viewType, uint64_t offset) : m_valid(true), m_viewType(viewType), m_offset(offset) { } + ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType) : m_valid(true), + m_viewType(viewType), m_offset(offset), m_hasILViewType(true), m_ilViewType(ilViewType) { } + ViewLocation(const QString& viewType, uint64_t offset, BNFunctionGraphType ilViewType, size_t instrIndex) : m_valid(true), + m_viewType(viewType), m_offset(offset), m_hasILViewType(true), m_ilViewType(ilViewType), m_instrIndex(instrIndex) { } + + bool isValid() const { return m_valid; } + QString getViewType() const { return m_viewType; } + uint64_t getOffset() const { return m_offset; } + bool hasILViewType() const { return m_hasILViewType; } + BNFunctionGraphType getILViewType() const { return m_ilViewType; } + size_t getInstrIndex() const { return m_instrIndex; } + + void setViewType(QString& viewType) { m_viewType = viewType; } + void setOffset(uint64_t offset) { m_offset = offset; } + void setILViewType(BNFunctionGraphType ilViewType) { m_hasILViewType = true; m_ilViewType = ilViewType; } + void setInstrIndex(uint64_t index) { m_instrIndex = index; } +}; + + class BINARYNINJAUIAPI ViewContainer { public: @@ -205,6 +237,9 @@ public: uint64_t getCurrentOffset(); BNAddressRange getSelectionOffsets(); + ViewLocation getViewLocation(); + void setViewLocation(const ViewLocation& viewLocation); + View* getCurrentViewInterface() const { return View::getViewFromWidget(m_view); } QWidget* getCurrentWidget() const { return m_view; } |
