mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibGUI+FontEditor: Move seek-prev/next-glyph logic into GlyphMapWidget
This commit is contained in:
parent
9ca8428238
commit
e975db23c0
3 changed files with 43 additions and 30 deletions
|
@ -233,39 +233,11 @@ FontEditorWidget::FontEditorWidget()
|
||||||
});
|
});
|
||||||
m_go_to_glyph_action->set_status_tip("Go to the specified code point");
|
m_go_to_glyph_action->set_status_tip("Go to the specified code point");
|
||||||
m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { 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_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||||
bool search_wrapped = false;
|
m_glyph_map_widget->select_previous_existing_glyph();
|
||||||
for (int i = m_glyph_map_widget->active_glyph() - 1;; --i) {
|
|
||||||
if (i < 0 && !search_wrapped) {
|
|
||||||
i = 0x10FFFF;
|
|
||||||
search_wrapped = true;
|
|
||||||
} else if (i < 0 && search_wrapped) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (m_edited_font->contains_raw_glyph(i)) {
|
|
||||||
m_glyph_map_widget->set_focus(true);
|
|
||||||
m_glyph_map_widget->set_active_glyph(i);
|
|
||||||
m_glyph_map_widget->scroll_to_glyph(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
m_previous_glyph_action->set_status_tip("Seek the previous visible 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_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&) {
|
||||||
bool search_wrapped = false;
|
m_glyph_map_widget->select_next_existing_glyph();
|
||||||
for (int i = m_glyph_map_widget->active_glyph() + 1;; ++i) {
|
|
||||||
if (i > 0x10FFFF && !search_wrapped) {
|
|
||||||
i = 0;
|
|
||||||
search_wrapped = true;
|
|
||||||
} else if (i > 0x10FFFF && search_wrapped) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (m_edited_font->contains_raw_glyph(i)) {
|
|
||||||
m_glyph_map_widget->set_focus(true);
|
|
||||||
m_glyph_map_widget->set_active_glyph(i);
|
|
||||||
m_glyph_map_widget->scroll_to_glyph(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
m_next_glyph_action->set_status_tip("Seek the next visible glyph");
|
m_next_glyph_action->set_status_tip("Seek the next visible glyph");
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,44 @@ void GlyphMapWidget::scroll_to_glyph(int glyph)
|
||||||
scroll_into_view(scroll_rect, true, true);
|
scroll_into_view(scroll_rect, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlyphMapWidget::select_previous_existing_glyph()
|
||||||
|
{
|
||||||
|
bool search_wrapped = false;
|
||||||
|
for (int i = active_glyph() - 1;; --i) {
|
||||||
|
if (i < 0 && !search_wrapped) {
|
||||||
|
i = 0x10FFFF;
|
||||||
|
search_wrapped = true;
|
||||||
|
} else if (i < 0 && search_wrapped) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (font().contains_glyph(i)) {
|
||||||
|
set_focus(true);
|
||||||
|
set_active_glyph(i);
|
||||||
|
scroll_to_glyph(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlyphMapWidget::select_next_existing_glyph()
|
||||||
|
{
|
||||||
|
bool search_wrapped = false;
|
||||||
|
for (int i = active_glyph() + 1;; ++i) {
|
||||||
|
if (i > 0x10FFFF && !search_wrapped) {
|
||||||
|
i = 0;
|
||||||
|
search_wrapped = true;
|
||||||
|
} else if (i > 0x10FFFF && search_wrapped) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (font().contains_glyph(i)) {
|
||||||
|
set_focus(true);
|
||||||
|
set_active_glyph(i);
|
||||||
|
scroll_to_glyph(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GlyphMapWidget::recalculate_content_size()
|
void GlyphMapWidget::recalculate_content_size()
|
||||||
{
|
{
|
||||||
auto inner_rect = frame_inner_rect();
|
auto inner_rect = frame_inner_rect();
|
||||||
|
|
|
@ -56,6 +56,9 @@ public:
|
||||||
void scroll_to_glyph(int);
|
void scroll_to_glyph(int);
|
||||||
void update_glyph(int);
|
void update_glyph(int);
|
||||||
|
|
||||||
|
void select_previous_existing_glyph();
|
||||||
|
void select_next_existing_glyph();
|
||||||
|
|
||||||
int rows() const { return m_rows; }
|
int rows() const { return m_rows; }
|
||||||
int columns() const { return m_columns; }
|
int columns() const { return m_columns; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue