1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #pragma once
6 
7 #include "../iplatformoptionmenu.h"
8 
9 #include "../../ccolor.h"
10 #include "../../cfont.h"
11 #include "../../iviewlistener.h"
12 
13 #include <memory>
14 
15 //------------------------------------------------------------------------
16 namespace VSTGUI {
17 
18 //------------------------------------------------------------------------
19 struct GenericOptionMenuTheme
20 {
21 	SharedPointer<CFontDesc> font {kSystemFont};
22 	CColor backgroundColor {MakeCColor (0x39, 0x3c, 0x3f, 252)};
23 	CColor selectedBackgroundColor {MakeCColor (200, 200, 200, 235)};
24 	CColor textColor {MakeCColor (255, 255, 255, 255)};
25 	CColor selectedTextColor {MakeCColor (0, 0, 0, 255)};
26 	CColor disabledTextColor {MakeCColor (150, 150, 150, 255)};
27 	CColor titleTextColor {MakeCColor (150, 150, 150, 255)};
28 	CColor separatorColor {MakeCColor (100, 100, 100, 255)};
29 	CPoint inset {6., 6.};
30 	uint32_t menuAnimationTime {240};
31 };
32 
33 //------------------------------------------------------------------------
34 struct IGenericOptionMenuListener
35 {
36 	virtual ~IGenericOptionMenuListener () noexcept = default;
37 
38 	virtual void optionMenuPopupStarted () = 0;
39 	virtual void optionMenuPopupStopped () = 0;
40 };
41 
42 //------------------------------------------------------------------------
43 class GenericOptionMenu : public IPlatformOptionMenu, public ViewMouseListenerAdapter
44 {
45 public:
46 	GenericOptionMenu (CFrame* frame, CButtonState initialButtons,
47 	                   GenericOptionMenuTheme theme = {});
48 	~GenericOptionMenu () noexcept override;
49 
50 	void setListener (IGenericOptionMenuListener* listener);
51 
52 	void popup (COptionMenu* optionMenu, const Callback& callback) override;
53 
54 private:
55 	void removeModalView (PlatformOptionMenuResult result);
56 	CMouseEventResult viewOnMouseDown (CView* view, CPoint pos, CButtonState buttons) override;
57 	CMouseEventResult viewOnMouseUp (CView* view, CPoint pos, CButtonState buttons) override;
58 
59 	struct Impl;
60 	std::unique_ptr<Impl> impl;
61 };
62 
63 //------------------------------------------------------------------------
64 } // VSTGUI
65