Theme system (#2164)

* Themes instead of Styles
* Colors changed to theme colors
* Reworked style management
* Theme settings app
* warn, menu dual set
* Added Aqua style
This commit is contained in:
Totoo
2024-05-27 21:02:52 +02:00
committed by GitHub
parent a8203a6372
commit ced8012783
143 changed files with 1566 additions and 1154 deletions

View File

@@ -41,8 +41,6 @@ namespace ui::external_app::analogtv {
/* AnalogTvView *******************************************************/
static const Style& style_options_group_new = Styles::bg_blue;
AnalogTvView::AnalogTvView(
NavigationView& nav)
: nav_(nav) {
@@ -140,13 +138,13 @@ void AnalogTvView::set_options_widget(std::unique_ptr<Widget> new_widget) {
options_widget = std::move(new_widget);
} else {
// TODO: Lame hack to hide options view due to my bad paint/damage algorithm.
options_widget = std::make_unique<Rectangle>(options_view_rect, style_options_group_new.background);
options_widget = std::make_unique<Rectangle>(options_view_rect, Theme::getInstance()->option_active->background);
}
add_child(options_widget.get());
}
void AnalogTvView::on_show_options_frequency() {
auto widget = std::make_unique<FrequencyOptionsView>(options_view_rect, &style_options_group_new);
auto widget = std::make_unique<FrequencyOptionsView>(options_view_rect, Theme::getInstance()->option_active);
widget->set_step(receiver_model.frequency_step());
widget->on_change_step = [this](rf::Frequency f) {
@@ -158,14 +156,14 @@ void AnalogTvView::on_show_options_frequency() {
};
set_options_widget(std::move(widget));
field_frequency.set_style(&style_options_group_new);
field_frequency.set_style(Theme::getInstance()->option_active);
}
void AnalogTvView::on_show_options_rf_gain() {
auto widget = std::make_unique<RadioGainOptionsView>(options_view_rect, &style_options_group_new);
auto widget = std::make_unique<RadioGainOptionsView>(options_view_rect, Theme::getInstance()->option_active);
set_options_widget(std::move(widget));
field_lna.set_style(&style_options_group_new);
field_lna.set_style(Theme::getInstance()->option_active);
}
void AnalogTvView::on_show_options_modulation() {
@@ -175,7 +173,7 @@ void AnalogTvView::on_show_options_modulation() {
tv.show_audio_spectrum_view(true);
set_options_widget(std::move(widget));
options_modulation.set_style(&style_options_group_new);
options_modulation.set_style(Theme::getInstance()->option_active);
}
void AnalogTvView::on_frequency_step_changed(rf::Frequency f) {

View File

@@ -30,7 +30,6 @@
#include "ui_freq_field.hpp"
#include "ui_tv.hpp"
#include "ui_record_view.hpp"
#include "ui_styles.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"

View File

@@ -44,13 +44,13 @@ class AudioTestView : public View {
bool beep{false};
Labels labels{
{{7 * 8, 3 * 16}, "Audio Beep Test", Color::light_grey()},
{{0 * 8, 6 * 16}, "Sample Rate (Hz):", Color::light_grey()},
{{25 * 8, 7 * 16}, "Step:", Color::light_grey()},
{{0 * 8, 8 * 16}, "Frequency (Hz):", Color::light_grey()},
{{0 * 8, 10 * 16}, "Duration (ms):", Color::light_grey()},
{{25 * 8, 10 * 16}, "0=con", Color::light_grey()},
{{0 * 8, 12 * 16}, "Volume:", Color::light_grey()}};
{{7 * 8, 3 * 16}, "Audio Beep Test", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 6 * 16}, "Sample Rate (Hz):", Theme::getInstance()->fg_light->foreground},
{{25 * 8, 7 * 16}, "Step:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 8 * 16}, "Frequency (Hz):", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 10 * 16}, "Duration (ms):", Theme::getInstance()->fg_light->foreground},
{{25 * 8, 10 * 16}, "0=con", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 12 * 16}, "Volume:", Theme::getInstance()->fg_light->foreground}};
OptionsField options_sample_rate{
{18 * 8, 6 * 16},
@@ -90,10 +90,10 @@ class AudioTestView : public View {
{21 * 8, 14 * 16, 2 * 8, 1 * 16},
&bitmap_icon_speaker_mute,
&bitmap_icon_speaker,
Color::light_grey(),
Color::dark_grey(),
Color::green(),
Color::dark_grey()};
Theme::getInstance()->fg_light->foreground,
Theme::getInstance()->bg_dark->background,
Theme::getInstance()->fg_green->foreground,
Theme::getInstance()->bg_dark->background};
};
} /* namespace ui */

View File

@@ -65,8 +65,8 @@ class CoasterPagerView : public View {
void on_tx_progress(const uint32_t progress, const bool done);
Labels labels{
{{1 * 8, 3 * 8}, "Syscall pager TX beta", Color::light_grey()},
{{1 * 8, 8 * 8}, LanguageHelper::currentMessages[LANG_DATADP], Color::light_grey()}};
{{1 * 8, 3 * 8}, "Syscall pager TX beta", Theme::getInstance()->fg_light->foreground},
{{1 * 8, 8 * 8}, LanguageHelper::currentMessages[LANG_DATADP], Theme::getInstance()->fg_light->foreground}};
SymField sym_data{
{7 * 8, 8 * 8},

View File

@@ -55,9 +55,9 @@ class ExtSensorsView : public View {
bool has_data = false;
Labels labels{
{{0 * 8, 3 * 16}, "GPS:", Color::light_grey()},
{{0 * 8, 5 * 16}, "ORI:", Color::light_grey()},
{{0 * 8, 7 * 16}, "ENV:", Color::light_grey()}};
{{0 * 8, 3 * 16}, "GPS:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 5 * 16}, "ORI:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 16}, "ENV:", Theme::getInstance()->fg_light->foreground}};
Text text_info{{0 * 8, 0 * 8, 30 * 8, 16 * 1}, "Connect a compatible module..."};
Text text_gps{{5 * 8, 3 * 16, 24 * 8, 16}, "-"};

View File

@@ -22,7 +22,6 @@
#include "ui_font_viewer.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "ui_styles.hpp"
#include "ui_painter.hpp"
#include "portapack.hpp"
@@ -57,8 +56,8 @@ uint16_t DebugFontsView::display_font(Painter& painter, uint16_t y_offset, const
void DebugFontsView::paint(Painter& painter) {
int16_t line_pos;
line_pos = display_font(painter, 32, &Styles::white, "Fixed 8x16");
display_font(painter, line_pos + 16, &Styles::white_small, "Fixed 5x8");
line_pos = display_font(painter, 32, Theme::getInstance()->bg_darkest, "Fixed 8x16");
display_font(painter, line_pos + 16, Theme::getInstance()->bg_darkest_small, "Fixed 5x8");
}
DebugFontsView::DebugFontsView(NavigationView& nav)

View File

@@ -114,8 +114,8 @@ class GpsSimAppView : public View {
ImageButton button_play{
{28 * 8, 2 * 16, 2 * 8, 1 * 16},
&bitmap_play,
Color::green(),
Color::black()};
Theme::getInstance()->fg_green->foreground,
Theme::getInstance()->fg_green->background};
spectrum::WaterfallView waterfall{};

View File

@@ -99,20 +99,20 @@ void RangeView::paint(Painter&) {
r = button_center.screen_rect();
p = r.center() + Point(0, r.height() / 2);
display.draw_line(p, p + Point(0, 10), Color::grey());
display.draw_line(p, p + Point(0, 10), Theme::getInstance()->fg_medium->foreground);
r = button_width.screen_rect();
c = r.top() + (r.height() / 2);
p = {r.left() - 64, c};
display.draw_line({r.left(), c}, p, Color::grey());
display.draw_line(p, p + Point(10, -10), Color::grey());
display.draw_line(p, p + Point(10, 10), Color::grey());
display.draw_line({r.left(), c}, p, Theme::getInstance()->fg_medium->foreground);
display.draw_line(p, p + Point(10, -10), Theme::getInstance()->fg_medium->foreground);
display.draw_line(p, p + Point(10, 10), Theme::getInstance()->fg_medium->foreground);
p = {r.right() + 64, c};
display.draw_line({r.right(), c}, p, Color::grey());
display.draw_line(p, p + Point(-10, -10), Color::grey());
display.draw_line(p, p + Point(-10, 10), Color::grey());
display.draw_line({r.right(), c}, p, Theme::getInstance()->fg_medium->foreground);
display.draw_line(p, p + Point(-10, -10), Theme::getInstance()->fg_medium->foreground);
display.draw_line(p, p + Point(-10, 10), Theme::getInstance()->fg_medium->foreground);
}
RangeView::RangeView(NavigationView& nav) {

View File

@@ -23,7 +23,6 @@
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_widget.hpp"
#include "ui_styles.hpp"
#include "ui_navigation.hpp"
#include "ui_tabview.hpp"
#include "transmitter_model.hpp"
@@ -54,13 +53,13 @@ class RangeView : public View {
uint32_t width{};
rf::Frequency center{};
const Style& style_info = Styles::grey;
const Style& style_info = *Theme::getInstance()->fg_medium;
Labels labels{
{{2 * 8, 8 * 8 + 4}, LanguageHelper::currentMessages[LANG_START], Color::light_grey()},
{{23 * 8, 8 * 8 + 4}, LanguageHelper::currentMessages[LANG_STOP], Color::light_grey()},
{{12 * 8, 5 * 8 - 4}, "Center", Color::light_grey()},
{{12 * 8 + 4, 13 * 8}, "Width", Color::light_grey()}};
{{2 * 8, 8 * 8 + 4}, LanguageHelper::currentMessages[LANG_START], Theme::getInstance()->fg_light->foreground},
{{23 * 8, 8 * 8 + 4}, LanguageHelper::currentMessages[LANG_STOP], Theme::getInstance()->fg_light->foreground},
{{12 * 8, 5 * 8 - 4}, "Center", Theme::getInstance()->fg_light->foreground},
{{12 * 8 + 4, 13 * 8}, "Width", Theme::getInstance()->fg_light->foreground}};
Checkbox check_enabled{
{1 * 8, 4},
@@ -120,8 +119,8 @@ class JammerView : public View {
int16_t mscounter = 0; // euquiq: Internal ms counter for do_timer()
lfsr_word_t lfsr_v = 1; // euquiq: Used to generate "random" Jitter
const Style& style_val = Styles::green;
const Style& style_cancel = Styles::red;
const Style& style_val = *Theme::getInstance()->fg_green;
const Style& style_cancel = *Theme::getInstance()->fg_red;
RangeView view_range_a{nav_};
RangeView view_range_b{nav_};
@@ -130,23 +129,23 @@ class JammerView : public View {
std::array<RangeView*, 3> range_views{{&view_range_a, &view_range_b, &view_range_c}};
TabView tab_view{
{"Range 1", Color::white(), range_views[0]},
{"Range 2", Color::white(), range_views[1]},
{"Range 3", Color::white(), range_views[2]},
{"Range 1", Theme::getInstance()->bg_darkest->foreground, range_views[0]},
{"Range 2", Theme::getInstance()->bg_darkest->foreground, range_views[1]},
{"Range 3", Theme::getInstance()->bg_darkest->foreground, range_views[2]},
};
Labels labels{
{{2 * 8, 23 * 8}, "Type:", Color::light_grey()},
{{1 * 8, 25 * 8}, "Speed:", Color::light_grey()},
{{3 * 8, 27 * 8}, "Hop:", Color::light_grey()},
{{4 * 8, 29 * 8}, "TX:", Color::light_grey()},
{{1 * 8, 31 * 8}, "Sle3p:", Color::light_grey()}, // euquiq: Token of appreciation to TheSle3p, which made this ehnancement a reality with his bounty.
{{0 * 8, 33 * 8}, "Jitter:", Color::light_grey()}, // Maybe the repository curator can keep the "mystype" for some versions.
{{11 * 8, 29 * 8}, "Secs.", Color::light_grey()},
{{11 * 8, 31 * 8}, "Secs.", Color::light_grey()},
{{11 * 8, 33 * 8}, "/60", Color::light_grey()},
{{2 * 8, 35 * 8}, "Gain:", Color::light_grey()},
{{11 * 8, 35 * 8}, "A:", Color::light_grey()}};
{{2 * 8, 23 * 8}, "Type:", Theme::getInstance()->fg_light->foreground},
{{1 * 8, 25 * 8}, "Speed:", Theme::getInstance()->fg_light->foreground},
{{3 * 8, 27 * 8}, "Hop:", Theme::getInstance()->fg_light->foreground},
{{4 * 8, 29 * 8}, "TX:", Theme::getInstance()->fg_light->foreground},
{{1 * 8, 31 * 8}, "Sle3p:", Theme::getInstance()->fg_light->foreground}, // euquiq: Token of appreciation to TheSle3p, which made this ehnancement a reality with his bounty.
{{0 * 8, 33 * 8}, "Jitter:", Theme::getInstance()->fg_light->foreground}, // Maybe the repository curator can keep the "mystype" for some versions.
{{11 * 8, 29 * 8}, "Secs.", Theme::getInstance()->fg_light->foreground},
{{11 * 8, 31 * 8}, "Secs.", Theme::getInstance()->fg_light->foreground},
{{11 * 8, 33 * 8}, "/60", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 35 * 8}, "Gain:", Theme::getInstance()->fg_light->foreground},
{{11 * 8, 35 * 8}, "A:", Theme::getInstance()->fg_light->foreground}};
OptionsField options_type{
{7 * 8, 23 * 8},

View File

@@ -76,11 +76,11 @@ class KeyfobView : public View {
void subaru_set_command(const uint32_t command);
Labels labels{
{{5 * 8, 1 * 16}, "Make:", Color::light_grey()},
{{2 * 8, 2 * 16}, "Command:", Color::light_grey()},
{{2 * 8, 4 * 16}, "Payload: #####", Color::light_grey()},
{{2 * 8, 7 * 16}, "Checksum is fixed just", Color::light_grey()},
{{2 * 8, 8 * 16}, "before transmission.", Color::light_grey()},
{{5 * 8, 1 * 16}, "Make:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 2 * 16}, "Command:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 4 * 16}, "Payload: #####", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 7 * 16}, "Checksum is fixed just", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 8 * 16}, "before transmission.", Theme::getInstance()->fg_light->foreground},
};
OptionsField options_make{

View File

@@ -237,7 +237,7 @@ LCRView::LCRView(NavigationView& nav) {
rectangle->set_parent_rect({static_cast<Coord>(98),
static_cast<Coord>(n * 32 + 66),
68, 20});
rectangle->set_color(ui::Color::grey());
rectangle->set_color(Theme::getInstance()->fg_medium->foreground);
rectangle->set_outline(true);
add_child(rectangle);

View File

@@ -105,8 +105,8 @@ class LCRView : public View {
std::string generate_message(std::string rgsb, std::vector<std::string> litterals, size_t option_ec);
Labels labels{
{{0, 8}, "EC: RGSB:", Color::light_grey()},
{{17 * 8, 4 * 8}, "List:", Color::light_grey()}};
{{0, 8}, "EC: RGSB:", Theme::getInstance()->fg_light->foreground},
{{17 * 8, 4 * 8}, "List:", Theme::getInstance()->fg_light->foreground}};
std::array<Button, LCR_MAX_AM> buttons{};
std::array<Checkbox, LCR_MAX_AM> checkboxes{};

View File

@@ -88,16 +88,16 @@ class LGEView : public View {
void on_tx_progress(const uint32_t progress, const bool done);
Labels labels{
//{ { 7 * 8, 1 * 8 }, "NO FUN ALLOWED !", Color::red() },
{{1 * 8, 1 * 8}, "Frame:", Color::light_grey()},
{{2 * 8, 3 * 8}, "Room:", Color::light_grey()},
{{14 * 8, 3 * 8}, "Text:", Color::light_grey()},
{{2 * 8, 5 * 8}, "Team:", Color::light_grey()},
{{0 * 8, 7 * 8}, "Player:", Color::light_grey()},
{{0 * 8, 10 * 8}, "Vest:", Color::light_grey()},
{{4 * 8, 12 * 8}, "ID:", Color::light_grey()},
{{3 * 8, 14 * 8}, "Pow: /10", Color::light_grey()},
{{2 * 8, 16 * 8}, "Time: x100ms", Color::light_grey()}};
//{ { 7 * 8, 1 * 8 }, "NO FUN ALLOWED !", Theme::getInstance()->error_dark->foreground },
{{1 * 8, 1 * 8}, "Frame:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 3 * 8}, "Room:", Theme::getInstance()->fg_light->foreground},
{{14 * 8, 3 * 8}, "Text:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 5 * 8}, "Team:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 8}, "Player:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 10 * 8}, "Vest:", Theme::getInstance()->fg_light->foreground},
{{4 * 8, 12 * 8}, "ID:", Theme::getInstance()->fg_light->foreground},
{{3 * 8, 14 * 8}, "Pow: /10", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 16 * 8}, "Time: x100ms", Theme::getInstance()->fg_light->foreground}};
OptionsField options_frame{
{7 * 8, 1 * 8},

View File

@@ -190,8 +190,8 @@ void SpectrumPainterView::paint(Painter& painter) {
painter.draw_bitmap(
pos,
bitmap_stripes,
ui::Color(191, 191, 0),
ui::Color::black());
Theme::getInstance()->fg_yellow->foreground,
Theme::getInstance()->fg_yellow->background);
if (c != 9)
pos += {24, 0};
else

View File

@@ -83,16 +83,16 @@ class SpectrumPainterView : public View {
std::array<View*, 2> input_views{{&input_image, &input_text}};
TabView tab_view{
{"Image", Color::white(), input_views[0]},
{"Text", Color::white(), input_views[1]}};
{"Image", Theme::getInstance()->bg_darkest->foreground, input_views[0]},
{"Text", Theme::getInstance()->bg_darkest->foreground, input_views[1]}};
static constexpr int32_t footer_location = 15 * 16 + 8;
ProgressBar progressbar{
{4, footer_location - 16, 240 - 8, 16}};
Labels labels{
{{10 * 8, footer_location + 1 * 16}, "GAIN A:", Color::light_grey()},
{{1 * 8, footer_location + 2 * 16}, "BW: Du: P:", Color::light_grey()},
{{10 * 8, footer_location + 1 * 16}, "GAIN A:", Theme::getInstance()->fg_light->foreground},
{{1 * 8, footer_location + 2 * 16}, "BW: Du: P:", Theme::getInstance()->fg_light->foreground},
};
TxFrequencyField field_frequency{
@@ -122,8 +122,8 @@ class SpectrumPainterView : public View {
ImageButton button_play{
{28 * 8, footer_location + 1 * 16, 2 * 8, 1 * 16},
&bitmap_play,
Color::green(),
Color::black()};
Theme::getInstance()->fg_green->foreground,
Theme::getInstance()->fg_green->background};
OptionsField option_bandwidth{
{4 * 8, footer_location + 2 * 16},

View File

@@ -96,7 +96,7 @@ static void rect(int x1, int y1, int x2, int y2, int color) {
};
static void printf(std::string str) {
auto style = (fg_color == White) ? ui::Styles::white : ui::Styles::bg_white;
auto style = (fg_color == White) ? *ui::Theme::getInstance()->bg_darkest : *ui::Theme::getInstance()->bg_lightest;
painter.draw_string({x_pos, y_pos - 1}, style, str);
};

View File

@@ -26,7 +26,6 @@
#include "event_m0.hpp"
#include "message.hpp"
#include "irq_controls.hpp"
#include "ui_styles.hpp"
#include "random.hpp"
#include "lpc43xx_cpp.hpp"
#include "limits.h"