3D buttons, to make UI clearer

This commit is contained in:
furrtek 2016-12-09 02:35:50 +01:00
parent 843c465c73
commit 75e8a664b0
13 changed files with 63 additions and 36 deletions

View File

@ -98,7 +98,7 @@ uint16_t gen_PSN(const char * psname, const RDS_flags * rds_flags) {
// 4 groups with 2 PSN characters in each
for (c = 0; c < 4; c++)
make_0B_group(&group[c][0], rds_flags->PI_code, rds_flags->TP, rds_flags->PTY, rds_flags->TA, rds_flags->MS, rds_flags->DI, c, &psname[c * 2]);
make_0B_group(&group[c][0], rds_flags->PI_code, rds_flags->TP, rds_flags->PTY, rds_flags->TA, rds_flags->MS, rds_flags->DI, c, &psname[c * 2]);
// Generate checkbits for each block of each group
for (c = 0; c < 4; c++) {

View File

@ -64,13 +64,13 @@ private:
const Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::green(),
};
const Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::red(),
};
Text text_format {

View File

@ -53,14 +53,14 @@ AlphanumView::AlphanumView(
static constexpr Style style_alpha {
.font = font::fixed_8x16,
.background = Color(191,31,31),
.foreground = Color::black()
.background = Color::black(),
.foreground = Color(191,31,31)
};
static constexpr Style style_num {
.font = font::fixed_8x16,
.background = Color(191,191,31),
.foreground = Color::black()
.background = Color::black(),
.foreground = Color(191,191,31)
};
txtidx = strlen(txt);

View File

@ -256,13 +256,13 @@ private:
const Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::green(),
};
const Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::red(),
};
const Style style_address {

View File

@ -98,13 +98,13 @@ private:
const Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::green(),
};
const Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::red(),
};
std::array<Button, 5> buttons;

View File

@ -105,7 +105,7 @@ SystemStatusView::SystemStatusView() {
}
void SystemStatusView::set_back_enabled(bool new_value) {
button_back.set_text(new_value ? back_text_enabled : back_text_disabled);
//button_back.set_text(new_value ? back_text_enabled : back_text_disabled);
button_back.set_focusable(new_value);
}

View File

@ -57,12 +57,12 @@ public:
private:
static constexpr auto default_title = "PortaPack|Havoc";
static constexpr auto back_text_enabled = " < ";
static constexpr auto back_text_disabled = " * ";
//static constexpr auto back_text_enabled = " < ";
//static constexpr auto back_text_disabled = " * ";
Button button_back {
{ 0 * 8, 0 * 16, 3 * 8, 16 },
back_text_disabled,
{ 0 * 8, 0 * 16, 20, 16 },
"", //back_text_disabled,
};
Text title {

View File

@ -56,8 +56,8 @@ private:
Style style_red {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black()
.background = Color::black(),
.foreground = Color::red()
};
NavigationView& nav_;

View File

@ -81,6 +81,12 @@ RDSView::RDSView(NavigationView& nav) {
strcpy(PSN, "TEST1234");
strcpy(RadioText, "Radiotext test ABCD1234");
rds_flags.DI = false;
rds_flags.MS = false;
rds_flags.PI_code = 0x1337;
rds_flags.TA = false;
rds_flags.TP = true;
add_children({ {
&field_frequency,
&options_pty,
@ -110,7 +116,6 @@ RDSView::RDSView(NavigationView& nav) {
};
};
options_pty.set_selected_index(0); // None
options_countrycode.set_selected_index(18); // France
options_coverage.set_selected_index(0); // Local
@ -118,6 +123,8 @@ RDSView::RDSView(NavigationView& nav) {
rds_flags.PTY = v;
};
options_pty.set_selected_index(0); // None
button_editpsn.on_select = [this,&nav](Button&) {
textentry(nav, PSN, 8);
};

View File

@ -171,6 +171,7 @@ private:
const char ccir_base[21] = "0000000000B0000B0000";
/*
const char xylos_sequence[9][21] = {
"0E0E18920EB1E10B0E0E",
"0E0E1890E0B0E12B0E0E",
@ -179,9 +180,9 @@ private:
"0E0E18920EB1E10B0E0E",
"0E0E18920EB1E10B0E0E",
"0E0E181AEAB10E0B0E0E",
"0E01E81AEAB10E0B0E0E", // 2016-05-22 05:22:29 0E01E81AEA/10E0/0E0E
"0E01E81AEAB10E0B0E0E",
"0E03181AEAB10E0B0E0E"
};
};*/
unsigned int sequence_idx;
@ -192,13 +193,13 @@ private:
const Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::green(),
};
const Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
.background = Color::black(),
.foreground = Color::red(),
};
const Style style_grey {
.font = font::fixed_8x16,

View File

@ -92,10 +92,18 @@ struct Color {
return { 255, 255, 255 };
}
static constexpr Color grey() {
static constexpr Color light_grey() {
return { 127, 127, 127 };
}
static constexpr Color grey() {
return { 91, 91, 91 };
}
static constexpr Color dark_grey() {
return { 63, 63, 63 };
}
static constexpr Color purple() {
return { 204, 0, 102 };
}

View File

@ -671,14 +671,25 @@ std::string Button::text() const {
}
void Button::paint(Painter& painter) {
Color bg, fg;
const auto r = screen_rect();
const auto paint_style = (has_focus() || highlighted()) ? style().invert() : style();
painter.draw_rectangle(r, paint_style.foreground);
if (has_focus() || highlighted()) {
bg = style().foreground;
fg = Color::black();
} else {
bg = Color::grey();
fg = style().foreground;
}
const Style paint_style = { style().font, bg, fg };
painter.draw_rectangle({r.pos, {r.size.w, 1}}, Color::light_grey());
painter.draw_rectangle({r.pos.x, r.pos.y + r.size.h - 1, r.size.w, 1}, Color::dark_grey());
painter.draw_rectangle({r.pos.x + r.size.w - 1, r.pos.y, 1, r.size.h}, Color::dark_grey());
painter.fill_rectangle(
{ r.pos.x + 1, r.pos.y + 1, r.size.w - 2, r.size.h - 2 },
{ r.pos.x, r.pos.y + 1, r.size.w - 1, r.size.h - 2 },
paint_style.background
);

Binary file not shown.