4#include "TinyGPU/Color/RGB565.h"
5#include "TinyGPU/Color/RGB666.h"
6#include "TinyGPU/Color/RGB888.h"
7#include "TinyMaterialDesign/Core/Widget.h"
12
13
14
15
16
17
18
19
29 void setTitle(
const char* title) { title_ = title; }
35 hasColorOverride_ =
true;
36 backgroundOverride_ = background;
37 foregroundOverride_ = foreground;
43 const int32_t size =
this->bounds.h - 8;
44 return Bounds(
this->bounds.x + 4,
this->bounds.y + (
this->bounds.h - size) / 2, size, size);
48 const int32_t size =
this->bounds.h - 8;
49 return Bounds(
this->bounds.right() - size - 4,
this->bounds.y + (
this->bounds.h - size) / 2,
53 void draw(tinygpu::ISurface<RGB_T>& target)
override {
54 const RGB_T background = hasColorOverride_ ? backgroundOverride_ :
this->theme().colors.surface;
55 const RGB_T foreground = hasColorOverride_ ? foregroundOverride_ :
this->theme().colors.onSurface;
57 target.fillRect(toPx(
this->bounds.x), toPx(
this->bounds.y), toPx(
this->bounds.w),
58 toPx(
this->bounds.h), background);
60 tinygpu::IFont<RGB_T>& font = *
this->theme().typography.title;
61 const size_t textHeight = font.getHeight(1);
62 const int32_t textY =
this->bounds.centerY() -
static_cast<int32_t>(textHeight) / 2;
64 font.drawText(target,
static_cast<int16_t>(textX),
static_cast<int16_t>(textY),
65 title_.c_str(), foreground, background,
false);
80 leading->setTheme(
this->theme());
81 leading->setThemeTint(background, foreground);
82 leading->draw(target);
86 trailing->setThemeTint(background, foreground);
87 trailing->draw(target);
91 bool onGesture(
const tinygpu::GestureEvent& event)
override {
92 if (leading !=
nullptr && leading->enabled &&
93 leading->bounds.contains(event.point.x, event.point.y)) {
94 return leading->onGesture(event);
96 if (trailing !=
nullptr && trailing->enabled &&
97 trailing->bounds.contains(event.point.x, event.point.y)) {
98 return trailing->onGesture(event);
104 bool changed =
false;
112 bool hasColorOverride_ =
false;
113 RGB_T backgroundOverride_;
114 RGB_T foregroundOverride_;
Top app bar: a title plus optional leading/trailing icon widgets (typically IconButton).
Definition: AppBar.h:21
void clearColorOverride()
Definition: AppBar.h:39
Widget< RGB_T > * leading
Definition: AppBar.h:26
bool onGesture(const tinygpu::GestureEvent &event) override
Handles one gesture event. Returns true if this widget consumed it.
Definition: AppBar.h:91
Bounds trailingRect() const
Suggested square icon slot at the bar's right edge.
Definition: AppBar.h:47
Bounds leadingRect() const
Suggested square icon slot at the bar's left edge.
Definition: AppBar.h:42
void draw(tinygpu::ISurface< RGB_T > &target) override
Definition: AppBar.h:53
Widget< RGB_T > * trailing
Definition: AppBar.h:27
void setTitle(const char *title)
Definition: AppBar.h:29
bool update(uint32_t nowMs) override
Definition: AppBar.h:103
void setColorOverride(RGB_T background, RGB_T foreground)
Definition: AppBar.h:34
AppBar(Bounds bounds, const char *title)
Definition: AppBar.h:24
Definition: AnchorLayout.h:4
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21