Skip to content

Commit

Permalink
Serendipity: Paint theme agnostic banner
Browse files Browse the repository at this point in the history
And remove temporary welcome-banner.png. Fixes invisible text in
dark themes.
  • Loading branch information
thankyouverycool authored and awesomekling committed Apr 12, 2021
1 parent 4366cb4 commit 198c4fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Binary file removed Base/res/graphics/welcome-serendipity.png
Binary file not shown.
17 changes: 13 additions & 4 deletions Userland/Applications/Serendipity/SerendipityWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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);
Expand Down Expand Up @@ -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());
}
2 changes: 2 additions & 0 deletions Userland/Applications/Serendipity/SerendipityWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class SerendipityWidget final : public GUI::Widget {
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();
Expand Down
10 changes: 0 additions & 10 deletions Userland/Applications/Serendipity/SerendipityWindow.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 198c4fd

Please sign in to comment.