mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00: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
1 changed files with 4 additions and 0 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include <LibGUI/GTextBox.h>
|
#include <LibGUI/GTextBox.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
|
|
||||||
|
static const int minimum_column_width = 2;
|
||||||
|
|
||||||
GTableView::GTableView(GWidget* parent)
|
GTableView::GTableView(GWidget* parent)
|
||||||
: GAbstractView(parent)
|
: GAbstractView(parent)
|
||||||
{
|
{
|
||||||
|
@ -217,6 +219,8 @@ void GTableView::mousemove_event(GMouseEvent& event)
|
||||||
if (m_in_column_resize) {
|
if (m_in_column_resize) {
|
||||||
auto delta = event.position() - m_column_resize_origin;
|
auto delta = event.position() - m_column_resize_origin;
|
||||||
int new_width = m_column_resize_original_width + delta.x();
|
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());
|
ASSERT(m_resizing_column >= 0 && m_resizing_column < model()->column_count());
|
||||||
auto& column_data = this->column_data(m_resizing_column);
|
auto& column_data = this->column_data(m_resizing_column);
|
||||||
if (column_data.width != new_width) {
|
if (column_data.width != new_width) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue