Merge pull request #161 from dqs105/mic_tx_rfgain

Added TX Gain control & code simplification
This commit is contained in:
Erwin Ried
2020-09-14 22:50:35 +02:00
committed by GitHub
4 changed files with 288 additions and 43 deletions

View File

@@ -827,9 +827,11 @@ bool Checkbox::on_touch(const TouchEvent event) {
Button::Button(
Rect parent_rect,
std::string text
std::string text,
bool instant_exec
) : Widget { parent_rect },
text_ { text }
text_ { text },
instant_exec_ { instant_exec }
{
set_focusable(true);
}
@@ -899,15 +901,24 @@ bool Button::on_touch(const TouchEvent event) {
case TouchEvent::Type::Start:
set_highlighted(true);
set_dirty();
if( on_touch_press) {
on_touch_press(*this);
}
if( on_select && instant_exec_ ) {
on_select(*this);
}
return true;
case TouchEvent::Type::End:
set_highlighted(false);
set_dirty();
if( on_select ) {
if( on_select && !instant_exec_ ) {
on_select(*this);
}
if( on_touch_release) {
on_touch_release(*this);
}
return true;
default:

View File

@@ -378,10 +378,18 @@ private:
class Button : public Widget {
public:
std::function<void(Button&)> on_select { };
std::function<void(Button&)> on_touch_release { }; // Executed when releasing touch, after on_select.
std::function<void(Button&)> on_touch_press { }; // Executed when touching, before on_select.
std::function<bool(Button&, KeyEvent)> on_dir { };
std::function<void(Button&)> on_highlight { };
Button(Rect parent_rect, std::string text);
Button(Rect parent_rect, std::string text, bool instant_exec); // instant_exec: Execute on_select when you touching instead of releasing
Button(
Rect parent_rect,
std::string text
) : Button { parent_rect, text, false }
{
}
Button(
) : Button { { }, { } }
@@ -399,6 +407,7 @@ public:
private:
std::string text_;
bool instant_exec_ { false };
};
class NewButton : public Widget {