Simplify away some theme parameters. Make popups look better

This commit is contained in:
Henrik Rydgård 2023-01-10 16:00:17 +01:00
parent e6380ecf77
commit 9547deb0c6
7 changed files with 16 additions and 25 deletions

View File

@ -337,6 +337,7 @@ void PopupScreen::CreateViews() {
box_->SetHasDropShadow(hasDropShadow_);
// Since we scale a bit, make the dropshadow bleed past the edges.
box_->SetDropShadowExpand(std::max(dp_xres, dp_yres));
box_->SetSpacing(0.0f);
View *title = new PopupHeader(title_);
if (HasTitleBar()) {
@ -668,14 +669,14 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
sprintf(temp, "%d", sliderValue_);
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
edit_->SetMaxLen(16);
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
edit_->SetTextColor(dc.theme->itemStyle.fgColor);
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
edit_->OnTextChange.Handle(this, &SliderPopupScreen::OnTextChange);
changing_ = false;
lin->Add(edit_);
if (!units_.empty())
lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->popupStyle.fgColor);
lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->itemStyle.fgColor);
if (!negativeLabel_.empty())
vert->Add(new CheckBox(&disabled_, negativeLabel_));
@ -702,13 +703,13 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
sprintf(temp, "%0.3f", sliderValue_);
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
edit_->SetMaxLen(16);
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
edit_->SetTextColor(dc.theme->itemStyle.fgColor);
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
edit_->OnTextChange.Handle(this, &SliderFloatPopupScreen::OnTextChange);
changing_ = false;
lin->Add(edit_);
if (!units_.empty())
lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->popupStyle.fgColor);
lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->itemStyle.fgColor);
// slider_ = parent->Add(new SliderFloat(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5))));
if (IsFocusMovementEnabled())

View File

@ -98,7 +98,7 @@ protected:
void update() override;
private:
UI::ViewGroup *box_;
UI::LinearLayout *box_;
UI::Button *defaultButton_;
std::string title_;
std::string button1_;

View File

@ -664,8 +664,8 @@ void PopupHeader::Draw(UIContext &dc) {
dc.PushScissor(tb);
}
dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->popupTitle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitle.fgColor);
dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->itemStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->itemStyle.fgColor);
if (availableWidth < tw) {
dc.PopScissor();
@ -1433,8 +1433,8 @@ void Slider::Clamp() {
void Slider::Draw(UIContext &dc) {
bool focus = HasFocus();
uint32_t linecolor = dc.theme->popupTitle.fgColor;
Style knobStyle = (down_ || focus) ? dc.theme->popupTitle : dc.theme->popupStyle;
uint32_t linecolor = dc.theme->itemStyle.fgColor;
Style knobStyle = (down_ || focus) ? dc.theme->itemStyle : dc.theme->popupStyle;
float knobX = ((float)(*value_) - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_);
dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4));
@ -1558,8 +1558,8 @@ void SliderFloat::Clamp() {
void SliderFloat::Draw(UIContext &dc) {
bool focus = HasFocus();
uint32_t linecolor = dc.theme->popupTitle.fgColor;
Style knobStyle = (down_ || focus) ? dc.theme->popupTitle : dc.theme->popupStyle;
uint32_t linecolor = dc.theme->itemStyle.fgColor;
Style knobStyle = (down_ || focus) ? dc.theme->itemStyle : dc.theme->popupStyle;
float knobX = (*value_ - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_);
dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4));

View File

@ -108,7 +108,6 @@ struct Theme {
Style headerStyle;
Style infoStyle;
Style popupTitle;
Style popupStyle;
uint32_t backgroundColor;

View File

@ -1104,7 +1104,7 @@ void SettingInfoMessage::Draw(UIContext &dc) {
}
if (alpha >= 0.1f) {
UI::Style style = dc.theme->popupTitle;
UI::Style style = dc.theme->popupStyle;
style.background.color = colorAlpha(style.background.color, alpha - 0.1f);
dc.FillRect(style.background, bounds_);
}

View File

@ -48,8 +48,6 @@ struct ThemeInfo {
uint32_t uHeaderStyleFg = 0xFFFFFFFF;
uint32_t uInfoStyleFg = 0xFFFFFFFF;
uint32_t uInfoStyleBg = 0x00000000;
uint32_t uPopupTitleStyleFg = 0xFFE3BE59;
uint32_t uPopupStyleFg = 0xFFFFFFFF;
uint32_t uPopupStyleBg = 0xFF303030;
uint32_t uBackgroundColor = 0xFF754D24;
@ -131,8 +129,6 @@ static void LoadThemeInfo(const std::vector<Path> &directories) {
section.Get("HeaderStyleFg", &info.uHeaderStyleFg, info.uHeaderStyleFg);
section.Get("InfoStyleFg", &info.uInfoStyleFg, info.uInfoStyleFg);
section.Get("InfoStyleBg", &info.uInfoStyleBg, info.uInfoStyleBg);
section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, info.uPopupTitleStyleFg);
section.Get("PopupStyleFg", &info.uPopupStyleFg, info.uPopupStyleFg);
section.Get("PopupStyleBg", &info.uPopupStyleBg, info.uPopupStyleBg);
section.Get("BackgroundColor", &info.uBackgroundColor, info.uBackgroundColor);
@ -218,8 +214,7 @@ void UpdateTheme(UIContext *ctx) {
ui_theme.headerStyle.fgColor = themeInfos[i].uHeaderStyleFg;
ui_theme.infoStyle = MakeStyle(themeInfos[i].uInfoStyleFg, themeInfos[i].uInfoStyleBg);
ui_theme.popupTitle.fgColor = themeInfos[i].uPopupTitleStyleFg;
ui_theme.popupStyle = MakeStyle(themeInfos[i].uPopupStyleFg, themeInfos[i].uPopupStyleBg);
ui_theme.popupStyle = MakeStyle(themeInfos[i].uItemStyleFg, themeInfos[i].uPopupStyleBg);
ui_theme.backgroundColor = themeInfos[i].uBackgroundColor;
// Load any missing atlas metadata (the images are loaded from UIContext).

View File

@ -11,9 +11,7 @@ ItemDisabledStyleBg = "#00000055"
HeaderStyleFg = "#FFFFFFFF"
InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupTitleStyleFg = "#59BEE3FF"
PopupStyleFg = "#FFFFFFFF"
PopupStyleBg = "#303030FF"
PopupStyleBg = "#1f4d5eFF"
BackgroundColor = "#244D75FF"
UIAtlas = "../ui_atlas"
@ -34,8 +32,6 @@ ItemDisabledStyleBg = "#1b1c1c55"
HeaderStyleFg = "#FFFFFFFF"
InfoStyleFg = "#FFFFFFFF"
InfoStyleBg = "#00000000"
PopupTitleStyleFg = "#59BEE3FF"
PopupStyleFg = "#FFFFFFFF"
PopupStyleBg = "#303030FF"
PopupStyleBg = "#0c1d24FF"
BackgroundColor = "#000000FF"
UIAtlas = "../ui_atlas"