mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-04-18 06:56:03 -04:00
Removed rec button, added rainbow button
This commit is contained in:
parent
794ba9ccb9
commit
4388cc29a5
33
firmware/application/external/gfxeq/ui_gfxeq.cpp
vendored
33
firmware/application/external/gfxeq/ui_gfxeq.cpp
vendored
@ -12,6 +12,30 @@ using namespace portapack;
|
||||
|
||||
namespace ui::external_app::gfxeq {
|
||||
|
||||
void RainbowButton::paint(Painter& painter) {
|
||||
Rect button_rect = screen_rect();
|
||||
int width = button_rect.width();
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
float hue = static_cast<float>(x) / width * 360.0f;
|
||||
uint8_t r, g, b;
|
||||
if (hue < 120) {
|
||||
r = hue < 60 ? 255 : (120 - hue) * 4.25;
|
||||
g = hue < 60 ? hue * 4.25 : 255;
|
||||
b = 0;
|
||||
} else if (hue < 240) {
|
||||
r = 0;
|
||||
g = hue < 180 ? (hue - 120) * 4.25 : (240 - hue) * 4.25;
|
||||
b = hue < 180 ? 255 : (240 - hue) * 4.25;
|
||||
} else {
|
||||
r = (hue - 240) * 4.25;
|
||||
g = 0;
|
||||
b = hue < 300 ? 255 : (360 - hue) * 4.25;
|
||||
}
|
||||
painter.fill_rectangle({button_rect.left() + x, button_rect.top(), 1, button_rect.height()}, Color(r, g, b));
|
||||
}
|
||||
}
|
||||
|
||||
gfxEQView::gfxEQView(NavigationView& nav)
|
||||
: nav_{nav}, bar_heights(NUM_BARS, 0), prev_bar_heights(NUM_BARS, 0) {
|
||||
std::vector<BoundSetting> bindings;
|
||||
@ -20,8 +44,8 @@ gfxEQView::gfxEQView(NavigationView& nav)
|
||||
|
||||
baseband::run_image(spi_flash::image_tag_wfm_audio);
|
||||
|
||||
add_children({&field_frequency, &field_lna, &field_vga, &options_modulation,
|
||||
&field_volume, &text_ctcss, &record_view, &button_mood, &dummy});
|
||||
add_children({&options_modulation, &field_frequency, &field_lna, &field_vga,
|
||||
&field_volume, &button_mood, &text_ctcss, &dummy});
|
||||
|
||||
field_lna.on_show_options = [this]() { this->on_show_options_rf_gain(); };
|
||||
field_vga.on_show_options = [this]() { this->on_show_options_rf_gain(); };
|
||||
@ -51,7 +75,7 @@ gfxEQView::~gfxEQView() {
|
||||
}
|
||||
|
||||
void gfxEQView::focus() {
|
||||
field_frequency.focus();
|
||||
options_modulation.focus();
|
||||
}
|
||||
|
||||
void gfxEQView::start() {
|
||||
@ -122,6 +146,8 @@ void gfxEQView::on_modulation_changed(ReceiverModel::Mode modulation) {
|
||||
update_modulation(modulation);
|
||||
on_show_options_modulation();
|
||||
start();
|
||||
remove_options_widget();
|
||||
options_modulation.focus();
|
||||
}
|
||||
|
||||
void gfxEQView::on_show_options_rf_gain() {
|
||||
@ -174,6 +200,7 @@ void gfxEQView::remove_options_widget() {
|
||||
field_lna.set_style(nullptr);
|
||||
options_modulation.set_style(nullptr);
|
||||
field_frequency.set_style(nullptr);
|
||||
nav_.set_dirty();
|
||||
}
|
||||
|
||||
void gfxEQView::set_options_widget(std::unique_ptr<Widget> new_widget) {
|
||||
|
@ -15,6 +15,12 @@
|
||||
|
||||
namespace ui::external_app::gfxeq {
|
||||
|
||||
class RainbowButton : public Button {
|
||||
public:
|
||||
RainbowButton(Rect parent_rect, std::string text) : Button{parent_rect, text} {}
|
||||
void paint(Painter& painter) override;
|
||||
};
|
||||
|
||||
class gfxEQView : public View {
|
||||
public:
|
||||
gfxEQView(NavigationView& nav);
|
||||
@ -92,7 +98,7 @@ class gfxEQView : public View {
|
||||
4};
|
||||
const Rect options_view_rect{0 * 8, 1 * 16, 30 * 8, 1 * 16};
|
||||
std::unique_ptr<Widget> options_widget{};
|
||||
Button button_mood{{21 * 8, 0, 6 * 8, 16}, "MOOD"};
|
||||
RainbowButton button_mood{{21 * 8, 0, 6 * 8, 16}, ""};
|
||||
Button dummy{{240, 0, 0, 0}, ""};
|
||||
|
||||
RxRadioState rx_radio_state_{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user