Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
icon_button.hpp
Go to the documentation of this file.
1
/*
2
Copyright 2026 JigSawFr
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
aurore/views/button.hpp
>
20
#include <
aurore/views/image.hpp
>
21
22
namespace
aurore
23
{
24
25
// A Button with an icon before its text, or an icon alone (a round button)
26
// when it has no text. The icon is a picture, a Material Icons glyph (drawn
27
// in the text's colour, so it follows the style and the state), or a view
28
// of the app's. Every Button attribute and style applies.
29
//
30
// XML: icon (a picture: "@res/…" or a file path), glyph (a Material Icons
31
// glyph, e.g. ""), iconSize, and the Button attributes.
32
class
IconButton
:
public
Button
33
{
34
public
:
35
IconButton
();
36
37
void
setIcon
(
const
std::string& path);
38
void
setGlyph
(
const
std::string& glyph);
39
void
setIconView
(
View
* view);
40
void
setIconSize
(
float
size);
41
42
void
setText
(
const
std::string&
text
);
43
44
bool
applyXMLAttribute
(std::string name, std::string value)
override
;
45
void
draw
(NVGcontext* vg,
float
x,
float
y,
float
width,
float
height,
Style
style,
FrameContext
* ctx)
override
;
46
47
static
View
*
create
();
48
49
private
:
50
Label
*
text
=
nullptr
;
// the Button's label
51
View
* icon =
nullptr
;
52
Label
* glyph =
nullptr
;
// the icon, when it is a glyph
53
float
iconSize = 24;
54
55
void
replaceIcon(
View
* view);
56
void
updateShape();
57
};
58
59
}
// namespace aurore
button.hpp
aurore::Button
Definition
button.hpp:146
aurore::FrameContext
Definition
frame_context.hpp:30
aurore::IconButton
Definition
icon_button.hpp:33
aurore::IconButton::IconButton
IconButton()
aurore::IconButton::setIcon
void setIcon(const std::string &path)
aurore::IconButton::applyXMLAttribute
bool applyXMLAttribute(std::string name, std::string value) override
aurore::IconButton::setIconSize
void setIconSize(float size)
aurore::IconButton::setGlyph
void setGlyph(const std::string &glyph)
aurore::IconButton::setIconView
void setIconView(View *view)
aurore::IconButton::setText
void setText(const std::string &text)
aurore::IconButton::create
static View * create()
aurore::IconButton::draw
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
aurore::Label
Definition
label.hpp:65
aurore::Style
Simple wrapper around StyleValues for the array operator.
Definition
style.hpp:115
aurore::View
Definition
view.hpp:232
image.hpp
aurore
Definition
actions.hpp:25
text
Definition
text.hpp:13
aurore
views
icon_button.hpp
Generated by
1.9.8