mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-05 02:35:29 +02:00
Update PopupSliderChoiceFloat to have increment/decrement buttons, and stepping.
This commit is contained in:
1 parent
4f3c69e714
commit
69e66df07e
2 files changed
+31
-4
No files matched your search
+24
-2
@@ -304,6 +304,11 @@ PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, flo
|
||||
OnClick.Handle(this, &PopupSliderChoiceFloat::HandleClick);
|
||||
}
|
||||
|
||||
PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, const std::string &text, float step, ScreenManager *screenManager, LayoutParams *layoutParams)
|
||||
: Choice(text, "", false, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), step_(step), screenManager_(screenManager) {
|
||||
OnClick.Handle(this, &PopupSliderChoiceFloat::HandleClick);
|
||||
}
|
||||
|
||||
EventReturn PopupSliderChoice::HandleClick(EventParams &e) {
|
||||
SliderPopupScreen *popupScreen = new SliderPopupScreen(value_, minValue_, maxValue_, text_, step_);
|
||||
popupScreen->OnChange.Handle(this, &PopupSliderChoice::HandleChange);
|
||||
@@ -330,7 +335,7 @@ void PopupSliderChoice::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
EventReturn PopupSliderChoiceFloat::HandleClick(EventParams &e) {
|
||||
SliderFloatPopupScreen *popupScreen = new SliderFloatPopupScreen(value_, minValue_, maxValue_, text_);
|
||||
SliderFloatPopupScreen *popupScreen = new SliderFloatPopupScreen(value_, minValue_, maxValue_, text_, step_);
|
||||
popupScreen->OnChange.Handle(this, &PopupSliderChoiceFloat::HandleChange);
|
||||
screenManager_->push(popupScreen);
|
||||
return EVENT_DONE;
|
||||
@@ -381,10 +386,27 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
sliderValue_ = *value_;
|
||||
slider_ = parent->Add(new SliderFloat(&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 SliderFloat(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(1.0f));
|
||||
lin->Add(slider_);
|
||||
lin->Add(new Button(" - "))->OnClick.Handle(this, &SliderFloatPopupScreen::OnDecrease);
|
||||
lin->Add(new Button(" + "))->OnClick.Handle(this, &SliderFloatPopupScreen::OnIncrease);
|
||||
// slider_ = parent->Add(new SliderFloat(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5))));
|
||||
UI::SetFocusedView(slider_);
|
||||
}
|
||||
|
||||
EventReturn SliderFloatPopupScreen::OnDecrease(EventParams ¶ms) {
|
||||
sliderValue_ -= step_;
|
||||
slider_->Clamp();
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
EventReturn SliderFloatPopupScreen::OnIncrease(EventParams ¶ms) {
|
||||
sliderValue_ += step_;
|
||||
slider_->Clamp();
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
void SliderPopupScreen::OnCompleted(DialogResult result) {
|
||||
if (result == DR_OK) {
|
||||
*value_ = sliderValue_;
|
||||
|
||||
+7
-2
@@ -147,19 +147,22 @@ private:
|
||||
|
||||
class SliderFloatPopupScreen : public PopupScreen {
|
||||
public:
|
||||
SliderFloatPopupScreen(float *value, float minValue, float maxValue, const std::string &title)
|
||||
: PopupScreen(title, "OK", "Cancel"), value_(value), minValue_(minValue), maxValue_(maxValue) {}
|
||||
SliderFloatPopupScreen(float *value, float minValue, float maxValue, const std::string &title, float step = 1.0f)
|
||||
: PopupScreen(title, "OK", "Cancel"), value_(value), minValue_(minValue), maxValue_(maxValue), step_(step) {}
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
|
||||
Event OnChange;
|
||||
|
||||
private:
|
||||
EventReturn OnIncrease(EventParams ¶ms);
|
||||
EventReturn OnDecrease(EventParams ¶ms);
|
||||
virtual void OnCompleted(DialogResult result) override;
|
||||
UI::SliderFloat *slider_;
|
||||
float sliderValue_;
|
||||
float *value_;
|
||||
float minValue_;
|
||||
float maxValue_;
|
||||
float step_;
|
||||
};
|
||||
|
||||
class TextEditPopupScreen : public PopupScreen {
|
||||
@@ -237,6 +240,7 @@ private:
|
||||
class PopupSliderChoiceFloat : public Choice {
|
||||
public:
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, const std::string &text, ScreenManager *screenManager, LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, const std::string &text, float step, ScreenManager *screenManager, LayoutParams *layoutParams = 0);
|
||||
|
||||
virtual void Draw(UIContext &dc) override;
|
||||
|
||||
@@ -248,6 +252,7 @@ private:
|
||||
float *value_;
|
||||
float minValue_;
|
||||
float maxValue_;
|
||||
float step_;
|
||||
ScreenManager *screenManager_;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user