1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:17:45 +00:00

Add concept of size increments to windowing system.

Use this to implement incremental resizing for Terminal so that we only
ever resize to fit a perfect number of rows and columns.

This is very nice. :^)
This commit is contained in:
Andreas Kling 2019-02-21 00:21:23 +01:00
parent fd575055c2
commit 6084cd0c56
12 changed files with 47 additions and 4 deletions

View file

@ -785,7 +785,6 @@ void Terminal::force_repaint()
{
for (int i = 0; i < m_rows; ++i)
line(i).dirty = true;
m_need_full_flush = true;
update();
}
@ -795,3 +794,9 @@ void Terminal::resize_event(GResizeEvent& event)
int new_rows = event.size().height() / m_line_height;
set_size(new_columns, new_rows);
}
void Terminal::apply_size_increments_to_window(GWindow& window)
{
window.set_size_increment({ font().glyph_width(), m_line_height });
window.set_base_size({ m_inset, m_inset });
}

View file

@ -21,6 +21,8 @@ public:
void flush_dirty_lines();
void force_repaint();
void apply_size_increments_to_window(GWindow&);
private:
virtual void event(GEvent&) override;
virtual void paint_event(GPaintEvent&) override;

View file

@ -92,6 +92,7 @@ int main(int argc, char** argv)
window->set_has_alpha_channel(true);
window->set_main_widget(&terminal);
window->move_to(300, 300);
terminal.apply_size_increments_to_window(*window);
window->show();
auto menubar = make<GMenuBar>();