Serendipity: Paint theme agnostic banner

And remove temporary welcome-banner.png. Fixes invisible text in
dark themes.
This commit is contained in:
thankyouverycool 2021-04-11 18:00:05 -04:00 committed by Andreas Kling
parent 4366cb469b
commit 198c4fd7f2
Notes: sideshowbarker 2024-07-18 20:30:10 +09:00
4 changed files with 15 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

View File

@ -31,7 +31,8 @@
#include <LibGUI/Button.h>
#include <LibGUI/CheckBox.h>
#include <LibGUI/Label.h>
#include <LibGfx/FontDatabase.h>
#include <LibGUI/Painter.h>
#include <LibGfx/BitmapFont.h>
#include <LibGfx/Palette.h>
#include <LibMarkdown/Document.h>
#include <LibWeb/OutOfProcessWebView.h>
@ -43,9 +44,6 @@ SerendipityWidget::SerendipityWidget()
{
load_from_gml(serendipity_window_gml);
auto& banner_label = *find_descendant_of_type_named<GUI::Label>("banner_label");
banner_label.set_icon(Gfx::Bitmap::load_from_file("/res/graphics/welcome-serendipity.png"));
auto& tip_frame = *find_descendant_of_type_named<GUI::Frame>("tip_frame");
tip_frame.set_background_role(Gfx::ColorRole::Base);
tip_frame.set_fill_with_background_color(true);
@ -153,3 +151,14 @@ void SerendipityWidget::set_random_tip()
m_initial_tip_index = n;
m_tip_label->set_text(m_tips[n]);
}
void SerendipityWidget::paint_event(GUI::PaintEvent& event)
{
GUI::Painter painter(*this);
painter.add_clip_rect(event.rect());
static auto font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font");
painter.draw_text({ 12, 4, 1, 30 }, "Welcome to ", *font, Gfx::TextAlignment::CenterLeft, palette().base_text());
painter.draw_text({ 12 + font->width("Welcome to "), 4, 1, 30 }, "Serenity", font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base_text());
painter.draw_text({ 12 + font->width("Welcome to ") + font->bold_variant().width("Serenity"), 4, 1, 30 }, "OS", font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base() == palette().window() ? palette().base_text() : palette().base());
}

View File

@ -37,6 +37,8 @@ public:
private:
SerendipityWidget();
virtual void paint_event(GUI::PaintEvent&) override;
void set_random_tip();
void open_and_parse_tips_file();
void open_and_parse_readme_file();

View File

@ -6,16 +6,6 @@
@GUI::Widget {
fixed_height: 30
layout: @GUI::HorizontalBoxLayout {
margins: [4, 0, 0, 0]
}
@GUI::Label {
name: "banner_label"
fixed_width: 251
}
@GUI::Widget
}
@GUI::Widget {