lecui 1.0.0-alpha.20
lecui C++ user interface library
context_menu.h
1//
2// context_menu.h - context menu interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "../form.h"
15#else
16#include <liblec/lecui/form.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
22 struct menu_item {
24 std::string label;
25
29
32 std::string image_file;
33
35 std::string font = "Segoe UI";
36
38 float font_size = 9.f;
39
43 std::vector<menu_item> children;
44 };
45
47 class lecui_api context_menu {
48 public:
51 enum class pin_type {
56 bottom,
57
61 right,
62 };
63
66 struct specs {
68 std::vector<menu_item> items;
69
72 lecui::rect pin = { 0.f, 0.f, 0.f, 0.f };
73
76 pin_type type = pin_type::bottom;
77
82 };
83
86
92 std::string operator() (form& fm, const specs& menu_specs);
93
94 private:
95 class impl;
96
97 // Copying an object of this class are not allowed
98 context_menu(const context_menu&) = delete;
99 context_menu& operator=(const context_menu&) = delete;
100 };
101 }
102}
Context menu.
Definition: context_menu.h:47
context_menu()
Context menu constructor.
pin_type
Pin type. Used to determine the position of the context menu with respect to the pin rectangle.
Definition: context_menu.h:51
Form base class. The user must inherit from this class and call one of the two constructors from its ...
Definition: form.h:122
Rectangle class.
Definition: lecui.h:158
@ right
Align text to the right.
image_quality
Image render quality. Used when resampling images.
Definition: lecui.h:916
@ high
High image quality, for best image quality possibly at the cost of rendering speed.
@ bottom
Align paragraph to the bottom.
Top level namespace for the liblec libraries.
Definition: appearance.h:19
The context menu specifications. By default the menu is pinned to the top left corner of the mouse cu...
Definition: context_menu.h:66
std::vector< menu_item > items
The menu items.
Definition: context_menu.h:68
Menu items.
Definition: context_menu.h:22
float font_size
The font size.
Definition: context_menu.h:38
int image_png_resource
The image resource to use for the menu item (placed on the left).
Definition: context_menu.h:28
std::string font
The font to use.
Definition: context_menu.h:35
std::string image_file
The image to use for the menu item (placed on the left).
Definition: context_menu.h:32
std::vector< menu_item > children
The children of the menu item (used to make a tree).
Definition: context_menu.h:43
std::string label
The label text of the menu item. Use an empty string to make a separator.
Definition: context_menu.h:24