diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-01-11 20:52:03 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-16 11:17:03 +0100 |
commit | 2bf7abcb283c250781fa4fe9e255c5dbfd9b7b04 (patch) | |
tree | 1532d0099ae27499628e085290043296af92069f | |
parent | e975db23c0ad6fdbad4b376da614135cc62fd6a2 (diff) | |
download | serenity-2bf7abcb283c250781fa4fe9e255c5dbfd9b7b04.zip |
CharacterMap: Add previous, next, and go-to glyph buttons
These work the same as in FontEditor, where I shamelessly stole them
from. :^)
-rw-r--r-- | Userland/Applications/CharacterMap/CharacterMapWidget.cpp | 31 | ||||
-rw-r--r-- | Userland/Applications/CharacterMap/CharacterMapWidget.h | 3 |
2 files changed, 34 insertions, 0 deletions
diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index c35e9162f2..553b1326e1 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -5,6 +5,7 @@ */ #include "CharacterMapWidget.h" +#include <AK/StringUtils.h> #include <Applications/CharacterMap/CharacterMapWindowGML.h> #include <LibConfig/Client.h> #include <LibGUI/Action.h> @@ -12,6 +13,7 @@ #include <LibGUI/Clipboard.h> #include <LibGUI/FontPicker.h> #include <LibGUI/Icon.h> +#include <LibGUI/InputBox.h> #include <LibGUI/Label.h> #include <LibGUI/Menu.h> #include <LibGUI/TextBox.h> @@ -48,10 +50,39 @@ CharacterMapWidget::CharacterMapWidget() } GUI::Clipboard::the().set_plain_text(builder.to_string()); }); + m_copy_selection_action->set_status_tip("Copy the highlighted characters to the clipboard"); + + m_previous_glyph_action = GUI::Action::create("Previous character", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_glyph_map->select_previous_existing_glyph(); + }); + m_previous_glyph_action->set_status_tip("Seek the previous visible glyph"); + + m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_glyph_map->select_next_existing_glyph(); + }); + m_next_glyph_action->set_status_tip("Seek the next visible glyph"); + + m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + String input; + if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecOK && !input.is_empty()) { + auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); + if (!maybe_code_point.has_value()) + return; + auto code_point = clamp(maybe_code_point.value(), 0x0000, 0x10FFFF); + m_glyph_map->set_focus(true); + m_glyph_map->set_active_glyph(code_point); + m_glyph_map->scroll_to_glyph(code_point); + } + }); + m_go_to_glyph_action->set_status_tip("Go to the specified code point"); m_toolbar->add_action(*m_choose_font_action); m_toolbar->add_separator(); m_toolbar->add_action(*m_copy_selection_action); + m_toolbar->add_separator(); + m_toolbar->add_action(*m_previous_glyph_action); + m_toolbar->add_action(*m_next_glyph_action); + m_toolbar->add_action(*m_go_to_glyph_action); m_glyph_map->on_active_glyph_changed = [&](int) { update_statusbar(); diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.h b/Userland/Applications/CharacterMap/CharacterMapWidget.h index 2af5f93c5d..0b57a35a01 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.h +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.h @@ -33,4 +33,7 @@ private: RefPtr<GUI::Action> m_choose_font_action; RefPtr<GUI::Action> m_copy_selection_action; + RefPtr<GUI::Action> m_previous_glyph_action; + RefPtr<GUI::Action> m_next_glyph_action; + RefPtr<GUI::Action> m_go_to_glyph_action; }; |