Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(color): allow all UI controls for widgets when full screen #5808

Merged
merged 25 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
62695a7
Allow UI controls in App Mode widget when full screen.
Jan 20, 2025
bbabb0c
Allow any full screen widget to use all controls.
Jan 20, 2025
c467346
Fix for using Lvgl widgets using only rotary encoder and keys.
Jan 21, 2025
1ba857c
Update comments.
Jan 21, 2025
9c97e7c
Fix 'page' object for full screen widgets.
Jan 22, 2025
3ab73ea
Fix layout creation. Allow button press function to return checked st…
Jan 22, 2025
4b035b8
Add long press function for buttons.
Jan 22, 2025
958a253
Allow event bubble on 'box' object. Don't allow 'setting' object unle…
Jan 22, 2025
d75e713
Fix for negative 'min' is slider object.
Jan 22, 2025
026c78c
Add 'enable', 'disable' and 'active' functions.
Jan 22, 2025
8347ae2
Add 'checked' property to button object.
Jan 23, 2025
369f50d
Add 'getContext' function.
Jan 23, 2025
97e1efb
Fix 'set' function for button.
Jan 23, 2025
63a8863
Update slider and toggle switch if value changes.
Jan 23, 2025
e9039a3
Bug fixes
Jan 23, 2025
d91551e
Add 'momentartButton' control.
Jan 24, 2025
bc6997e
Fix RE events for non-lvgl widgets when running full screen. Add 'exi…
Jan 27, 2025
04d1dbb
Add 'cornerRadius', 'color' and 'textColor' properties to buttons.
Jan 27, 2025
74731c7
Add 'verticalSlider' control. Allow font to be set on buttons. Fix 'a…
Jan 28, 2025
200ebd5
Add 'filter' property to source picker.
Jan 30, 2025
48641b1
Rename 'SRC_NONE' to 'SRC_CLEAR'.
Jan 30, 2025
ac810db
Add 'filter' property to switch picker.
Jan 30, 2025
83bef3b
Add 'color' setting to slider control.
Jan 30, 2025
815679a
Fix instruction limit being applied incorrectly to widgets.
Feb 1, 2025
8ed0eca
Fix B&W build.
Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,16 @@ enum SwitchSources {
SWSRC_INVERT SKIP = SWSRC_COUNT+1,
};

enum SwitchTypes {
SW_SWITCH = 1 << 0,
SW_TRIM = 1 << 1,
SW_LOGICAL_SWITCH = 1 << 2,
SW_FLIGHT_MODE = 1 << 3,
SW_TELEM = 1 << 4,
SW_OTHER = 1 << 5,
SW_NONE = 1 << 20,
};

