Skip to content

Commit 7234119

Browse files
committed
fix(UI): prevent slider reset button from obscuring the input
fix(UI): set speed factor numberpad limits correctly
1 parent 072b42e commit 7234119

File tree

22 files changed

+19
-10
lines changed

22 files changed

+19
-10
lines changed

libraries/lvgl

src/UI/Components/Input/Slider.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ namespace UI
2323
setFlexFlow(LV_FLEX_FLOW_COLUMN);
2424
setFlexAlign(LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
2525

26+
setStylePad(0, LV_PART_MAIN, Padding::ROW);
27+
28+
m_header.setSize(LV_PCT(100), LV_SIZE_CONTENT);
29+
m_header.setStylePad(0);
30+
2631
m_label.hide(); // will be shown if `setLabel()` is called
2732
m_label.setSize(LV_PCT(100), LV_SIZE_CONTENT);
28-
m_sliderCont.setSize(LV_PCT(100), LV_SIZE_CONTENT);
2933

3034
m_reset.setText(_("slider.reset"));
31-
m_reset.setFlag(LV_OBJ_FLAG_FLOATING, true);
32-
m_reset.setAlign(LV_ALIGN_TOP_RIGHT, -5, 5);
35+
m_reset.setAlign(LV_ALIGN_RIGHT_MID, 0, 0);
3336
m_reset.setVisible(false);
3437

38+
m_sliderCont.setSize(LV_PCT(100), LV_SIZE_CONTENT);
3539
m_sliderCont.setFlexFlow(LV_FLEX_FLOW_ROW);
3640
m_sliderCont.setFlexAlign(LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
3741

src/UI/Components/Input/Slider.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ namespace UI
8181
private:
8282
void onShow() override;
8383

84-
LvLabel m_label{"label", getRoot()};
84+
LvContainer m_header{"header", getRoot()};
8585
LvContainer m_sliderCont{"slider_cont", getRoot()};
8686

87+
LvLabel m_label{"label", m_header};
88+
Button m_reset{"reset", m_header};
89+
8790
Button m_decrement{"decrement", m_sliderCont};
8891
LvSlider m_slider{"slider", m_sliderCont};
8992
Button m_increment{"increment", m_sliderCont};
9093
LvTextarea m_input{"input", m_sliderCont};
91-
Button m_reset{"reset", getRoot()};
9294

9395
float m_incrementValue = 1;
9496
ModalNumberPad* m_numberPad = nullptr;

src/UI/Widgets/Control/SpeedFactor/SpeedFactor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace UI
1313
{
1414
static constexpr float SPEED_FACTOR_MIN = 1.0f;
15+
static constexpr float SPEED_FACTOR_MAX = 10000.0f;
1516

1617
SpeedFactor::SpeedFactor(const std::string& name, LvObj& parent)
1718
: View(name, parent)
@@ -36,8 +37,8 @@ namespace UI
3637
return;
3738
m_numberPad->setHeader(slider->getLabelText());
3839
m_numberPad->setValue(slider->getValue());
39-
m_numberPad->setMinValue(slider->getMin());
40-
m_numberPad->setMaxValue(slider->getMax());
40+
m_numberPad->setMinValue(SPEED_FACTOR_MIN);
41+
m_numberPad->setMaxValue(SPEED_FACTOR_MAX);
4142
slider->getInput().sendEvent(LV_EVENT_DEFOCUSED, nullptr);
4243
m_numberPad->setConfirmCallback([this, slider](float value) { slider->setValue(value); });
4344
});
@@ -93,8 +94,8 @@ namespace UI
9394
return;
9495

9596
m_numberPad.setValue(m_speedFactor.getSlider().getValue());
96-
m_numberPad.setMinValue(m_speedFactor.getSlider().getMin());
97-
m_numberPad.setMaxValue(m_speedFactor.getSlider().getMax());
97+
m_numberPad.setMinValue(SPEED_FACTOR_MIN);
98+
m_numberPad.setMaxValue(SPEED_FACTOR_MAX);
9899
m_speedFactor.getSlider().getInput().sendEvent(LV_EVENT_DEFOCUSED, nullptr);
99100
m_numberPad.setConfirmCallback(
100101
[this](float value)
49 Bytes
Loading
998 Bytes
Loading

tests/ref_imgs/slider/basic.png

0 Bytes
Loading
2 Bytes
Loading
-225 Bytes
Loading
98 Bytes
Loading

0 commit comments

Comments
 (0)