forked from AuroraMiddleware/gtk
Merge branch 'matthiasc/for-master' into 'master'
Various columnview fixes Closes #3265, #3272, and #3276 See merge request GNOME/gtk!2717
This commit is contained in:
commit
2359510b1f
@ -41,6 +41,7 @@
|
|||||||
#include "gtkeventcontrollermotion.h"
|
#include "gtkeventcontrollermotion.h"
|
||||||
#include "gtkdragsource.h"
|
#include "gtkdragsource.h"
|
||||||
#include "gtkeventcontrollerkey.h"
|
#include "gtkeventcontrollerkey.h"
|
||||||
|
#include "gtkgestureclick.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkcolumnview
|
* SECTION:gtkcolumnview
|
||||||
@ -852,7 +853,7 @@ update_autoscroll (GtkColumnView *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DRAG_WIDTH 6
|
#define DRAG_WIDTH 8
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_column_view_in_resize_rect (GtkColumnView *self,
|
gtk_column_view_in_resize_rect (GtkColumnView *self,
|
||||||
@ -862,12 +863,16 @@ gtk_column_view_in_resize_rect (GtkColumnView *self,
|
|||||||
{
|
{
|
||||||
GtkWidget *header;
|
GtkWidget *header;
|
||||||
graphene_rect_t rect;
|
graphene_rect_t rect;
|
||||||
|
int width;
|
||||||
|
|
||||||
header = gtk_column_view_column_get_header (column);
|
header = gtk_column_view_column_get_header (column);
|
||||||
|
|
||||||
if (!gtk_widget_compute_bounds (header, self->header, &rect))
|
if (!gtk_widget_compute_bounds (header, self->header, &rect))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
gtk_column_view_column_get_allocation (column, NULL, &width);
|
||||||
|
rect.size.width = width;
|
||||||
|
|
||||||
rect.origin.x += rect.size.width - DRAG_WIDTH / 2;
|
rect.origin.x += rect.size.width - DRAG_WIDTH / 2;
|
||||||
rect.size.width = DRAG_WIDTH;
|
rect.size.width = DRAG_WIDTH;
|
||||||
|
|
||||||
@ -891,6 +896,25 @@ header = gtk_column_view_column_get_header (column);
|
|||||||
return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
|
return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_resize_cursor (GtkColumnView *self,
|
||||||
|
gboolean set)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
||||||
|
GtkWidget *header = gtk_column_view_column_get_header (column);
|
||||||
|
if (set)
|
||||||
|
gtk_widget_set_cursor_from_name (header, "col-resize");
|
||||||
|
else
|
||||||
|
gtk_widget_set_cursor (header, NULL);
|
||||||
|
g_object_unref (column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
header_drag_begin (GtkGestureDrag *gesture,
|
header_drag_begin (GtkGestureDrag *gesture,
|
||||||
double start_x,
|
double start_x,
|
||||||
@ -902,7 +926,7 @@ header_drag_begin (GtkGestureDrag *gesture,
|
|||||||
self->drag_pos = -1;
|
self->drag_pos = -1;
|
||||||
|
|
||||||
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
for (i = 0; !self->in_column_resize && i < n; i++)
|
for (i = n - 1; !self->in_column_resize && i >= 0; i--)
|
||||||
{
|
{
|
||||||
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
||||||
|
|
||||||
@ -929,9 +953,23 @@ header_drag_begin (GtkGestureDrag *gesture,
|
|||||||
self->drag_x = start_x - size;
|
self->drag_x = start_x - size;
|
||||||
self->in_column_resize = TRUE;
|
self->in_column_resize = TRUE;
|
||||||
|
|
||||||
|
set_resize_cursor (self, TRUE);
|
||||||
|
|
||||||
g_object_unref (column);
|
g_object_unref (column);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; !self->in_column_resize && i < n; i++)
|
||||||
|
{
|
||||||
|
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
||||||
|
|
||||||
|
if (!gtk_column_view_column_get_visible (column))
|
||||||
|
{
|
||||||
|
g_object_unref (column);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (gtk_column_view_get_reorderable (self) &&
|
if (gtk_column_view_get_reorderable (self) &&
|
||||||
gtk_column_view_in_header (self, column, start_x, start_y))
|
gtk_column_view_in_header (self, column, start_x, start_y))
|
||||||
@ -966,6 +1004,7 @@ header_drag_end (GtkGestureDrag *gesture,
|
|||||||
|
|
||||||
if (self->in_column_resize)
|
if (self->in_column_resize)
|
||||||
{
|
{
|
||||||
|
set_resize_cursor (self, FALSE);
|
||||||
self->in_column_resize = FALSE;
|
self->in_column_resize = FALSE;
|
||||||
}
|
}
|
||||||
else if (self->in_column_reorder)
|
else if (self->in_column_reorder)
|
||||||
@ -1102,6 +1141,9 @@ header_motion (GtkEventControllerMotion *controller,
|
|||||||
gboolean cursor_set = FALSE;
|
gboolean cursor_set = FALSE;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
|
if (self->in_column_resize)
|
||||||
|
return;
|
||||||
|
|
||||||
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -1145,6 +1187,36 @@ header_key_pressed (GtkEventControllerKey *controller,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
header_pressed (GtkGestureClick *gesture,
|
||||||
|
int n_press,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
GtkColumnView *self)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
if (n_press != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
|
for (i = n - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
||||||
|
|
||||||
|
g_object_unref (column);
|
||||||
|
|
||||||
|
if (i + 1 < n &&
|
||||||
|
gtk_column_view_column_get_resizable (column) &&
|
||||||
|
gtk_column_view_in_resize_rect (self, column, x, y))
|
||||||
|
{
|
||||||
|
gtk_gesture_set_state (self->drag_gesture, GTK_EVENT_SEQUENCE_DENIED);
|
||||||
|
gtk_column_view_column_set_fixed_width (column, -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_column_view_drag_motion (GtkDropControllerMotion *motion,
|
gtk_column_view_drag_motion (GtkDropControllerMotion *motion,
|
||||||
double x,
|
double x,
|
||||||
@ -1180,6 +1252,11 @@ gtk_column_view_init (GtkColumnView *self)
|
|||||||
gtk_widget_set_layout_manager (self->header, gtk_column_view_layout_new (self));
|
gtk_widget_set_layout_manager (self->header, gtk_column_view_layout_new (self));
|
||||||
gtk_widget_set_parent (self->header, GTK_WIDGET (self));
|
gtk_widget_set_parent (self->header, GTK_WIDGET (self));
|
||||||
|
|
||||||
|
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
|
||||||
|
g_signal_connect (controller, "pressed", G_CALLBACK (header_pressed), self);
|
||||||
|
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
|
||||||
|
gtk_widget_add_controller (self->header, controller);
|
||||||
|
|
||||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
|
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
|
||||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (header_drag_begin), self);
|
g_signal_connect (controller, "drag-begin", G_CALLBACK (header_drag_begin), self);
|
||||||
g_signal_connect (controller, "drag-update", G_CALLBACK (header_drag_update), self);
|
g_signal_connect (controller, "drag-update", G_CALLBACK (header_drag_update), self);
|
||||||
|
@ -124,15 +124,15 @@ gtk_column_view_cell_size_allocate (GtkWidget *widget,
|
|||||||
int height,
|
int height,
|
||||||
int baseline)
|
int baseline)
|
||||||
{
|
{
|
||||||
GtkColumnViewCell *self = GTK_COLUMN_VIEW_CELL (widget);
|
|
||||||
GtkWidget *child = gtk_widget_get_first_child (widget);
|
GtkWidget *child = gtk_widget_get_first_child (widget);
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
if (gtk_column_view_column_get_fixed_width (self->column) > -1)
|
int min;
|
||||||
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
|
|
||||||
|
|
||||||
gtk_widget_allocate (child, width, height, baseline, NULL);
|
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +136,11 @@ gtk_column_view_title_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
if (gtk_column_view_column_get_fixed_width (self->column) > -1)
|
int min;
|
||||||
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
|
|
||||||
|
|
||||||
gtk_widget_allocate (child, width, height, baseline, NULL);
|
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->popup_menu)
|
if (self->popup_menu)
|
||||||
|
@ -1069,13 +1069,11 @@ gtk_inspector_visual_constructed (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_inspector_visual_dispose (GObject *object)
|
gtk_inspector_visual_unroot (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
|
GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (widget);
|
||||||
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
||||||
|
|
||||||
g_clear_pointer (&vis->swin, gtk_widget_unparent);
|
|
||||||
|
|
||||||
if (vis->layout_overlay)
|
if (vis->layout_overlay)
|
||||||
{
|
{
|
||||||
gtk_inspector_window_remove_overlay (iw, vis->layout_overlay);
|
gtk_inspector_window_remove_overlay (iw, vis->layout_overlay);
|
||||||
@ -1097,6 +1095,16 @@ gtk_inspector_visual_dispose (GObject *object)
|
|||||||
vis->focus_overlay = NULL;
|
vis->focus_overlay = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (gtk_inspector_visual_parent_class)->unroot (widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_inspector_visual_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
|
||||||
|
|
||||||
|
g_clear_pointer (&vis->swin, gtk_widget_unparent);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1109,6 +1117,8 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
|
|||||||
object_class->constructed = gtk_inspector_visual_constructed;
|
object_class->constructed = gtk_inspector_visual_constructed;
|
||||||
object_class->dispose = gtk_inspector_visual_dispose;
|
object_class->dispose = gtk_inspector_visual_dispose;
|
||||||
|
|
||||||
|
widget_class->unroot = gtk_inspector_visual_unroot;
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui");
|
||||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, swin);
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, swin);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, box);
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, box);
|
||||||
|
@ -1772,7 +1772,7 @@ treeview.view {
|
|||||||
%column_header_button {
|
%column_header_button {
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
background-image: none;
|
background-image: none;
|
||||||
border-style: none solid solid none;
|
border-style: none none solid solid;
|
||||||
border-color: $_treeview_borders_color;
|
border-color: $_treeview_borders_color;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
@ -3141,15 +3141,15 @@ columnview {
|
|||||||
> cell {
|
> cell {
|
||||||
padding: 8px 6px;
|
padding: 8px 6px;
|
||||||
|
|
||||||
&:not(:last-child) {
|
&:not(:first-child) {
|
||||||
border-right: 1px solid transparent;
|
border-left: 1px solid transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make column separators visible when :show-column-separators is true
|
// make column separators visible when :show-column-separators is true
|
||||||
&.column-separators > listview > row > cell {
|
&.column-separators > listview > row > cell {
|
||||||
border-right-color: $_treeview_borders_color;
|
border-left-color: $_treeview_borders_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shrink vertically for .data-table
|
// shrink vertically for .data-table
|
||||||
|
Loading…
Reference in New Issue
Block a user