FontEditor: Make the application theme-aware

This commit is contained in:
Tibor Nagy 2020-02-20 10:55:00 +01:00 committed by Andreas Kling
parent 59b9e9cd4d
commit e490fc9e35
Notes: sideshowbarker 2024-07-19 09:11:58 +09:00
2 changed files with 9 additions and 8 deletions

View file

@ -27,6 +27,7 @@
#include "GlyphEditorWidget.h"
#include <LibGUI/Painter.h>
#include <LibGfx/Font.h>
#include <LibGfx/Palette.h>
GlyphEditorWidget::GlyphEditorWidget(Gfx::Font& mutable_font, GUI::Widget* parent)
: GUI::Frame(parent)
@ -57,15 +58,15 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
GUI::Painter painter(*this);
painter.add_clip_rect(frame_inner_rect());
painter.add_clip_rect(event.rect());
painter.fill_rect(frame_inner_rect(), Color::White);
painter.fill_rect(frame_inner_rect(), palette().base());
painter.translate(frame_thickness(), frame_thickness());
painter.translate(-1, -1);
for (int y = 1; y < font().glyph_height(); ++y)
painter.draw_line({ 0, y * m_scale }, { font().max_glyph_width() * m_scale, y * m_scale }, Color::Black);
painter.draw_line({ 0, y * m_scale }, { font().max_glyph_width() * m_scale, y * m_scale }, palette().threed_shadow2());
for (int x = 1; x < font().max_glyph_width(); ++x)
painter.draw_line({ x * m_scale, 0 }, { x * m_scale, font().glyph_height() * m_scale }, Color::Black);
painter.draw_line({ x * m_scale, 0 }, { x * m_scale, font().glyph_height() * m_scale }, palette().threed_shadow2());
auto bitmap = font().glyph_bitmap(m_glyph);
@ -73,10 +74,10 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
for (int x = 0; x < font().max_glyph_width(); ++x) {
Gfx::Rect rect { x * m_scale, y * m_scale, m_scale, m_scale };
if (x >= font().glyph_width(m_glyph)) {
painter.fill_rect(rect, Color::MidGray);
painter.fill_rect(rect, palette().threed_shadow1());
} else {
if (bitmap.bit_at(x, y))
painter.fill_rect(rect, Color::Black);
painter.fill_rect(rect, palette().base_text());
}
}
}

View file

@ -89,7 +89,7 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
painter.add_clip_rect(event.rect());
painter.set_font(font());
painter.fill_rect(frame_inner_rect(), Color::White);
painter.fill_rect(frame_inner_rect(), palette().base());
u8 glyph = 0;
@ -103,9 +103,9 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
font().glyph_height());
if (glyph == m_selected_glyph) {
painter.fill_rect(outer_rect, palette().selection());
painter.draw_glyph(inner_rect.location(), glyph, Color::White);
painter.draw_glyph(inner_rect.location(), glyph, palette().selection_text());
} else {
painter.draw_glyph(inner_rect.location(), glyph, Color::Black);
painter.draw_glyph(inner_rect.location(), glyph, palette().base_text());
}
}
}