mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-03 21:03:44 +01:00
Various newui tweaks
This commit is contained in:
1 parent
8559d298f8
commit
07feef3f44
6 files changed
+29
-15
No files matched your search
+5
-3
@@ -62,7 +62,8 @@ void PopupScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
ViewGroup *box = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(30, 30, 30, 30));
|
||||
LinearLayout *box = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(30, 30, 30, 30));
|
||||
|
||||
root_->Add(box);
|
||||
box->SetBG(UI::Drawable(0xFF303030));
|
||||
box->SetHasDropShadow(true);
|
||||
@@ -80,14 +81,12 @@ void PopupScreen::CreateViews() {
|
||||
}
|
||||
|
||||
UI::EventReturn PopupScreen::OnOK(UI::EventParams &e) {
|
||||
// callback_(true);
|
||||
OnCompleted();
|
||||
screenManager()->finishDialog(this, DR_OK);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn PopupScreen::OnCancel(UI::EventParams &e) {
|
||||
// callback_(false);
|
||||
screenManager()->finishDialog(this, DR_CANCEL);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
@@ -106,3 +105,6 @@ UI::EventReturn ListPopupScreen::OnListChoice(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
void ListPopupScreen::OnCompleted() {
|
||||
callback_(adaptor_.GetSelected());
|
||||
}
|
||||
+4
-3
@@ -49,13 +49,14 @@ private:
|
||||
class ListPopupScreen : public PopupScreen {
|
||||
public:
|
||||
ListPopupScreen(const std::string &title) : PopupScreen(title) {}
|
||||
ListPopupScreen(const std::string &title, const std::vector<std::string> &items, int selected)
|
||||
: PopupScreen(title), adaptor_(items, selected) {
|
||||
ListPopupScreen(const std::string &title, const std::vector<std::string> &items, int selected, std::function<void(int)> callback)
|
||||
: PopupScreen(title), adaptor_(items, selected), callback_(callback) {
|
||||
}
|
||||
|
||||
UI::Event OnChoice;
|
||||
|
||||
protected:
|
||||
virtual void OnCompleted();
|
||||
void CreatePopupContents(UI::ViewGroup *parent);
|
||||
UI::StringVectorListAdaptor adaptor_;
|
||||
UI::ListView *listView_;
|
||||
@@ -63,5 +64,5 @@ protected:
|
||||
private:
|
||||
UI::EventReturn OnListChoice(UI::EventParams &e);
|
||||
|
||||
std::function<void(bool, int)> callback_;
|
||||
std::function<void(int)> callback_;
|
||||
};
|
||||
+13
-5
@@ -125,11 +125,13 @@ void View::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
}
|
||||
|
||||
Point View::GetFocusPosition(FocusDirection dir) {
|
||||
// The +2/-2 is some extra fudge factor to cover for views sitting right next to each other.
|
||||
// Distance zero yields strange results otherwise.
|
||||
switch (dir) {
|
||||
case FOCUS_LEFT: return Point(bounds_.x, bounds_.centerY());
|
||||
case FOCUS_RIGHT: return Point(bounds_.x2(), bounds_.centerY());
|
||||
case FOCUS_UP: return Point(bounds_.centerX(), bounds_.y);
|
||||
case FOCUS_DOWN: return Point(bounds_.centerX(), bounds_.y2());
|
||||
case FOCUS_LEFT: return Point(bounds_.x + 2, bounds_.centerY());
|
||||
case FOCUS_RIGHT: return Point(bounds_.x2() - 2, bounds_.centerY());
|
||||
case FOCUS_UP: return Point(bounds_.centerX(), bounds_.y + 2);
|
||||
case FOCUS_DOWN: return Point(bounds_.centerX(), bounds_.y2() - 2);
|
||||
|
||||
default:
|
||||
return bounds_.Center();
|
||||
@@ -288,7 +290,13 @@ void InfoItem::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
void ItemHeader::Draw(UIContext &dc) {
|
||||
dc.Draw()->DrawText(dc.theme->uiFontSmaller, text_.c_str(), bounds_.x + 4, bounds_.y, 0xFF707070, ALIGN_LEFT);
|
||||
float scale = 1.0f;
|
||||
if (dc.theme->uiFontSmaller == dc.theme->uiFont) {
|
||||
scale = 0.6f;
|
||||
}
|
||||
dc.Draw()->SetFontScale(scale, scale);
|
||||
dc.Draw()->DrawText(dc.theme->uiFontSmaller, text_.c_str(), bounds_.x + 4, bounds_.y, 0xFFa0a0a0, ALIGN_LEFT);
|
||||
dc.Draw()->SetFontScale(1.0f, 1.0f);
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
@@ -450,9 +450,10 @@ public:
|
||||
virtual void GetContentDimensions(const UIContext &dc, float &w, float &h) const;
|
||||
virtual void Draw(UIContext &dc);
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::string text_;
|
||||
std::string smallText_;
|
||||
private:
|
||||
bool selected_;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -743,8 +743,8 @@ void ChoiceStrip::SetSelection(int sel) {
|
||||
|
||||
ListView::ListView(ListAdaptor *a, LayoutParams *layoutParams)
|
||||
: ScrollView(ORIENT_VERTICAL, layoutParams), adaptor_(a) {
|
||||
|
||||
linLayout_ = new LinearLayout(ORIENT_VERTICAL);
|
||||
linLayout_->SetSpacing(0.0f);
|
||||
Add(linLayout_);
|
||||
CreateAllItems();
|
||||
}
|
||||
|
||||
+4
-2
@@ -130,7 +130,9 @@ public:
|
||||
|
||||
void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert);
|
||||
void Layout();
|
||||
|
||||
void SetSpacing(float spacing) {
|
||||
spacing_ = spacing;
|
||||
}
|
||||
private:
|
||||
Orientation orientation_;
|
||||
Margins defaultMargins_;
|
||||
@@ -212,7 +214,7 @@ public:
|
||||
class ChoiceStrip : public LinearLayout {
|
||||
public:
|
||||
ChoiceStrip(Orientation orientation, LayoutParams *layoutParams = 0)
|
||||
: LinearLayout(orientation, layoutParams), selected_(0) {}
|
||||
: LinearLayout(orientation, layoutParams), selected_(0) { SetSpacing(0.0f); }
|
||||
|
||||
void AddChoice(const std::string &title);
|
||||
int GetSelection() const { return selected_; }
|
||||
|
||||
Reference in new issue
Block a user