enum MixSources {
MIXSRC_NONE,

Expand Down Expand Up @@ -563,6 +573,31 @@ enum MixSources {
#define MIXSRC_FIRST_FS_SWITCH (MIXSRC_LAST_REGULAR_SWITCH + 1)
#endif

enum SrcTypes {
SRC_INPUT = 1 << 0,
SRC_LUA = 1 << 1,
SRC_STICK = 1 << 2,
SRC_POT = 1 << 3,
SRC_TILT = 1 << 4,
SRC_SPACEMOUSE = 1 << 5,
SRC_MINMAX = 1 << 6,
SRC_HELI = 1 << 7,
SRC_TRIM = 1 << 8,
SRC_SWITCH = 1 << 9,
SRC_FUNC_SWITCH = 1 << 10,
SRC_LOGICAL_SWITCH = 1 << 11,
SRC_TRAINER = 1 << 12,
SRC_CHANNEL = 1 << 13,
SRC_CHANNEL_ALL = 1 << 14,
SRC_GVAR = 1 << 15,
SRC_TX = 1 << 16,
SRC_TIMER = 1 << 17,
SRC_TELEM = 1 << 18,
SRC_TELEM_COMP = 1 << 19,
SRC_NONE = 1 << 20,
SRC_INVERT = 1 << 21,
};

enum BacklightMode {
e_backlight_mode_off = 0,
e_backlight_mode_keys = 1,
Expand Down
4 changes: 0 additions & 4 deletions radio/src/gui/colorlcd/controls/sourcechoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ class SourceChoiceMenuToolbar : public MenuToolbar
[=](int16_t index) {
if (index >= MIXSRC_FIRST_POT && index <= MIXSRC_LAST_POT)
return false;
#if MAX_AXIS > 0
if (index >= MIXSRC_FIRST_AXIS && index <= MIXSRC_LAST_AXIS)
return false;
#endif
return index >= MIXSRC_FIRST_STICK && index <= lastSource;
},
STR_MENU_STICKS);
Expand Down
38 changes: 38 additions & 0 deletions radio/src/gui/colorlcd/libui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "static.h"
#include "etx_lv_theme.h"

//-----------------------------------------------------------------------------

static void button_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
{
etx_btn_style(obj, LV_PART_MAIN);
Expand Down Expand Up @@ -51,6 +53,8 @@ Button::Button(Window* parent, const rect_t& rect,
{
}

//-----------------------------------------------------------------------------

ButtonBase::ButtonBase(Window* parent, const rect_t& rect,
std::function<uint8_t(void)> pressHandler,
LvglCreate objConstruct) :
Expand Down Expand Up @@ -97,6 +101,8 @@ void ButtonBase::checkEvents()
if (checkHandler) checkHandler();
}

//-----------------------------------------------------------------------------

TextButton::TextButton(Window* parent, const rect_t& rect, std::string text,
std::function<uint8_t(void)> pressHandler) :
ButtonBase(parent, rect, pressHandler, button_create),
Expand All @@ -107,6 +113,8 @@ TextButton::TextButton(Window* parent, const rect_t& rect, std::string text,
lv_obj_center(label);
}

//-----------------------------------------------------------------------------

IconButton::IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y,
std::function<uint8_t(void)> pressHandler) :
ButtonBase(parent, {x, y, EdgeTxStyles::UI_ELEMENT_HEIGHT, EdgeTxStyles::UI_ELEMENT_HEIGHT}, pressHandler, button_create)
Expand All @@ -117,3 +125,33 @@ IconButton::IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y,
}

void IconButton::setIcon(EdgeTxIcon icon) { iconImage->setIcon(icon); }

//-----------------------------------------------------------------------------

MomentaryButton::MomentaryButton(Window* parent, const rect_t& rect, std::string text,
std::function<void(void)> pressHandler,
std::function<void(void)> releaseHandler) :
FormField(parent, rect, button_create),
pressHandler(std::move(pressHandler)),
releaseHandler(std::move(releaseHandler)),
text(std::move(text))
{
label = lv_label_create(lvobj);
lv_label_set_text(label, this->text.c_str());
lv_obj_center(label);
}

void MomentaryButton::onPressed()
{
if (pressHandler)
pressHandler();
lv_obj_add_state(lvobj, LV_STATE_CHECKED);
lv_obj_clear_state(lvobj, LV_STATE_PRESSED);
}

void MomentaryButton::onReleased()
{
if (releaseHandler)
releaseHandler();
lv_obj_clear_state(lvobj, LV_STATE_CHECKED);
}
45 changes: 43 additions & 2 deletions radio/src/gui/colorlcd/libui/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class TextButton : public ButtonBase
}
}

void setFont(FontIndex font)
{
etx_font(label, font);
}

void setWrap()
{
lv_obj_set_width(label, lv_pct(100));
Expand All @@ -102,9 +107,8 @@ class TextButton : public ButtonBase
}

protected:
lv_obj_t* label = nullptr;

std::string text;
lv_obj_t* label = nullptr;
};

class IconButton : public ButtonBase
Expand All @@ -118,3 +122,40 @@ class IconButton : public ButtonBase
protected:
StaticIcon* iconImage = nullptr;
};

// Button class that is in checked state while pressed and
// returns to normal state when released.
// Used by Lua scripts.
class MomentaryButton : public FormField
{
public:
MomentaryButton(Window* parent, const rect_t& rect, std::string text,
std::function<void(void)> pressHandler = nullptr,
std::function<void(void)> releaseHandler = nullptr);

#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "MomentaryButton"; }
#endif

void onPressed() override;
void onReleased() override;

void setText(std::string value)
{
if (value != text) {
text = std::move(value);
lv_label_set_text(label, text.c_str());
}
}

void setFont(FontIndex font)
{
etx_font(label, font);
}

protected:
std::function<void(void)> pressHandler;
std::function<void(void)> releaseHandler;
std::string text;
lv_obj_t* label = nullptr;
};
Loading