summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-11-29 10:05:57 -0500
committerAndreas Kling <kling@serenityos.org>2021-11-30 10:51:51 +0100
commitae922c67fd769eed54ecc496ea81ea549dd2c8d7 (patch)
treeb2174af954cba3167523c74c8b0bd712fd5d0fbf /Userland
parentc1744822a17601afcd19702d46cf901ec407da05 (diff)
downloadserenity-ae922c67fd769eed54ecc496ea81ea549dd2c8d7.zip
FontEditor: Remove code duplication when resizing GlyphEditor
The left column now also enforces a minimum width to prevent especially small fonts from hiding the glyph toolbars and width widgets.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/FontEditor/FontEditor.cpp20
-rw-r--r--Userland/Applications/FontEditor/FontEditor.h1
2 files changed, 12 insertions, 9 deletions
diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp
index 72535babb9..f408552241 100644
--- a/Userland/Applications/FontEditor/FontEditor.cpp
+++ b/Userland/Applications/FontEditor/FontEditor.cpp
@@ -297,22 +297,19 @@ FontEditorWidget::FontEditorWidget()
m_scale_five_action = GUI::Action::create_checkable("500%", { Mod_Ctrl, Key_1 }, [&](auto&) {
m_glyph_editor_widget->set_scale(5);
- m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
- m_left_column_container->set_fixed_width(m_glyph_editor_widget->preferred_width());
+ did_resize_glyph_editor();
});
m_scale_five_action->set_checked(false);
m_scale_five_action->set_status_tip("Scale the editor in proportion to the current font");
m_scale_ten_action = GUI::Action::create_checkable("1000%", { Mod_Ctrl, Key_2 }, [&](auto&) {
m_glyph_editor_widget->set_scale(10);
- m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
- m_left_column_container->set_fixed_width(m_glyph_editor_widget->preferred_width());
+ did_resize_glyph_editor();
});
m_scale_ten_action->set_checked(true);
m_scale_ten_action->set_status_tip("Scale the editor in proportion to the current font");
m_scale_fifteen_action = GUI::Action::create_checkable("1500%", { Mod_Ctrl, Key_3 }, [&](auto&) {
m_glyph_editor_widget->set_scale(15);
- m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
- m_left_column_container->set_fixed_width(m_glyph_editor_widget->preferred_width());
+ did_resize_glyph_editor();
});
m_scale_fifteen_action->set_checked(false);
m_scale_fifteen_action->set_status_tip("Scale the editor in proportion to the current font");
@@ -500,9 +497,7 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
m_glyph_map_widget->initialize(*m_edited_font);
m_glyph_editor_widget->initialize(*m_edited_font);
-
- m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
- m_left_column_container->set_fixed_width(m_glyph_editor_widget->preferred_width());
+ did_resize_glyph_editor();
m_glyph_editor_width_spinbox->set_visible(!m_edited_font->is_fixed_width());
m_glyph_editor_width_spinbox->set_max(m_edited_font->max_glyph_width(), GUI::AllowCallback::No);
@@ -769,3 +764,10 @@ void FontEditorWidget::drop_event(GUI::DropEvent& event)
open_file(urls.first().path());
}
}
+
+void FontEditorWidget::did_resize_glyph_editor()
+{
+ constexpr int glyph_toolbars_width = 100;
+ m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
+ m_left_column_container->set_fixed_width(max(m_glyph_editor_widget->preferred_width(), glyph_toolbars_width));
+}
diff --git a/Userland/Applications/FontEditor/FontEditor.h b/Userland/Applications/FontEditor/FontEditor.h
index 5245e5f5d8..ea97b3ec0a 100644
--- a/Userland/Applications/FontEditor/FontEditor.h
+++ b/Userland/Applications/FontEditor/FontEditor.h
@@ -43,6 +43,7 @@ private:
void undo();
void redo();
void did_modify_font();
+ void did_resize_glyph_editor();
void update_statusbar();
void update_preview();