mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
FontEditor: Move common restoration work into restore_state()
This commit is contained in:
parent
c7eee16292
commit
cf4ddd1dcf
2 changed files with 14 additions and 29 deletions
|
@ -803,12 +803,8 @@ void MainWidget::reset_selection_and_push_undo()
|
||||||
push_undo();
|
push_undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::undo()
|
void MainWidget::restore_state()
|
||||||
{
|
{
|
||||||
if (!m_undo_stack->can_undo())
|
|
||||||
return;
|
|
||||||
m_undo_stack->undo();
|
|
||||||
|
|
||||||
auto glyph = m_undo_selection->restored_active_glyph();
|
auto glyph = m_undo_selection->restored_active_glyph();
|
||||||
auto glyph_width = m_font->raw_glyph_width(glyph);
|
auto glyph_width = m_font->raw_glyph_width(glyph);
|
||||||
if (glyph < m_range.first || glyph > m_range.last)
|
if (glyph < m_range.first || glyph > m_range.last)
|
||||||
|
@ -820,43 +816,31 @@ void MainWidget::undo()
|
||||||
m_glyph_map_widget->scroll_to_glyph(glyph);
|
m_glyph_map_widget->scroll_to_glyph(glyph);
|
||||||
m_glyph_map_widget->set_focus(true);
|
m_glyph_map_widget->set_focus(true);
|
||||||
|
|
||||||
if (m_font->is_fixed_width()) {
|
if (m_font->is_fixed_width())
|
||||||
m_glyph_editor_present_checkbox->set_checked(glyph_width > 0, GUI::AllowCallback::No);
|
m_glyph_editor_present_checkbox->set_checked(glyph_width > 0, GUI::AllowCallback::No);
|
||||||
} else {
|
else
|
||||||
m_glyph_editor_width_spinbox->set_value(glyph_width, GUI::AllowCallback::No);
|
m_glyph_editor_width_spinbox->set_value(glyph_width, GUI::AllowCallback::No);
|
||||||
}
|
|
||||||
m_glyph_editor_widget->update();
|
m_glyph_editor_widget->update();
|
||||||
m_glyph_map_widget->update();
|
m_glyph_map_widget->update();
|
||||||
update_preview();
|
update_preview();
|
||||||
update_statusbar();
|
update_statusbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::undo()
|
||||||
|
{
|
||||||
|
if (!m_undo_stack->can_undo())
|
||||||
|
return;
|
||||||
|
m_undo_stack->undo();
|
||||||
|
restore_state();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::redo()
|
void MainWidget::redo()
|
||||||
{
|
{
|
||||||
if (!m_undo_stack->can_redo())
|
if (!m_undo_stack->can_redo())
|
||||||
return;
|
return;
|
||||||
m_undo_stack->redo();
|
m_undo_stack->redo();
|
||||||
|
restore_state();
|
||||||
auto glyph = m_undo_selection->restored_active_glyph();
|
|
||||||
auto glyph_width = m_font->raw_glyph_width(glyph);
|
|
||||||
if (glyph < m_range.first || glyph > m_range.last)
|
|
||||||
m_search_textbox->set_text(""sv);
|
|
||||||
|
|
||||||
auto start = m_undo_selection->restored_start();
|
|
||||||
auto size = m_undo_selection->restored_size();
|
|
||||||
m_glyph_map_widget->restore_selection(start, size, glyph);
|
|
||||||
m_glyph_map_widget->scroll_to_glyph(glyph);
|
|
||||||
m_glyph_map_widget->set_focus(true);
|
|
||||||
|
|
||||||
if (m_font->is_fixed_width()) {
|
|
||||||
m_glyph_editor_present_checkbox->set_checked(glyph_width > 0, GUI::AllowCallback::No);
|
|
||||||
} else {
|
|
||||||
m_glyph_editor_width_spinbox->set_value(glyph_width, GUI::AllowCallback::No);
|
|
||||||
}
|
|
||||||
m_glyph_editor_widget->update();
|
|
||||||
m_glyph_map_widget->update();
|
|
||||||
update_preview();
|
|
||||||
update_statusbar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::request_close()
|
bool MainWidget::request_close()
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
|
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
void restore_state();
|
||||||
void did_modify_font();
|
void did_modify_font();
|
||||||
|
|
||||||
void update_statusbar();
|
void update_statusbar();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue