Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_context_menu.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_CONTEXT_MENU_H
8#define _DS_CONTEXT_MENU_H
9
10
11#include <ds_view.h>
12#include <ds_string.h>
13
14
20class DsContextMenu: public DsView
21{
22public:
31 DsContextMenu(DsView* parent, const ds_bitmap_font_t* font, uint32_t corner_radius = 0, float row_spacing = 1.0);
32
33
37 void clear(void);
38
39
46 void add(const char* name, const lambda<void(void)> &cb);
47
48
54 void setMenuColors(DsColor color, DsColor color_selected);
55
56
62 void setTextColors(DsColor color, DsColor color_selected);
63
64
70
71
76 void setBorderThickness(uint8_t thickness);
77
78private:
79 struct link_t
80 {
81 const char* name;
82 lambda<void(void)> callback;
83 link_t* next;
84 };
85
86 const ds_bitmap_font_t* mFont;
87 float mRowSpacing;
88
89 DsColor mMenuColor;
90 DsColor mSelectedMenuColor;
91
92 DsColor mTextColor;
93 DsColor mSelectedTextColor;
94
95 uint32_t mCornerRadius;
96 DsColor mBorderColor;
97 uint8_t mBorderThickness;
98
99 uint32_t mHorizontalPadding;
100 uint32_t mVerticalPadding;
101
102 DsSize mRowSize;
103 uint32_t mRowCount;
104 int32_t mSelected;
105
106 link_t* mFreeLinks;
107 link_t* mRowList;
108
109
110 void onPaint(DsRenderer &renderer) override final;
111
112 void onShow(void) override final;
113};
114
115
116
117#endif
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
DsContextMenu is a class implementing a context menu.
Definition ds_context_menu.h:21
void setBorderThickness(uint8_t thickness)
Sets the border thickness.
void clear(void)
Clears all menu entries from the context menu.
void setBorderColor(DsColor color)
Sets the border color.
void setMenuColors(DsColor color, DsColor color_selected)
Sets the colors for the menu entry.
void add(const char *name, const lambda< void(void)> &cb)
Adds a menu entry to the context menu.
void setTextColors(DsColor color, DsColor color_selected)
Sets the colors for the menu label.
DsContextMenu(DsView *parent, const ds_bitmap_font_t *font, uint32_t corner_radius=0, float row_spacing=1.0)
DsRenderer is a class that implements all the drawing operations.
Definition ds_renderer.h:42
DsSize is class that represents the 2D size of a graphic object (width, height) as integer values.
Definition ds_geometry.h:780
DsView is a base class that represents any view on the screen.
Definition ds_view.h:40
Definition ds_types_lambda.h:24
Definition ds_font.h:45