diff options
Diffstat (limited to 'Userland/Applications/FontEditor/main.cpp')
-rw-r--r-- | Userland/Applications/FontEditor/main.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index db91ce1c51..c18a0a14d9 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -98,23 +98,24 @@ int main(int argc, char** argv) auto window = GUI::Window::construct(); window->set_icon(app_icon.bitmap_for_size(16)); + window->resize(440, 470); + window->set_main_widget<FontEditorWidget>(path, move(edited_font)); + window->set_title(String::formatted("{} - Font Editor", path)); - auto set_edited_font = [&](const String& path, RefPtr<Gfx::BitmapFont>&& font, Gfx::IntPoint point) { + auto set_edited_font = [&](const String& path, RefPtr<Gfx::BitmapFont>&& font) { // Convert 256 char font to 384 char font. if (font->type() == Gfx::FontTypes::Default) font->set_type(Gfx::FontTypes::LatinExtendedA); window->set_title(String::formatted("{} - Font Editor", path)); - auto& font_editor_widget = window->set_main_widget<FontEditorWidget>(path, move(font)); - window->set_rect({ point, { font_editor_widget.preferred_width(), font_editor_widget.preferred_height() } }); + static_cast<FontEditorWidget*>(window->main_widget())->initialize(path, move(font)); }; - set_edited_font(path, move(edited_font), window->position()); auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { - Optional<String> open_path = GUI::FilePicker::get_open_filepath(window); + Optional<String> open_path = GUI::FilePicker::get_open_filepath(window, {}, "/res/fonts/"); if (!open_path.has_value()) return; @@ -131,7 +132,7 @@ int main(int argc, char** argv) return; } - set_edited_font(open_path.value(), move(new_font), window->position()); + set_edited_font(open_path.value(), move(new_font)); })); app_menu.add_action(GUI::CommonActions::make_save_action([&](auto&) { FontEditorWidget* editor = static_cast<FontEditorWidget*>(window->main_widget()); @@ -152,6 +153,13 @@ int main(int argc, char** argv) app->quit(); })); + auto& view_menu = menubar->add_menu("View"); + auto set_font_metadata = GUI::Action::create_checkable("Font metadata", { Mod_Ctrl, Key_M }, [&](auto& action) { + static_cast<FontEditorWidget*>(window->main_widget())->set_show_font_metadata(action.is_checked()); + }); + set_font_metadata->set_checked(true); + view_menu.add_action(*set_font_metadata); + auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md"), "/bin/Help"); |