5#include "TinyGPU/Color/RGB565.h"
6#include "TinyGPU/Color/RGB666.h"
7#include "TinyGPU/Color/RGB888.h"
8#include "TinyMaterialDesign/Core/Widget.h"
9#include "TinyMaterialDesign/Draw/Icons.h"
20 this->bounds = bounds;
29 void draw(tinygpu::ISurface<RGB_T>& target)
override {
30 RGB_T ring = selected_ ?
this->theme().colors.primary :
this->theme().colors.outline;
31 RGB_T dot =
this->theme().colors.primary;
33 ring = blend(ring,
this->theme().colors.surface, 0.5f);
34 dot = blend(dot,
this->theme().colors.surface, 0.4f);
37 const int32_t diameter =
this->bounds.w <
this->bounds.h ?
this->bounds.w :
this->bounds.h;
38 target.drawCircle(toPx(
this->bounds.centerX()), toPx(
this->bounds.centerY()),
39 toPx(diameter / 2), ring);
41 drawDot(target,
this->bounds, dot);
45 bool onGesture(
const tinygpu::GestureEvent& event)
override {
46 if (!isTapGesture(event.type))
return false;
49 if (onSelected) onSelected();
55 bool selected_ =
false;
71 const int index =
static_cast<
int>(buttons_.size());
72 buttons_.push_back(&button);
73 button.onSelected = [
this, index]() { select(index); };
77 for (size_t i = 0; i < buttons_.size(); ++i) {
78 if (buttons_[i]->selected())
return static_cast<
int>(i);
84 std::vector<RadioButton<RGB_T>*> buttons_;
86 void select(
int index) {
87 for (size_t i = 0; i < buttons_.size(); ++i) {
88 buttons_[i]->setSelected(
static_cast<
int>(i) == index);
90 if (onChange) onChange(index);
Coordinates a set of RadioButtons so selecting one deselects the rest. Not itself a Widget - each Rad...
Definition: RadioButton.h:66
void addButton(RadioButton< RGB_T > &button)
Definition: RadioButton.h:70
int selectedIndex() const
Definition: RadioButton.h:76
std::function< void(int)> onChange
Definition: RadioButton.h:68
Definition: AnchorLayout.h:4
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21