2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-10 22:28:48 +03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-02-02 10:05:14 +03:00
|
|
|
#pragma once
|
|
|
|
|
2022-03-17 15:56:02 +03:00
|
|
|
#include "UndoSelection.h"
|
2021-04-22 21:12:53 +03:00
|
|
|
#include <LibGUI/ActionGroup.h>
|
2022-02-16 18:12:46 +03:00
|
|
|
#include <LibGUI/FilteringProxyModel.h>
|
2022-01-09 19:15:23 +03:00
|
|
|
#include <LibGUI/GlyphMapWidget.h>
|
2021-04-22 21:12:53 +03:00
|
|
|
#include <LibGUI/UndoStack.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/Widget.h>
|
2022-04-09 10:28:38 +03:00
|
|
|
#include <LibGfx/Font/BitmapFont.h>
|
2019-02-02 10:05:14 +03:00
|
|
|
|
2022-07-05 12:32:22 +03:00
|
|
|
namespace FontEditor {
|
|
|
|
|
2019-02-02 10:05:14 +03:00
|
|
|
class GlyphEditorWidget;
|
|
|
|
|
2022-07-05 13:37:06 +03:00
|
|
|
class MainWidget final : public GUI::Widget {
|
|
|
|
C_OBJECT(MainWidget)
|
2019-02-02 10:05:14 +03:00
|
|
|
public:
|
2022-07-05 13:37:06 +03:00
|
|
|
static ErrorOr<NonnullRefPtr<MainWidget>> try_create()
|
2022-07-05 05:22:06 +03:00
|
|
|
{
|
2022-07-05 13:37:06 +03:00
|
|
|
NonnullRefPtr<MainWidget> font_editor = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) MainWidget()));
|
2022-07-05 05:22:06 +03:00
|
|
|
TRY(font_editor->create_actions());
|
|
|
|
TRY(font_editor->create_models());
|
|
|
|
TRY(font_editor->create_toolbars());
|
|
|
|
TRY(font_editor->create_undo_stack());
|
|
|
|
return font_editor;
|
|
|
|
}
|
|
|
|
|
2022-07-05 13:37:06 +03:00
|
|
|
virtual ~MainWidget() override = default;
|
2019-02-02 10:05:14 +03:00
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
ErrorOr<void> initialize(DeprecatedString const& path, RefPtr<Gfx::BitmapFont>&&);
|
2022-07-05 05:22:06 +03:00
|
|
|
ErrorOr<void> initialize_menubar(GUI::Window&);
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
ErrorOr<void> open_file(DeprecatedString const&);
|
|
|
|
ErrorOr<void> save_file(DeprecatedString const&);
|
2021-04-26 16:11:14 +03:00
|
|
|
bool request_close();
|
|
|
|
void update_title();
|
2020-07-11 04:20:39 +03:00
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
DeprecatedString const& path() { return m_path; }
|
2021-11-29 20:06:10 +03:00
|
|
|
Gfx::BitmapFont const& edited_font() { return *m_edited_font; }
|
2021-04-06 19:04:21 +03:00
|
|
|
|
|
|
|
bool is_showing_font_metadata() { return m_font_metadata; }
|
2022-02-13 23:18:39 +03:00
|
|
|
void set_show_font_metadata(bool);
|
|
|
|
|
|
|
|
bool is_showing_unicode_blocks() { return m_unicode_blocks; }
|
|
|
|
void set_show_unicode_blocks(bool);
|
2021-04-06 19:04:21 +03:00
|
|
|
|
2022-08-14 22:56:54 +03:00
|
|
|
void set_show_toolbar(bool);
|
|
|
|
void set_show_statusbar(bool);
|
|
|
|
|
2022-08-02 16:30:58 +03:00
|
|
|
void set_highlight_modifications(bool);
|
2022-08-14 23:00:26 +03:00
|
|
|
void set_show_system_emoji(bool);
|
2022-08-02 16:30:58 +03:00
|
|
|
|
2019-02-02 10:05:14 +03:00
|
|
|
private:
|
2022-07-05 13:37:06 +03:00
|
|
|
MainWidget();
|
2021-04-22 21:12:53 +03:00
|
|
|
|
2022-07-05 05:22:06 +03:00
|
|
|
ErrorOr<void> create_actions();
|
|
|
|
ErrorOr<void> create_models();
|
|
|
|
ErrorOr<void> create_toolbars();
|
|
|
|
ErrorOr<void> create_undo_stack();
|
2022-07-05 05:41:05 +03:00
|
|
|
ErrorOr<RefPtr<GUI::Window>> create_preview_window();
|
2022-07-05 05:22:06 +03:00
|
|
|
|
2022-11-05 00:32:17 +03:00
|
|
|
virtual void drag_enter_event(GUI::DragEvent&) override;
|
2021-10-13 23:16:25 +03:00
|
|
|
virtual void drop_event(GUI::DropEvent&) override;
|
|
|
|
|
2021-04-22 21:12:53 +03:00
|
|
|
void undo();
|
|
|
|
void redo();
|
2021-04-26 16:11:14 +03:00
|
|
|
void did_modify_font();
|
2021-09-22 16:25:25 +03:00
|
|
|
void update_statusbar();
|
|
|
|
void update_preview();
|
2021-11-14 16:26:10 +03:00
|
|
|
void set_scale_and_save(i32);
|
2021-04-22 21:12:53 +03:00
|
|
|
|
2022-07-30 14:30:30 +03:00
|
|
|
ErrorOr<void> copy_selected_glyphs();
|
|
|
|
ErrorOr<void> cut_selected_glyphs();
|
2022-01-04 20:24:06 +03:00
|
|
|
void paste_glyphs();
|
|
|
|
void delete_selected_glyphs();
|
|
|
|
|
2022-07-05 12:28:39 +03:00
|
|
|
void push_undo();
|
2022-03-19 15:52:26 +03:00
|
|
|
void reset_selection_and_push_undo();
|
|
|
|
|
2022-08-15 14:20:20 +03:00
|
|
|
void show_error(Error, StringView action, StringView basename = {});
|
2022-07-30 14:29:04 +03:00
|
|
|
|
2020-12-31 16:01:59 +03:00
|
|
|
RefPtr<Gfx::BitmapFont> m_edited_font;
|
2019-02-03 01:13:12 +03:00
|
|
|
|
2022-01-09 19:15:23 +03:00
|
|
|
RefPtr<GUI::GlyphMapWidget> m_glyph_map_widget;
|
2020-03-04 21:07:55 +03:00
|
|
|
RefPtr<GlyphEditorWidget> m_glyph_editor_widget;
|
2019-02-05 09:23:01 +03:00
|
|
|
|
2021-04-10 20:40:59 +03:00
|
|
|
RefPtr<GUI::Action> m_new_action;
|
|
|
|
RefPtr<GUI::Action> m_open_action;
|
|
|
|
RefPtr<GUI::Action> m_save_action;
|
|
|
|
RefPtr<GUI::Action> m_save_as_action;
|
|
|
|
|
|
|
|
RefPtr<GUI::Action> m_cut_action;
|
|
|
|
RefPtr<GUI::Action> m_copy_action;
|
|
|
|
RefPtr<GUI::Action> m_paste_action;
|
|
|
|
RefPtr<GUI::Action> m_delete_action;
|
|
|
|
|
2022-03-19 20:29:55 +03:00
|
|
|
RefPtr<GUI::Action> m_copy_text_action;
|
|
|
|
RefPtr<GUI::Action> m_select_all_action;
|
|
|
|
|
2021-04-22 21:12:53 +03:00
|
|
|
RefPtr<GUI::Action> m_undo_action;
|
|
|
|
RefPtr<GUI::Action> m_redo_action;
|
2022-03-17 15:56:02 +03:00
|
|
|
RefPtr<UndoSelection> m_undo_selection;
|
2021-04-22 21:12:53 +03:00
|
|
|
OwnPtr<GUI::UndoStack> m_undo_stack;
|
|
|
|
|
2021-09-09 14:43:19 +03:00
|
|
|
RefPtr<GUI::Action> m_go_to_glyph_action;
|
|
|
|
RefPtr<GUI::Action> m_previous_glyph_action;
|
|
|
|
RefPtr<GUI::Action> m_next_glyph_action;
|
|
|
|
|
2021-04-10 20:40:59 +03:00
|
|
|
RefPtr<GUI::Action> m_open_preview_action;
|
|
|
|
RefPtr<GUI::Action> m_show_metadata_action;
|
2022-02-13 23:18:39 +03:00
|
|
|
RefPtr<GUI::Action> m_show_unicode_blocks_action;
|
2022-08-14 22:56:54 +03:00
|
|
|
RefPtr<GUI::Action> m_show_toolbar_action;
|
|
|
|
RefPtr<GUI::Action> m_show_statusbar_action;
|
2022-08-02 16:30:58 +03:00
|
|
|
RefPtr<GUI::Action> m_highlight_modifications_action;
|
2022-08-14 23:00:26 +03:00
|
|
|
RefPtr<GUI::Action> m_show_system_emoji_action;
|
2021-04-10 20:40:59 +03:00
|
|
|
|
2021-04-22 21:04:19 +03:00
|
|
|
GUI::ActionGroup m_glyph_editor_scale_actions;
|
|
|
|
RefPtr<GUI::Action> m_scale_five_action;
|
|
|
|
RefPtr<GUI::Action> m_scale_ten_action;
|
|
|
|
RefPtr<GUI::Action> m_scale_fifteen_action;
|
|
|
|
|
2021-11-29 17:26:24 +03:00
|
|
|
GUI::ActionGroup m_glyph_tool_actions;
|
|
|
|
RefPtr<GUI::Action> m_move_glyph_action;
|
|
|
|
RefPtr<GUI::Action> m_paint_glyph_action;
|
|
|
|
|
|
|
|
RefPtr<GUI::Action> m_flip_horizontal_action;
|
|
|
|
RefPtr<GUI::Action> m_flip_vertical_action;
|
|
|
|
RefPtr<GUI::Action> m_rotate_clockwise_action;
|
|
|
|
RefPtr<GUI::Action> m_rotate_counterclockwise_action;
|
|
|
|
|
2021-09-22 16:25:25 +03:00
|
|
|
RefPtr<GUI::Statusbar> m_statusbar;
|
2022-08-14 22:56:54 +03:00
|
|
|
RefPtr<GUI::ToolbarContainer> m_toolbar_container;
|
2022-02-16 18:12:46 +03:00
|
|
|
RefPtr<GUI::Widget> m_unicode_block_container;
|
2021-04-10 20:40:59 +03:00
|
|
|
RefPtr<GUI::ComboBox> m_weight_combobox;
|
2021-09-24 03:07:34 +03:00
|
|
|
RefPtr<GUI::ComboBox> m_slope_combobox;
|
2021-04-06 19:04:21 +03:00
|
|
|
RefPtr<GUI::SpinBox> m_spacing_spinbox;
|
|
|
|
RefPtr<GUI::SpinBox> m_baseline_spinbox;
|
|
|
|
RefPtr<GUI::SpinBox> m_mean_line_spinbox;
|
|
|
|
RefPtr<GUI::SpinBox> m_presentation_spinbox;
|
|
|
|
RefPtr<GUI::SpinBox> m_glyph_editor_width_spinbox;
|
2021-04-18 21:12:52 +03:00
|
|
|
RefPtr<GUI::CheckBox> m_glyph_editor_present_checkbox;
|
2021-04-06 19:04:21 +03:00
|
|
|
RefPtr<GUI::TextBox> m_name_textbox;
|
|
|
|
RefPtr<GUI::TextBox> m_family_textbox;
|
2022-02-16 18:12:46 +03:00
|
|
|
RefPtr<GUI::TextBox> m_search_textbox;
|
2021-04-06 19:04:21 +03:00
|
|
|
RefPtr<GUI::CheckBox> m_fixed_width_checkbox;
|
|
|
|
RefPtr<GUI::GroupBox> m_font_metadata_groupbox;
|
2022-02-13 23:18:39 +03:00
|
|
|
RefPtr<GUI::ListView> m_unicode_block_listview;
|
|
|
|
RefPtr<GUI::Model> m_unicode_block_model;
|
2022-02-16 18:12:46 +03:00
|
|
|
RefPtr<GUI::FilteringProxyModel> m_filter_model;
|
2022-03-19 20:29:55 +03:00
|
|
|
RefPtr<GUI::Menu> m_context_menu;
|
2021-04-06 19:04:21 +03:00
|
|
|
|
2022-07-05 05:41:05 +03:00
|
|
|
RefPtr<GUI::Label> m_preview_label;
|
|
|
|
RefPtr<GUI::TextBox> m_preview_textbox;
|
|
|
|
RefPtr<GUI::Window> m_font_preview_window;
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
DeprecatedString m_path;
|
|
|
|
Vector<DeprecatedString> m_font_weight_list;
|
|
|
|
Vector<DeprecatedString> m_font_slope_list;
|
|
|
|
Vector<DeprecatedString> m_unicode_block_list;
|
2021-04-06 19:04:21 +03:00
|
|
|
bool m_font_metadata { true };
|
2022-02-13 23:18:39 +03:00
|
|
|
bool m_unicode_blocks { true };
|
|
|
|
Unicode::CodePointRange m_range { 0x0000, 0x10FFFF };
|
2019-02-02 10:05:14 +03:00
|
|
|
};
|
2022-07-05 12:32:22 +03:00
|
|
|
|
|
|
|
}
|