flowbox: Use a CSS node for rubberband drawing
Use a CSS node with name rubberband to draw the rubberband selection.
This commit is contained in:
parent
75d465eee4
commit
6c7f4b78b5
@ -56,6 +56,7 @@
|
|||||||
*
|
*
|
||||||
* GtkFlowBox uses a single CSS node with name flowbox. GtkFlowBoxChild
|
* GtkFlowBox uses a single CSS node with name flowbox. GtkFlowBoxChild
|
||||||
* uses a single CSS node with name flowboxchild.
|
* uses a single CSS node with name flowboxchild.
|
||||||
|
* For rubberband selection, a subnode with name rubberband is used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -67,6 +68,7 @@
|
|||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
#include "gtkcssnodeprivate.h"
|
#include "gtkcssnodeprivate.h"
|
||||||
#include "gtkwidgetprivate.h"
|
#include "gtkwidgetprivate.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
|
|
||||||
#include "a11y/gtkflowboxaccessibleprivate.h"
|
#include "a11y/gtkflowboxaccessibleprivate.h"
|
||||||
#include "a11y/gtkflowboxchildaccessible.h"
|
#include "a11y/gtkflowboxchildaccessible.h"
|
||||||
@ -813,9 +815,10 @@ struct _GtkFlowBoxPrivate {
|
|||||||
GtkGesture *multipress_gesture;
|
GtkGesture *multipress_gesture;
|
||||||
GtkGesture *drag_gesture;
|
GtkGesture *drag_gesture;
|
||||||
|
|
||||||
gboolean rubberband_select;
|
|
||||||
GtkFlowBoxChild *rubberband_first;
|
GtkFlowBoxChild *rubberband_first;
|
||||||
GtkFlowBoxChild *rubberband_last;
|
GtkFlowBoxChild *rubberband_last;
|
||||||
|
GtkCssNode *rubberband_node;
|
||||||
|
gboolean rubberband_select;
|
||||||
gboolean rubberband_modify;
|
gboolean rubberband_modify;
|
||||||
gboolean rubberband_extend;
|
gboolean rubberband_extend;
|
||||||
|
|
||||||
@ -2564,8 +2567,7 @@ gtk_flow_box_draw (GtkWidget *widget,
|
|||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
gtk_style_context_save (context);
|
gtk_style_context_save_to_node (context, priv->rubberband_node);
|
||||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
|
|
||||||
|
|
||||||
iter1 = CHILD_PRIV (priv->rubberband_first)->iter;
|
iter1 = CHILD_PRIV (priv->rubberband_first)->iter;
|
||||||
iter2 = CHILD_PRIV (priv->rubberband_last)->iter;
|
iter2 = CHILD_PRIV (priv->rubberband_last)->iter;
|
||||||
@ -2637,7 +2639,7 @@ gtk_flow_box_draw (GtkWidget *widget,
|
|||||||
cairo_append_path (cr, path);
|
cairo_append_path (cr, path);
|
||||||
cairo_path_destroy (path);
|
cairo_path_destroy (path);
|
||||||
|
|
||||||
state = gtk_widget_get_state_flags (widget);
|
state = gtk_style_context_get_state (context);
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
gtk_style_context_get_border_color (context, state, &border_color);
|
gtk_style_context_get_border_color (context, state, &border_color);
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
@ -2863,6 +2865,7 @@ gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
|
|||||||
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
|
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
|
||||||
gdouble start_x, start_y;
|
gdouble start_x, start_y;
|
||||||
GtkFlowBoxChild *child;
|
GtkFlowBoxChild *child;
|
||||||
|
GtkCssNode *widget_node;
|
||||||
|
|
||||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||||
|
|
||||||
@ -2871,6 +2874,13 @@ gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
|
|||||||
{
|
{
|
||||||
priv->rubberband_select = TRUE;
|
priv->rubberband_select = TRUE;
|
||||||
priv->rubberband_first = gtk_flow_box_find_child_at_pos (box, start_x, start_y);
|
priv->rubberband_first = gtk_flow_box_find_child_at_pos (box, start_x, start_y);
|
||||||
|
|
||||||
|
widget_node = gtk_widget_get_css_node (GTK_WIDGET (box));
|
||||||
|
priv->rubberband_node = gtk_css_node_new ();
|
||||||
|
gtk_css_node_set_name (priv->rubberband_node, I_("rubberband"));
|
||||||
|
gtk_css_node_set_parent (priv->rubberband_node, widget_node);
|
||||||
|
gtk_css_node_set_state (priv->rubberband_node, gtk_css_node_get_state (widget_node));
|
||||||
|
g_object_unref (priv->rubberband_node);
|
||||||
|
|
||||||
/* Grab focus here, so Escape-to-stop-rubberband works */
|
/* Grab focus here, so Escape-to-stop-rubberband works */
|
||||||
gtk_flow_box_update_cursor (box, priv->rubberband_first);
|
gtk_flow_box_update_cursor (box, priv->rubberband_first);
|
||||||
@ -3028,6 +3038,9 @@ gtk_flow_box_stop_rubberband (GtkFlowBox *box)
|
|||||||
priv->rubberband_first = NULL;
|
priv->rubberband_first = NULL;
|
||||||
priv->rubberband_last = NULL;
|
priv->rubberband_last = NULL;
|
||||||
|
|
||||||
|
gtk_css_node_set_parent (priv->rubberband_node, NULL);
|
||||||
|
priv->rubberband_node = NULL;
|
||||||
|
|
||||||
remove_autoscroll (box);
|
remove_autoscroll (box);
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (box));
|
gtk_widget_queue_draw (GTK_WIDGET (box));
|
||||||
|
Loading…
Reference in New Issue
Block a user