forked from hchenqi/ViewDesign
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPopupMenu.cpp
More file actions
45 lines (39 loc) · 1.14 KB
/
Copy pathPopupMenu.cpp
File metadata and controls
45 lines (39 loc) · 1.14 KB
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
#include <ViewDesign/view/control/Placeholder.h>
#include <ViewDesign/view/control/TextView.h>
#include <ViewDesign/view/widget/DefaultWindow.h>
#include <ViewDesign/view/widget/Popup.h>
#include <ViewDesign/view/widget/Box.h>
#include <ViewDesign/view/widget/FilledButton.h>
#include <ViewDesign/view/wrapper/HitTestHelper.h>
#include <ViewDesign/view/wrapper/Background.h>
using namespace ViewDesign;
class MainView : public Placeholder<Fixed, Fixed> {
private:
void ShowMenu(Point point) {
ShowPopup(
*this, point,
new HitSelf<FilledButton<Box<Bounded, Bounded>>>(
FilledButtonStyle(), [&] { desktop.CloseAllWindows(); },
Margin(0.0f), Border(2.0f, 3.0f, ColorCode::Gray), color_transparent, Padding(3.0f),
new TextView(TextView::Style(), u"exit")
)
);
}
private:
virtual void OnMouseEvent(MouseEvent event) override {
switch (event.type) {
case MouseEvent::LeftDown: SetFocus(); break;
case MouseEvent::RightDown: ShowMenu(event.point); break;
}
}
};
void App() {
desktop.AddWindow(
new DefaultBackground<DefaultWindow>(
DefaultWindow::Style(),
u"Placeholder",
new MainView()
)
);
desktop.EventLoop();
}