Skip to content

Commit

Permalink
Draw the line between the tabs and contents as a spacer instead of cu…
Browse files Browse the repository at this point in the history
…stom code.
  • Loading branch information
hrydgard committed Jan 19, 2024
1 parent 0e03b66 commit 7a318b4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
7 changes: 7 additions & 0 deletions Common/UI/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,4 +1657,11 @@ void SliderFloat::GetContentDimensions(const UIContext &dc, float &w, float &h)
h = 50;
}

void Spacer::Draw(UIContext &dc) {
View::Draw(dc);
if (drawAsSeparator_) {
dc.FillRect(UI::Drawable(dc.theme->itemDownStyle.background.color), bounds_);
}
}

} // namespace
4 changes: 3 additions & 1 deletion Common/UI/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,13 @@ class Spacer : public InertView {
h = size_;
}

void Draw(UIContext &dc) override {}
void Draw(UIContext &dc) override;
std::string DescribeText() const override { return ""; }
void SetSeparator() { drawAsSeparator_ = true; }

private:
float size_ = 0.0f;
bool drawAsSeparator_ = false;
};

class BorderView : public InertView {
Expand Down
12 changes: 2 additions & 10 deletions Common/UI/ViewGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,8 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay
}
tabStrip_->OnChoice.Handle(this, &TabHolder::OnTabClick);

Add(new Spacer(4.0f))->SetSeparator();

contents_ = new AnchorLayout(new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f));
Add(contents_)->SetClip(true);
}
Expand Down Expand Up @@ -1161,16 +1163,6 @@ bool ChoiceStrip::Key(const KeyInput &input) {
return ret || ViewGroup::Key(input);
}

void ChoiceStrip::Draw(UIContext &dc) {
ViewGroup::Draw(dc);
if (topTabs_) {
if (orientation_ == ORIENT_HORIZONTAL)
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2() - 4, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
else if (orientation_ == ORIENT_VERTICAL)
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x2() - 4, bounds_.y, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
}
}

std::string ChoiceStrip::DescribeText() const {
auto u = GetI18NCategory(I18NCat::UI_ELEMENTS);
return DescribeListUnordered(u->T("Choices:"));
Expand Down
1 change: 0 additions & 1 deletion Common/UI/ViewGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class ChoiceStrip : public LinearLayout {
bool Key(const KeyInput &input) override;

void SetTopTabs(bool tabs) { topTabs_ = tabs; }
void Draw(UIContext &dc) override;

std::string DescribeLog() const override { return "ChoiceStrip: " + View::DescribeLog(); }
std::string DescribeText() const override;
Expand Down
2 changes: 1 addition & 1 deletion UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ UI::EventReturn CreditsScreen::OnSupport(UI::EventParams &e) {
}

UI::EventReturn CreditsScreen::OnTwitter(UI::EventParams &e) {
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://twitter.com/#!/PPSSPP_emu");
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://twitter.com/PPSSPP_emu");
return UI::EVENT_DONE;
}

Expand Down

0 comments on commit 7a318b4

Please sign in to comment.