Use tooltip_text style & color to paint tooltip windows (fix #2554)

This commit is contained in:
David Capello 2022-07-18 16:00:13 -03:00
parent 7c8153b5ec
commit dd0c296209
4 changed files with 31 additions and 10 deletions

View File

@ -496,9 +496,6 @@
<style id="tooltip_window_arrow">
<background part="tooltip_arrow" />
</style>
<style id="tooltip_face">
<background color="tooltip_face" />
</style>
<style id="tooltip_text">
<background color="tooltip_face" />
<text color="tooltip_text" align="left" />

View File

@ -1430,8 +1430,7 @@ void SkinTheme::paintTextBox(ui::PaintEvent& ev)
Graphics* g = ev.graphics();
Widget* widget = static_cast<Widget*>(ev.getSource());
Theme::drawTextBox(g, widget, nullptr, nullptr,
BGCOLOR, colors.textboxText());
Theme::paintTextBoxWithStyle(g, widget);
}
void SkinTheme::paintViewViewport(PaintEvent& ev)

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -294,6 +294,28 @@ void Theme::paintTooltip(Graphics* g,
}
}
gfx::Size Theme::paintTextBoxWithStyle(Graphics* g,
const Widget* widget)
{
gfx::Size size;
gfx::Color bg = gfx::ColorNone, fg = gfx::ColorNone;
for_each_layer(
PaintWidgetPartInfo::getStyleFlagsForWidget(widget),
widget->style(),
[&fg, &bg](const Style::Layer& layer) {
switch (layer.type()) {
case Style::Layer::Type::kBackground: bg = layer.color(); break;
case Style::Layer::Type::kText: fg = layer.color(); break;
}
});
if (fg != gfx::ColorNone)
Theme::drawTextBox(g, widget, &size.w, &size.h, bg, fg);
return size;
}
void Theme::paintLayer(Graphics* g,
const Style* style,
const Style::Layer& layer,
@ -744,7 +766,7 @@ void Theme::drawSlices(Graphics* g, os::Surface* sheet,
}
// static
void Theme::drawTextBox(Graphics* g, Widget* widget,
void Theme::drawTextBox(Graphics* g, const Widget* widget,
int* w, int* h, gfx::Color bg, gfx::Color fg)
{
View* view = (g ? View::getView(widget): nullptr);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
@ -101,6 +101,9 @@ namespace ui {
const int arrowAlign,
const gfx::Rect& target);
gfx::Size paintTextBoxWithStyle(Graphics* g,
const Widget* widget);
virtual gfx::Size calcSizeHint(const Widget* widget,
const Style* style);
virtual gfx::Border calcBorder(const Widget* widget,
@ -125,8 +128,8 @@ namespace ui {
const gfx::Color color,
const bool drawCenter = true);
static void drawTextBox(Graphics* g, Widget* textbox,
int* w, int* h, gfx::Color bg, gfx::Color fg);
static void drawTextBox(Graphics* g, const Widget* textbox,
int* w, int* h, gfx::Color bg, gfx::Color fg);
protected:
virtual void onRegenerateTheme() = 0;