mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Add ability to hide items from popup lists
This commit is contained in:
1 parent
f08ae677e8
commit
98dc56116f
4 files changed
+25
-9
No files matched your search
@@ -288,7 +288,7 @@ UI::EventReturn PopupScreen::OnCancel(UI::EventParams &e) {
|
||||
void ListPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
|
||||
listView_ = parent->Add(new ListView(&adaptor_)); //, new LinearLayoutParams(1.0)));
|
||||
listView_ = parent->Add(new ListView(&adaptor_, hidden_)); //, new LinearLayoutParams(1.0)));
|
||||
listView_->SetMaxHeight(screenManager()->getUIContext()->GetBounds().h - 140);
|
||||
listView_->OnChoice.Handle(this, &ListPopupScreen::OnListChoice);
|
||||
}
|
||||
@@ -315,8 +315,9 @@ UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
|
||||
choices.push_back(category ? category->T(choices_[i]) : choices_[i]);
|
||||
}
|
||||
|
||||
Screen *popupScreen = new ListPopupScreen(text_, choices, *value_ - minVal_,
|
||||
ListPopupScreen *popupScreen = new ListPopupScreen(text_, choices, *value_ - minVal_,
|
||||
std::bind(&PopupMultiChoice::ChoiceCallback, this, placeholder::_1));
|
||||
popupScreen->SetHiddenChoices(hidden_);
|
||||
screenManager_->push(popupScreen);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "ui/screen.h"
|
||||
#include "ui/viewgroup.h"
|
||||
|
||||
@@ -93,9 +95,13 @@ public:
|
||||
std::string GetChoiceString() const {
|
||||
return adaptor_.GetTitle(listView_->GetSelected());
|
||||
}
|
||||
UI::Event OnChoice;
|
||||
void SetHiddenChoices(std::set<int> hidden) {
|
||||
hidden_ = hidden;
|
||||
}
|
||||
virtual std::string tag() const override { return std::string("listpopup"); }
|
||||
|
||||
UI::Event OnChoice;
|
||||
|
||||
protected:
|
||||
virtual bool FillVertical() const override { return false; }
|
||||
virtual bool ShowButtons() const override { return showButtons_; }
|
||||
@@ -108,6 +114,7 @@ private:
|
||||
|
||||
std::function<void(int)> callback_;
|
||||
bool showButtons_;
|
||||
std::set<int> hidden_;
|
||||
};
|
||||
|
||||
class MessagePopupScreen : public PopupScreen {
|
||||
@@ -215,6 +222,10 @@ public:
|
||||
virtual void Draw(UIContext &dc) override;
|
||||
virtual void Update(const InputState &input_state) override;
|
||||
|
||||
void HideChoice(int c) {
|
||||
hidden_.insert(c);
|
||||
}
|
||||
|
||||
UI::Event OnChoice;
|
||||
|
||||
private:
|
||||
@@ -231,6 +242,7 @@ private:
|
||||
ScreenManager *screenManager_;
|
||||
std::string valueText_;
|
||||
bool restoreFocus_;
|
||||
std::set<int> hidden_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1258,9 +1258,8 @@ StickyChoice *ChoiceStrip::Choice(int index) {
|
||||
return static_cast<StickyChoice *>(views_[index]);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ListView::ListView(ListAdaptor *a, LayoutParams *layoutParams)
|
||||
: ScrollView(ORIENT_VERTICAL, layoutParams), adaptor_(a), maxHeight_(0) {
|
||||
ListView::ListView(ListAdaptor *a, std::set<int> hidden, LayoutParams *layoutParams)
|
||||
: ScrollView(ORIENT_VERTICAL, layoutParams), adaptor_(a), maxHeight_(0), hidden_(hidden) {
|
||||
|
||||
linLayout_ = new LinearLayout(ORIENT_VERTICAL);
|
||||
linLayout_->SetSpacing(0.0f);
|
||||
@@ -1272,8 +1271,10 @@ void ListView::CreateAllItems() {
|
||||
linLayout_->Clear();
|
||||
// Let's not be clever yet, we'll just create them all up front and add them all in.
|
||||
for (int i = 0; i < adaptor_->GetNumItems(); i++) {
|
||||
View * v = linLayout_->Add(adaptor_->CreateItemView(i));
|
||||
adaptor_->AddEventCallback(v, std::bind(&ListView::OnItemCallback, this, i, placeholder::_1));
|
||||
if (hidden_.find(i) == hidden_.end()) {
|
||||
View * v = linLayout_->Add(adaptor_->CreateItemView(i));
|
||||
adaptor_->AddEventCallback(v, std::bind(&ListView::OnItemCallback, this, i, placeholder::_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/mutex.h"
|
||||
@@ -389,7 +390,7 @@ private:
|
||||
// In the future, it might be smart and load/unload items as they go, but currently not.
|
||||
class ListView : public ScrollView {
|
||||
public:
|
||||
ListView(ListAdaptor *a, LayoutParams *layoutParams = 0);
|
||||
ListView(ListAdaptor *a, std::set<int> hidden = std::set<int>(), LayoutParams *layoutParams = 0);
|
||||
|
||||
int GetSelected() { return adaptor_->GetSelected(); }
|
||||
virtual void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override;
|
||||
@@ -403,6 +404,7 @@ private:
|
||||
ListAdaptor *adaptor_;
|
||||
LinearLayout *linLayout_;
|
||||
float maxHeight_;
|
||||
std::set<int> hidden_;
|
||||
};
|
||||
|
||||
void LayoutViewHierarchy(const UIContext &dc, ViewGroup *root);
|
||||
|
||||
Reference in new issue
Block a user