Compare commits

...

3 Commits

Author SHA1 Message Date
Mark Thompson 76948cffa8 Improve visibility of green icons on white background (#1196) 2023-06-27 10:19:34 +02:00
Mark Thompson 4ea8abb53b Limit title length when too many status icons & shade background of every other icon (#1195)
* Shading alternate icon backgrounds on title bar

* Shading alternate icons on title bar

* Shading alternate icons on title bar

* Clang
2023-06-27 10:15:58 +02:00
gullradriel 32085f317b adding one more character to modulation widget for spec (#1193)
Co-authored-by: GullCode <gullradriel@hotmail.com>
2023-06-27 10:02:04 +02:00
5 changed files with 26 additions and 11 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ class LevelView : public View {
OptionsField field_mode{
{15 * 8, 1 * 16},
3,
4,
{}};
OptionsField step_mode{
+18 -9
View File
@@ -110,6 +110,12 @@ StatusTray::StatusTray(Point pos)
set_focusable(false);
}
void StatusTray::add_button(ImageButton* child) {
child->set_background((shading_) ? Color::dark_grey() : Color::darker_grey());
shading_ = !shading_;
add(child);
}
void StatusTray::add(Widget* child) {
width_ += child->parent_rect().width();
add_child(child);
@@ -136,6 +142,7 @@ void StatusTray::clear() {
child->set_parent(nullptr);
children_.clear();
width_ = 0;
shading_ = false;
set_parent_rect({pos_, {width_, height}});
set_dirty();
}
@@ -216,17 +223,17 @@ void SystemStatusView::refresh() {
// NB: Order of insertion is the display order Left->Right.
// TODO: Might be better to support hide and only add once.
status_icons.clear();
if (!pmem::ui_hide_camera()) status_icons.add(&button_camera);
if (!pmem::ui_hide_sleep()) status_icons.add(&button_sleep);
if (!pmem::ui_hide_stealth()) status_icons.add(&button_stealth);
if (!pmem::ui_hide_converter()) status_icons.add(&button_converter);
if (!pmem::ui_hide_bias_tee()) status_icons.add(&button_bias_tee);
if (!pmem::ui_hide_clock()) status_icons.add(&button_clock_status);
if (!pmem::ui_hide_mute()) status_icons.add(&button_mute);
if (!pmem::ui_hide_camera()) status_icons.add_button(&button_camera);
if (!pmem::ui_hide_sleep()) status_icons.add_button(&button_sleep);
if (!pmem::ui_hide_stealth()) status_icons.add_button(&button_stealth);
if (!pmem::ui_hide_converter()) status_icons.add_button(&button_converter);
if (!pmem::ui_hide_bias_tee()) status_icons.add_button(&button_bias_tee);
if (!pmem::ui_hide_clock()) status_icons.add_button(&button_clock_status);
if (!pmem::ui_hide_mute()) status_icons.add_button(&button_mute);
// Display "Disable speaker" icon only if AK4951 Codec which has separate speaker/headphone control
if (audio::speaker_disable_supported() && !pmem::ui_hide_speaker())
status_icons.add(&button_speaker);
status_icons.add_button(&button_speaker);
if (!pmem::ui_hide_sd_card()) status_icons.add(&sd_card_status_view);
status_icons.update_layout();
@@ -297,7 +304,9 @@ void SystemStatusView::set_title(const std::string new_value) {
if (new_value.empty()) {
title.set(default_title);
} else {
title.set(new_value);
// Limit length of title string to prevent partial characters if too many StatusView icons
size_t max_len = (240 - 16 - 7 - status_icons.width()) / 8;
title.set(truncate(new_value, max_len));
}
}
+3
View File
@@ -131,10 +131,12 @@ class StatusTray : public View {
StatusTray(const StatusTray&) = delete;
StatusTray& operator=(const StatusTray&) = delete;
void add_button(ImageButton* child);
void add(Widget* child);
void update_layout();
void clear();
void paint(Painter& painter) override;
uint8_t width() { return width_; };
private:
static constexpr uint8_t height = 16;
@@ -142,6 +144,7 @@ class StatusTray : public View {
// track of the right edge.
const Point pos_{};
uint8_t width_{};
bool shading_{};
};
class SystemStatusView : public View {
+3
View File
@@ -140,6 +140,9 @@ struct Color {
static constexpr Color dark_grey() {
return {63, 63, 63};
}
static constexpr Color darker_grey() {
return {31, 31, 31};
}
static constexpr Color purple() {
return {204, 0, 102};
+1 -1
View File
@@ -80,7 +80,7 @@ int Painter::draw_string(
void Painter::draw_bitmap(Point p, const Bitmap& bitmap, Color foreground, Color background) {
// If bright foreground colors on white background, darken the foreground color to improve visibility
if ((background.v == ui::Color::white().v) && (foreground.to_greyscale() > 175))
if ((background.v == ui::Color::white().v) && (foreground.to_greyscale() > 146))
foreground = foreground.dark();
display.draw_bitmap(p, bitmap.size, bitmap.data, foreground, background);