forked from Vector35/binaryninja-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsidebarwidget.h
232 lines (194 loc) · 5.51 KB
/
sidebarwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#pragma once
#include <QtWidgets/QWidget>
#include <QtWidgets/QLabel>
#include <QtWidgets/QStackedWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtGui/QPicture>
#include "theme.h"
class ContextMenuManager;
class SplitTabWidget;
class SidebarWidgetType;
class SidebarHeader;
class DockableTabCollection;
class Pane;
class SplitPaneWidget;
class DockableTabStyle;
/*!
\defgroup sidebar Sidebar
\ingroup uiapi
*/
/*!
\ingroup sidebar
*/
struct BINARYNINJAUIAPI SidebarIcon
{
QImage original;
QImage active;
QImage inactive;
static SidebarIcon generate(const QImage& src);
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarWidget : public QWidget
{
Q_OBJECT
protected:
QString m_title;
UIActionHandler m_actionHandler;
ContextMenuManager* m_contextMenuManager = nullptr;
Menu* m_menu = nullptr;
bool m_quiesceState = true;
QTimer* m_updateTimer = nullptr;
public:
SidebarWidget(const QString& title);
~SidebarWidget() { closing(); }
const QString& title() const { return m_title; }
void enableRefreshTimer(int interval);
void setRefreshQuiesce(bool enable);
bool isQuiesced() const { return m_quiesceState; }
virtual void notifyRefresh() {};
virtual void notifyQuiesce(bool /*quiesce*/) {};
virtual void notifyFontChanged() {}
virtual void notifyOffsetChanged(uint64_t /*offset*/) {}
virtual void notifyThemeChanged();
virtual void notifyViewChanged(ViewFrame* /*frame*/) {}
virtual void notifyViewLocationChanged(View* /*view*/, const ViewLocation& /*viewLocation*/) {}
virtual void focus();
virtual void closing() {}
virtual void setPrimaryOrientation(Qt::Orientation /*orientation*/) {}
virtual QWidget* headerWidget() { return nullptr; }
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarWidgetAndHeader : public QWidget
{
Q_OBJECT
bool m_tabsActive = false;
bool m_combinedTabsAndHeader = false;
bool m_alwaysShowTabs;
bool m_fixedHeaderWidget;
SidebarWidgetType* m_type;
SidebarWidget* m_widget = nullptr;
SidebarHeader* m_header = nullptr;
QVBoxLayout* m_layout;
SplitTabWidget* m_tabs = nullptr;
DockableTabCollection* m_tabCollection = nullptr;
QStackedWidget* m_headerStack;
std::map<QWidget*, SidebarHeader*> m_headerWidgets;
std::set<SidebarWidget*> m_activeWidgets;
QLabel* m_noWidgetLabel = nullptr;
private Q_SLOTS:
void tabChanged(QWidget* widget);
void tabClosed(QWidget* widget);
public:
SidebarWidgetAndHeader(SidebarWidgetType* type, SplitPaneWidget* panes, ViewFrame* frame, BinaryViewRef data);
~SidebarWidgetAndHeader() override;
SidebarWidget* widget() const { return m_widget; }
QWidget* header() const;
void addWidget(SidebarWidget* widget, bool canClose = false);
void removeWidget(SidebarWidget* widget);
SidebarWidget* widgetWithTitle(const QString& title) const;
bool hasWidgetWithTitle(const QString& title) const;
bool activateWidgetWithTitle(const QString& title);
bool hasContent() const;
void updateTheme();
void updateFonts();
void closing();
void notifyViewChanged(ViewFrame* frame);
void notifyViewLocationChanged(View* view, const ViewLocation& viewLocation);
void notifyOffsetChanged(uint64_t offset);
void forAllWidgets(const std::function<void(SidebarWidget*)>& func) const;
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarHeaderTitle : public QLabel
{
Q_OBJECT
public:
SidebarHeaderTitle(const QString& name);
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarHeader : public QWidget
{
Q_OBJECT
bool m_hasRightSide = false;
public:
SidebarHeader(const QString& name, QWidget* rightSide = nullptr);
bool hasRightSide() const { return m_hasRightSide; }
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarInvalidContextWidget : public SidebarWidget
{
Q_OBJECT
public:
SidebarInvalidContextWidget(const QString& title);
private Q_SLOTS:
void openFile();
};
/*!
\ingroup sidebar
*/
enum SidebarWidgetLocation
{
LeftContent,
LeftReference,
LeftBottom,
RightContent,
RightReference,
RightBottom
};
/*!
\ingroup sidebar
*/
enum SidebarContextSensitivity
{
GlobalSidebarContext,
SelfManagedSidebarContext,
PerTabSidebarContext,
PerViewTypeSidebarContext,
PerPaneSidebarContext
};
/*!
\ingroup sidebar
*/
class BINARYNINJAUIAPI SidebarWidgetType
{
SidebarIcon m_icon;
QString m_name;
public:
SidebarWidgetType(const QImage& icon, const QString& name);
virtual ~SidebarWidgetType() {}
const SidebarIcon& icon() const { return m_icon; }
const QString& name() const { return m_name; }
/*!
\deprecated Use `defaultLocation()`
*/
virtual bool isInReferenceArea() const { return false; }
/*!
\deprecated Use `contextSensitivity()`
*/
virtual bool viewSensitive() const { return true; }
virtual SidebarWidgetLocation defaultLocation() const;
virtual SidebarContextSensitivity contextSensitivity() const;
virtual bool alwaysShowTabs() const { return false; }
virtual bool hideIfNoContent() const { return false; }
virtual SidebarWidget* createWidget(ViewFrame* /*frame*/, BinaryViewRef /*data*/) { return nullptr; }
virtual SidebarWidget* createInvalidContextWidget();
virtual QWidget* headerWidget(SplitPaneWidget* /*panes*/, ViewFrame* /*frame*/, BinaryViewRef /*data*/)
{
return nullptr;
}
virtual bool focusHeaderWidget() const { return false; }
virtual QString noWidgetMessage() const { return "No content active"; }
virtual DockableTabStyle* tabStyle() const;
virtual bool canUseAsPane(SplitPaneWidget* /*panes*/, BinaryViewRef /*data*/) const { return false; }
virtual Pane* createPane(SplitPaneWidget* /*panes*/, BinaryViewRef /*data*/) { return nullptr; }
void updateTheme();
};