mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
GTableView: Don't allow resizing columns to a negative width
This is definitely not perfect but better than letting you put the GTableView into a weird state with negative column widths. :^)
This commit is contained in:
parent
e08d605f72
commit
e630ad5927
Notes:
sideshowbarker
2024-07-19 11:07:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e630ad59273
1 changed files with 4 additions and 0 deletions
|
@ -9,6 +9,8 @@
|
|||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
|
||||
static const int minimum_column_width = 2;
|
||||
|
||||
GTableView::GTableView(GWidget* parent)
|
||||
: GAbstractView(parent)
|
||||
{
|
||||
|
@ -217,6 +219,8 @@ void GTableView::mousemove_event(GMouseEvent& event)
|
|||
if (m_in_column_resize) {
|
||||
auto delta = event.position() - m_column_resize_origin;
|
||||
int new_width = m_column_resize_original_width + delta.x();
|
||||
if (new_width <= minimum_column_width)
|
||||
new_width = minimum_column_width;
|
||||
ASSERT(m_resizing_column >= 0 && m_resizing_column < model()->column_count());
|
||||
auto& column_data = this->column_data(m_resizing_column);
|
||||
if (column_data.width != new_width) {
|
||||
|
|
Loading…
Add table
Reference in a new issue