Compare commits

...

4 Commits

Author SHA1 Message Date
Khalid Abu Shawarib
af9567b221 gtk/columnview: Invert resizing drag direction in RTL
Reverse the side of column resizing drag handle in RTL and change
the base for drag coordinates and the column resizing caluculations.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6049
2024-04-13 22:24:51 +03:00
Khalid Abu Shawarib
e411b14105 gtk/columnview: Invert horizontal translation in RTL
Part of https://gitlab.gnome.org/GNOME/gtk/-/issues/6049
2024-04-13 21:50:19 +03:00
Khalid Abu Shawarib
55f908279f gtk/range: Invert autoscroll properly
This inverts autoscroll properly in Right-to-Left.

part of https://gitlab.gnome.org/GNOME/gtk/-/issues/6049
2024-04-13 21:50:19 +03:00
Khalid Abu Shawarib
e3a416bf2b gtk/scrollbar: Mark range as flippable
This inverts both the gesture interaction and physical placment of
the scrollbar in Right-to-Left.

Part of https://gitlab.gnome.org/GNOME/gtk/-/issues/6049
2024-04-13 21:50:19 +03:00
3 changed files with 27 additions and 7 deletions

View File

@@ -484,7 +484,7 @@ gtk_column_view_allocate (GtkWidget *widget,
int baseline)
{
GtkColumnView *self = GTK_COLUMN_VIEW (widget);
int full_width, header_height, min, nat, x;
int full_width, header_height, min, nat, x, dx;
x = gtk_adjustment_get_value (self->hadjustment);
full_width = gtk_column_view_allocate_columns (self, width);
@@ -494,12 +494,15 @@ gtk_column_view_allocate (GtkWidget *widget,
header_height = min;
else
header_height = nat;
dx = (_gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) ? -x : width - full_width + x;
gtk_widget_allocate (self->header, full_width, header_height, -1,
gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (-x, 0)));
gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (dx, 0)));
gtk_widget_allocate (GTK_WIDGET (self->listview),
full_width, height - header_height, -1,
gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (-x, header_height)));
gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (dx, header_height)));
gtk_adjustment_configure (self->hadjustment, x, 0, full_width, width * 0.1, width * 0.9, width);
}
@@ -1065,7 +1068,9 @@ gtk_column_view_in_resize_rect (GtkColumnView *self,
gtk_column_view_column_get_allocation (column, NULL, &width);
rect.size.width = width;
rect.origin.x += rect.size.width - DRAG_WIDTH / 2;
if (_gtk_widget_get_direction (GTK_WIDGET (self)) != GTK_TEXT_DIR_RTL)
rect.origin.x += rect.size.width;
rect.origin.x -= DRAG_WIDTH / 2;
rect.size.width = DRAG_WIDTH;
return graphene_rect_contains_point (&rect, &(graphene_point_t) { x, y});
@@ -1142,7 +1147,14 @@ header_drag_begin (GtkGestureDrag *gesture,
gtk_column_view_column_set_fixed_width (column, size);
self->drag_pos = i;
self->drag_x = start_x - size;
if (_gtk_widget_get_direction (GTK_WIDGET (self)) != GTK_TEXT_DIR_RTL)
self->drag_x = start_x - size;
else
{
int width = gtk_widget_get_width (GTK_WIDGET (self->header));
self->drag_x = width - (start_x + size);
}
self->in_column_resize = TRUE;
set_resize_cursor (self, TRUE);
@@ -1254,6 +1266,13 @@ update_column_resize (GtkColumnView *self,
{
GtkColumnViewColumn *column;
if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
{
int width = gtk_widget_get_width (GTK_WIDGET (self->header));
x = width - x;
}
column = g_list_model_get_item (G_LIST_MODEL (self->columns), self->drag_pos);
gtk_column_view_column_set_fixed_width (column, MAX (x - self->drag_x, 0));
g_object_unref (column);

View File

@@ -2291,9 +2291,9 @@ update_autoscroll_mode (GtkRange *range,
}
if (pos < SCROLL_EDGE_SIZE)
mode = priv->inverted ? GTK_SCROLL_STEP_FORWARD : GTK_SCROLL_STEP_BACKWARD;
mode = should_invert (range) ? GTK_SCROLL_STEP_FORWARD : GTK_SCROLL_STEP_BACKWARD;
else if (pos > (size - SCROLL_EDGE_SIZE))
mode = priv->inverted ? GTK_SCROLL_STEP_BACKWARD : GTK_SCROLL_STEP_FORWARD;
mode = should_invert (range) ? GTK_SCROLL_STEP_BACKWARD : GTK_SCROLL_STEP_FORWARD;
}
if (mode != priv->autoscroll_mode)

View File

@@ -263,6 +263,7 @@ gtk_scrollbar_init (GtkScrollbar *self)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
priv->range = g_object_new (GTK_TYPE_RANGE, NULL);
gtk_range_set_flippable (GTK_RANGE (priv->range), TRUE);
gtk_widget_set_hexpand (priv->range, TRUE);
gtk_widget_set_vexpand (priv->range, TRUE);
gtk_widget_set_parent (priv->range, GTK_WIDGET (self));