Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_button.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_BUTTON_H
8#define _DS_BUTTON_H
9
10
11#include <ds_view.h>
12#include <ds_string.h>
13
14
15
19class DsButton: public DsView
20{
21public:
22
35 DsButton(DsView* parent, const DsPoint &pos, const DsSize &size, DsColor color, uint32_t corner_radius, const char* label, const ds_bitmap_font_t* font, DsColor label_color);
36
37
47 DsButton(DsView* parent, const DsPoint &pos, const DsSize &size, const DsSurface* surface, const DsSurface* pressed_surface);
48
49
57 void setCornerRadius(uint32_t tl, uint32_t tr, uint32_t br, uint32_t bl);
58
59
65
66
72
73
79
80
85 void setColor(DsColor color);
86
87
92 void setFont(const ds_bitmap_font_t* font);
93
94
99 void setTextColor(DsColor color);
100
101
106 void setText(const char* text);
107
108
114 void setSurfaces(const DsSurface* surface, const DsSurface* pressed_surface);
115
116
117private:
118 uint32_t mTlCornerRadius;
119 uint32_t mTrCornerRadius;
120 uint32_t mBlCornerRadius;
121 uint32_t mBrCornerRadius;
122
123 DsColor mColor;
124 DsColor mHighlightMaskColor;
125 DsColor mTextHighlightMaskColor;
126 DsColor mDisabledMaskColor;
127
128 const ds_bitmap_font_t* mFont;
129 const char* mText;
130 DsColor mTextColor;
131
132 const DsSurface* mSurface;
133 const DsSurface* mPressedSurface;
134
135 void onPaint(DsRenderer &renderer) override;
136 DsSize fitContent(void) override;
137};
138
139
140#endif
DsButton is a class representing a standard, 2D, rounded corner button.
Definition ds_button.h:20
void setFont(const ds_bitmap_font_t *font)
Sets the button text label font.
void setDisabledMaskColor(DsColor color)
Sets the color for the mask which is applied on top when the button is disabled.
void setTextColor(DsColor color)
Sets the button text color.
void setSurfaces(const DsSurface *surface, const DsSurface *pressed_surface)
Sets the button surfaces.
void setHighlightMaskColor(DsColor color)
Sets the color for the highlighting mask which is applied when the button is touched.
DsButton(DsView *parent, const DsPoint &pos, const DsSize &size, const DsSurface *surface, const DsSurface *pressed_surface)
Creates a DsButton object using surfaces.
DsButton(DsView *parent, const DsPoint &pos, const DsSize &size, DsColor color, uint32_t corner_radius, const char *label, const ds_bitmap_font_t *font, DsColor label_color)
Creates a drawn DsButton object.
void setColor(DsColor color)
Sets the button color.
void setTextHighlightMaskColor(DsColor color)
Sets the color for the highlighting mask which is applied to the text when the button is touched.
void setCornerRadius(uint32_t tl, uint32_t tr, uint32_t br, uint32_t bl)
Sets the radius for each corner.
void setText(const char *text)
Sets the button text label.
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
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
DsSurface is a class that represents a drawing surface.
Definition ds_surface.h:30
DsView is a base class that represents any view on the screen.
Definition ds_view.h:40
Definition ds_font.h:45