Give all views a bool popupStyle_, so they know the context.

This commit is contained in:
Henrik Rydgård committed 2025-02-17 11:25:23 -06:00
1 parent 4ff642ccc8
commit 863bef5f64
4 files changed
+21 -3

No files matched your search

+5 -1
View File
@@ -430,11 +430,15 @@ void PopupScreen::CreateViews() {
box_->SetSpacing(0.0f); box_->SetSpacing(0.0f);
if (HasTitleBar()) { if (HasTitleBar()) {
View* title = new PopupHeader(title_); View *title = new PopupHeader(title_);
box_->Add(title); box_->Add(title);
} }
CreatePopupContents(box_); CreatePopupContents(box_);
root_->Recurse([](View *view) {
view->SetPopupStyle(true);
});
root_->SetDefaultFocusView(box_); root_->SetDefaultFocusView(box_);
if (ShowButtons() && !button1_.empty()) { if (ShowButtons() && !button1_.empty()) {
// And the two buttons at the bottom. // And the two buttons at the bottom.
+7 -2
View File
@@ -429,6 +429,8 @@ public:
virtual bool CanBeFocused() const { return true; } virtual bool CanBeFocused() const { return true; }
virtual bool SubviewFocused(View *view) { return false; } virtual bool SubviewFocused(View *view) { return false; }
void SetPopupStyle(bool popupStyle) { popupStyle_ = popupStyle; }
bool HasFocus() const { bool HasFocus() const {
return GetFocusedView() == this; return GetFocusedView() == this;
} }
@@ -480,6 +482,8 @@ public:
return t; return t;
} }
virtual void Recurse(void (*func)(View *view)) {}
protected: protected:
// Inputs to layout // Inputs to layout
std::unique_ptr<LayoutParams> layoutParams_; std::unique_ptr<LayoutParams> layoutParams_;
@@ -496,6 +500,9 @@ protected:
std::vector<Tween *> tweens_; std::vector<Tween *> tweens_;
// Whether to use popup colors for styling.
bool popupStyle_ = false;
private: private:
std::function<bool()> enabledFunc_; std::function<bool()> enabledFunc_;
bool *enabledPtr_ = nullptr; bool *enabledPtr_ = nullptr;
@@ -851,11 +858,9 @@ public:
std::string DescribeText() const override; std::string DescribeText() const override;
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override; void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
void SetLarge(bool large) { large_ = large; } void SetLarge(bool large) { large_ = large; }
void SetPopupStyle(bool popupStyle) { popupStyle_ = popupStyle; }
private: private:
std::string text_; std::string text_;
bool large_ = false; bool large_ = false;
bool popupStyle_ = false;
}; };
class PopupHeader : public Item { class PopupHeader : public Item {
+7
View File
@@ -48,6 +48,13 @@ ViewGroup::~ViewGroup() {
Clear(); Clear();
} }
void ViewGroup::Recurse(void (*func)(View *view)) {
for (View *view : views_) {
func(view);
view->Recurse(func);
}
}
void ViewGroup::RemoveSubview(View *subView) { void ViewGroup::RemoveSubview(View *subView) {
// loop counter needed, so can't convert loop. // loop counter needed, so can't convert loop.
for (size_t i = 0; i < views_.size(); i++) { for (size_t i = 0; i < views_.size(); i++) {
+2
View File
@@ -82,6 +82,8 @@ public:
std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); } std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); }
std::string DescribeText() const override; std::string DescribeText() const override;
void Recurse(void (*func)(View *view)) override;
protected: protected:
std::string DescribeListUnordered(std::string_view heading) const; std::string DescribeListUnordered(std::string_view heading) const;
std::string DescribeListOrdered(std::string_view heading) const; std::string DescribeListOrdered(std::string_view heading) const;