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
21
22namespace 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.
32class IconButton : public Button
33{
34 public:
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
Definition button.hpp:146
Definition frame_context.hpp:30
Definition icon_button.hpp:33
void setIcon(const std::string &path)
bool applyXMLAttribute(std::string name, std::string value) override
void setIconSize(float size)
void setGlyph(const std::string &glyph)
void setIconView(View *view)
void setText(const std::string &text)
static View * create()
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
Definition label.hpp:65
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition view.hpp:232
Definition actions.hpp:25
Definition text.hpp:13