mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-04 11:45:18 +02:00
Add +/- buttons to integer sliders for fine adjustment
This commit is contained in:
+18
-1
@@ -305,10 +305,27 @@ void PopupSliderChoiceFloat::Draw(UIContext &dc) {
|
||||
dc.DrawText(temp, bounds_.x2() - 12, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
EventReturn SliderPopupScreen::OnDecrease(EventParams ¶ms) {
|
||||
sliderValue_--;
|
||||
slider_->Clamp();
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
EventReturn SliderPopupScreen::OnIncrease(EventParams ¶ms) {
|
||||
sliderValue_++;
|
||||
slider_->Clamp();
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
sliderValue_ = *value_;
|
||||
slider_ = parent->Add(new Slider(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5))));
|
||||
LinearLayout *lin = parent->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(UI::Margins(10, 5))));
|
||||
slider_ = new Slider(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(1.0f));
|
||||
lin->Add(slider_);
|
||||
lin->Add(new Button(" - "))->OnClick.Handle(this, &SliderPopupScreen::OnDecrease);
|
||||
lin->Add(new Button(" + "))->OnClick.Handle(this, &SliderPopupScreen::OnIncrease);
|
||||
|
||||
UI::SetFocusedView(slider_);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ public:
|
||||
Event OnChange;
|
||||
|
||||
private:
|
||||
EventReturn OnDecrease(EventParams ¶ms);
|
||||
EventReturn OnIncrease(EventParams ¶ms);
|
||||
virtual void OnCompleted(DialogResult result);
|
||||
Slider *slider_;
|
||||
int *value_;
|
||||
|
||||
@@ -446,8 +446,10 @@ public:
|
||||
virtual void Touch(const TouchInput &input);
|
||||
virtual void GetContentDimensions(const UIContext &dc, float &w, float &h) const;
|
||||
void SetShowPercent(bool s) { showPercent_ = s; }
|
||||
private:
|
||||
|
||||
// OK to call this from the outside after having modified *value_
|
||||
void Clamp();
|
||||
private:
|
||||
int *value_;
|
||||
bool showPercent_;
|
||||
int minValue_;
|
||||
@@ -465,8 +467,9 @@ public:
|
||||
virtual void Touch(const TouchInput &input);
|
||||
virtual void GetContentDimensions(const UIContext &dc, float &w, float &h) const;
|
||||
|
||||
private:
|
||||
// OK to call this from the outside after having modified *value_
|
||||
void Clamp();
|
||||
private:
|
||||
float *value_;
|
||||
float minValue_;
|
||||
float maxValue_;
|
||||
|
||||
Reference in New Issue
Block a user