Auto layout of top status icons (#1178)

* WIP - updated pmem

* WIP status tray auto layout

* Add settings page for icons

* Add ui_config2 to pmem dump

---------

Co-authored-by: kallanreed <kallanreed@noreply.github.com>
This commit is contained in:
Kyle Reed 2023-06-23 16:13:39 -07:00 committed by GitHub
parent 6b0f90c321
commit e08273b8b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 632 additions and 360 deletions

View file

@ -500,6 +500,8 @@ class Image : public Widget {
void paint(Painter& painter) override;
const Bitmap& bitmap() & { return *bitmap_; }
private:
const Bitmap* bitmap_;
Color foreground_;
@ -520,6 +522,49 @@ class ImageButton : public Image {
bool on_touch(const TouchEvent event) override;
};
/* A button that toggles between two images when set. */
class ImageToggle : public ImageButton {
public:
std::function<void(bool value)> on_change{};
ImageToggle(
Rect parent_rect,
const Bitmap* bitmap_);
ImageToggle(
Rect parent_rect,
const Bitmap* bitmap_,
Color foreground_true,
Color foreground_false,
Color background_);
ImageToggle(
Rect parent_rect,
const Bitmap* bitmap_true,
const Bitmap* bitmap_false,
Color foreground_true,
Color background_true,
Color foreground_false,
Color background_false);
ImageToggle(const ImageToggle&) = delete;
ImageToggle& operator=(const ImageToggle&) = delete;
bool value() const;
void set_value(bool b);
private:
// Hide this field.
using ImageButton::on_select;
const Bitmap* bitmap_true_;
const Bitmap* bitmap_false_;
const Color foreground_true_;
const Color background_true_;
const Color foreground_false_;
const Color background_false_;
bool value_;
};
class ImageOptionsField : public Widget {
public:
using value_t = int32_t;