summaryrefslogtreecommitdiff
path: root/include/ui/MenuItem.hpp
blob: 1d75488aa35d01eb769905a1a4d37770c3c7fc15 (plain)
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
#pragma once
#include <ui/common.hpp>
#include <ui/Menu.hpp>
#include <ui/MenuEntry.hpp>
#include <context.hpp>


namespace rack {
namespace ui {


struct MenuItem : MenuEntry {
	std::string text;
	std::string rightText;
	bool disabled = false;

	void draw(const DrawArgs& args) override;
	PRIVATE void drawOffset(NVGcontext* vg, float offset = 0);
	void step() override;
	void onEnter(const EnterEvent& e) override;
	void onDragDrop(const DragDropEvent& e) override;
	void doAction(bool consume = true);
	virtual Menu* createChildMenu() {
		return NULL;
	}
	/** Override to handle behavior when user clicks the menu item.
	Event is consumed by default. Unconsume to prevent the menu from being closed.
	If Ctrl (Cmd on Mac) is held, the event is *not* pre-consumed, so if your menu must be closed, always consume the event.
	*/
	void onAction(const ActionEvent& e) override;
};


struct ColorDotMenuItem : MenuItem {
	NVGcolor color;

	void draw(const DrawArgs& args) override;
	void step() override;
};


} // namespace ui
} // namespace rack