Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx 2023-05-19 08:16:05 +12:00 committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
599 changed files with 70746 additions and 66896 deletions

View file

@ -36,91 +36,89 @@
namespace ui {
struct MenuItem {
std::string text;
ui::Color color;
const Bitmap* bitmap;
std::function<void(KeyEvent)> on_select;
std::string text;
ui::Color color;
const Bitmap* bitmap;
std::function<void(KeyEvent)> on_select;
// TODO: Prevent default-constructed MenuItems.
// I managed to construct a menu with three extra, unspecified menu items
// in the array that were default constructed...
// TODO: Prevent default-constructed MenuItems.
// I managed to construct a menu with three extra, unspecified menu items
// in the array that were default constructed...
};
class MenuItemView : public Widget {
public:
MenuItemView(
bool keep_highlight
) : keep_highlight { keep_highlight }
{
}
MenuItemView(const MenuItemView&) = delete;
MenuItemView(MenuItemView&&) = delete;
MenuItemView& operator=(const MenuItemView&) = delete;
MenuItemView& operator=(MenuItemView&&) = delete;
public:
MenuItemView(
bool keep_highlight)
: keep_highlight{keep_highlight} {
}
void paint(Painter& painter) override;
void set_item(MenuItem* item_);
MenuItemView(const MenuItemView&) = delete;
MenuItemView(MenuItemView&&) = delete;
MenuItemView& operator=(const MenuItemView&) = delete;
MenuItemView& operator=(MenuItemView&&) = delete;
void highlight();
void unhighlight();
void paint(Painter& painter) override;
private:
MenuItem* item { nullptr };
bool keep_highlight = false;
void set_item(MenuItem* item_);
void highlight();
void unhighlight();
private:
MenuItem* item{nullptr};
bool keep_highlight = false;
};
class MenuView : public View {
public:
std::function<void(void)> on_left { };
std::function<void(void)> on_highlight { nullptr };
public:
std::function<void(void)> on_left{};
std::function<void(void)> on_highlight{nullptr};
MenuView(Rect new_parent_rect = { 0, 0, 240, 304 }, bool keep_highlight = false);
~MenuView();
MenuView(Rect new_parent_rect = {0, 0, 240, 304}, bool keep_highlight = false);
void add_item(MenuItem new_item);
void add_items(std::initializer_list<MenuItem> new_items);
void clear();
size_t item_count() const;
MenuItemView* item_view(size_t index) const;
~MenuView();
bool set_highlighted(int32_t new_value);
uint32_t highlighted_index() const;
void add_item(MenuItem new_item);
void add_items(std::initializer_list<MenuItem> new_items);
void clear();
size_t item_count() const;
void set_parent_rect(const Rect new_parent_rect) override;
void on_focus() override;
void on_blur() override;
bool on_key(const KeyEvent event) override;
bool on_encoder(const EncoderEvent event) override;
private:
void update_items();
void on_tick_second();
bool keep_highlight { false };
SignalToken signal_token_tick_second { };
std::vector<MenuItem> menu_items { };
std::vector<MenuItemView*> menu_item_views { };
Image arrow_more {
{ 228, 320 - 8, 8, 8 },
&bitmap_more,
Color::white(),
Color::black()
};
MenuItemView* item_view(size_t index) const;
const size_t item_height = 24;
bool blink = false;
bool more = false;
size_t displayed_max { 0 };
size_t highlighted_item { 0 };
size_t offset { 0 };
bool set_highlighted(int32_t new_value);
uint32_t highlighted_index() const;
void set_parent_rect(const Rect new_parent_rect) override;
void on_focus() override;
void on_blur() override;
bool on_key(const KeyEvent event) override;
bool on_encoder(const EncoderEvent event) override;
private:
void update_items();
void on_tick_second();
bool keep_highlight{false};
SignalToken signal_token_tick_second{};
std::vector<MenuItem> menu_items{};
std::vector<MenuItemView*> menu_item_views{};
Image arrow_more{
{228, 320 - 8, 8, 8},
&bitmap_more,
Color::white(),
Color::black()};
const size_t item_height = 24;
bool blink = false;
bool more = false;
size_t displayed_max{0};
size_t highlighted_item{0};
size_t offset{0};
};
} /* namespace ui */
#endif/*__UI_MENU_H__*/
#endif /*__UI_MENU_H__*/