mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-14 15:00:30 +02:00
Convert TouchControlVisibilityScreen to use Tabbed...
This commit is contained in:
1 parent
412e4ae015
commit
f4073cfa0e
2 files changed
+27
-25
No files matched your search
@@ -16,6 +16,7 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Common/UI/TabHolder.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/StringUtils.h"
|
||||
@@ -44,32 +45,38 @@ private:
|
||||
UI::CheckBox *checkbox_;
|
||||
};
|
||||
|
||||
void TouchControlVisibilityScreen::CreateViews() {
|
||||
void TouchControlVisibilityScreen::CreateTabs() {
|
||||
auto co = GetI18NCategory(I18NCat::CONTROLS);
|
||||
|
||||
AddTab("Visibility", co->T("Visibility"), [this](UI::LinearLayout *contents) {
|
||||
CreateVisibilityTab(contents);
|
||||
});
|
||||
}
|
||||
|
||||
void TouchControlVisibilityScreen::CreateVisibilityTab(UI::LinearLayout *vert) {
|
||||
using namespace UI;
|
||||
using namespace CustomKeyData;
|
||||
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto co = GetI18NCategory(I18NCat::CONTROLS);
|
||||
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
const bool portrait = UsePortraitLayout();
|
||||
|
||||
Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth - 10, WRAP_CONTENT, 10, NONE, NONE, 10));
|
||||
root_->Add(back)->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
Choice *toggleAll = new Choice(di->T("Toggle All"), "", false, new AnchorLayoutParams(leftColumnWidth - 10, WRAP_CONTENT, 10, NONE, NONE, 84));
|
||||
root_->Add(toggleAll)->OnClick.Handle(this, &TouchControlVisibilityScreen::OnToggleAll);
|
||||
|
||||
TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, TabHolderFlags::Default, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false));
|
||||
tabHolder->SetTag("TouchControlVisibility");
|
||||
root_->Add(tabHolder);
|
||||
ScrollView *rightPanel = new ScrollView(ORIENT_VERTICAL);
|
||||
tabHolder->AddTab(co->T("Visibility"), rightPanel);
|
||||
|
||||
LinearLayout *vert = rightPanel->Add(new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)));
|
||||
vert->SetSpacing(0);
|
||||
|
||||
vert->Add(toggleAll)->OnClick.Add([this](UI::EventParams &e) {
|
||||
// TODO: Is this a meaningful operation to support?
|
||||
for (auto toggle : toggles_) {
|
||||
*toggle.show = nextToggleAll_;
|
||||
}
|
||||
nextToggleAll_ = !nextToggleAll_;
|
||||
});
|
||||
|
||||
vert->Add(new ItemHeader(co->T("Touch Control Visibility")));
|
||||
|
||||
const int cellSize = 380;
|
||||
const int cellSize = portrait ? std::min((g_display.dp_xres / 2 - 10), 290) : 380;
|
||||
|
||||
UI::GridLayoutSettings gridsettings(cellSize, 64, 5);
|
||||
gridsettings.fillCells = true;
|
||||
@@ -170,13 +177,6 @@ void RightAnalogMappingScreen::CreateViews() {
|
||||
rightAnalogPress->SetEnabledPtr(&g_Config.bRightAnalogCustom);
|
||||
}
|
||||
|
||||
void TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) {
|
||||
for (auto toggle : toggles_) {
|
||||
*toggle.show = nextToggleAll_;
|
||||
}
|
||||
nextToggleAll_ = !nextToggleAll_;
|
||||
}
|
||||
|
||||
void CheckBoxChoice::HandleClick(UI::EventParams &e) {
|
||||
checkbox_->Toggle();
|
||||
};
|
||||
@@ -18,7 +18,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
#include "MiscScreens.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/TabbedDialogScreen.h"
|
||||
|
||||
namespace UI {
|
||||
class CheckBox;
|
||||
@@ -31,16 +32,17 @@ struct TouchButtonToggle {
|
||||
std::function<void(UI::EventParams&)> handle;
|
||||
};
|
||||
|
||||
class TouchControlVisibilityScreen : public UIDialogScreenWithGameBackground {
|
||||
class TouchControlVisibilityScreen : public TabbedUIDialogScreenWithGameBackground {
|
||||
public:
|
||||
TouchControlVisibilityScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
||||
void CreateViews() override;
|
||||
TouchControlVisibilityScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {}
|
||||
void CreateTabs() override;
|
||||
void onFinish(DialogResult result) override;
|
||||
|
||||
const char *tag() const override { return "TouchControlVisibility"; }
|
||||
|
||||
protected:
|
||||
void OnToggleAll(UI::EventParams &e);
|
||||
bool ShowSearchControls() const override { return false; }
|
||||
void CreateVisibilityTab(UI::LinearLayout *contents);
|
||||
|
||||
private:
|
||||
std::vector<TouchButtonToggle> toggles_;
|
||||
|
||||
Reference in new issue
Block a user