mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
menu: Implement snapshot() for the menu code
This commit is contained in:
parent
e492a63e4c
commit
65e9894450
@ -84,13 +84,13 @@ enum {
|
||||
PROP_DRAW_AS_RADIO
|
||||
};
|
||||
|
||||
static gint gtk_check_menu_item_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_check_menu_item_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_check_menu_item_activate (GtkMenuItem *menu_item);
|
||||
static void gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||
gint *requisition);
|
||||
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
||||
cairo_t *cr);
|
||||
static void gtk_real_check_menu_item_snapshot_indicator (GtkCheckMenuItem *check_menu_item,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_check_menu_item_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
@ -213,14 +213,14 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
widget_class->draw = gtk_check_menu_item_draw;
|
||||
widget_class->snapshot = gtk_check_menu_item_snapshot;
|
||||
|
||||
menu_item_class->activate = gtk_check_menu_item_activate;
|
||||
menu_item_class->hide_on_activate = FALSE;
|
||||
menu_item_class->toggle_size_request = gtk_check_menu_item_toggle_size_request;
|
||||
|
||||
klass->toggled = NULL;
|
||||
klass->draw_indicator = gtk_real_check_menu_item_draw_indicator;
|
||||
klass->snapshot_indicator = gtk_real_check_menu_item_snapshot_indicator;
|
||||
|
||||
/**
|
||||
* GtkCheckMenuItem::toggled:
|
||||
@ -501,19 +501,17 @@ gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
|
||||
update_node_state (check_menu_item);
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_check_menu_item_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_check_menu_item_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw)
|
||||
GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw (widget, cr);
|
||||
if (GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->snapshot)
|
||||
GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator)
|
||||
GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator (check_menu_item, cr);
|
||||
|
||||
return FALSE;
|
||||
if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->snapshot_indicator)
|
||||
GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->snapshot_indicator (check_menu_item, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -581,10 +579,10 @@ gtk_check_menu_item_direction_changed (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
||||
cairo_t *cr)
|
||||
gtk_real_check_menu_item_snapshot_indicator (GtkCheckMenuItem *check_menu_item,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
gtk_css_gadget_draw (check_menu_item->priv->indicator_gadget, cr);
|
||||
gtk_css_gadget_snapshot (check_menu_item->priv->indicator_gadget, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -67,9 +67,9 @@ struct _GtkCheckMenuItemClass
|
||||
|
||||
/*< public >*/
|
||||
|
||||
void (* toggled) (GtkCheckMenuItem *check_menu_item);
|
||||
void (* draw_indicator) (GtkCheckMenuItem *check_menu_item,
|
||||
cairo_t *cr);
|
||||
void (* toggled) (GtkCheckMenuItem *check_menu_item);
|
||||
void (* snapshot_indicator) (GtkCheckMenuItem *check_menu_item,
|
||||
GtkSnapshot *snapshot);
|
||||
|
||||
/*< private >*/
|
||||
|
||||
|
@ -234,8 +234,8 @@ static void gtk_menu_unrealize (GtkWidget *widget);
|
||||
static void gtk_menu_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_menu_show (GtkWidget *widget);
|
||||
static gboolean gtk_menu_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_menu_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static gboolean gtk_menu_key_press (GtkWidget *widget,
|
||||
GdkEventKey *event);
|
||||
static gboolean gtk_menu_scroll (GtkWidget *widget,
|
||||
@ -515,7 +515,7 @@ gtk_menu_class_init (GtkMenuClass *class)
|
||||
widget_class->unrealize = gtk_menu_unrealize;
|
||||
widget_class->size_allocate = gtk_menu_size_allocate;
|
||||
widget_class->show = gtk_menu_show;
|
||||
widget_class->draw = gtk_menu_draw;
|
||||
widget_class->snapshot = gtk_menu_snapshot;
|
||||
widget_class->scroll_event = gtk_menu_scroll;
|
||||
widget_class->key_press_event = gtk_menu_key_press;
|
||||
widget_class->motion_notify_event = gtk_menu_motion_notify;
|
||||
@ -2931,9 +2931,9 @@ gtk_menu_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_menu_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_menu_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkMenu *menu;
|
||||
GtkMenuPrivate *priv;
|
||||
@ -2947,28 +2947,30 @@ gtk_menu_draw (GtkWidget *widget,
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
gtk_render_background (context, cr, 0, 0,
|
||||
allocation.width, allocation.height);
|
||||
gtk_render_frame (context, cr, 0, 0,
|
||||
allocation.width, allocation.height);
|
||||
gtk_snapshot_render_background (snapshot, context, 0, 0,
|
||||
allocation.width, allocation.height);
|
||||
gtk_snapshot_render_frame (snapshot, context, 0, 0,
|
||||
allocation.width, allocation.height);
|
||||
|
||||
if (priv->upper_arrow_visible)
|
||||
gtk_css_gadget_draw (priv->top_arrow_gadget, cr);
|
||||
gtk_css_gadget_snapshot (priv->top_arrow_gadget, snapshot);
|
||||
|
||||
if (priv->lower_arrow_visible)
|
||||
gtk_css_gadget_draw (priv->bottom_arrow_gadget, cr);
|
||||
gtk_css_gadget_snapshot (priv->bottom_arrow_gadget, snapshot);
|
||||
|
||||
gdk_window_get_position (priv->view_window, &x, &y);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
x - allocation.x, y - allocation.y,
|
||||
gdk_window_get_width (priv->view_window),
|
||||
gdk_window_get_height (priv->view_window));
|
||||
cairo_clip (cr);
|
||||
gtk_snapshot_push_clip (snapshot,
|
||||
&GRAPHENE_RECT_INIT(
|
||||
x - allocation.x, y - allocation.y,
|
||||
gdk_window_get_width (priv->view_window),
|
||||
gdk_window_get_height (priv->view_window)
|
||||
),
|
||||
"MenuClip");
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_menu_parent_class)->draw (widget, cr);
|
||||
GTK_WIDGET_CLASS (gtk_menu_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
return FALSE;
|
||||
gtk_snapshot_pop_and_append (snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -94,8 +94,8 @@ static void gtk_menu_bar_measure_ (GtkWidget *widget,
|
||||
int *natural_baseline);
|
||||
static void gtk_menu_bar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static gint gtk_menu_bar_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_menu_bar_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *old_toplevel);
|
||||
static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
|
||||
@ -116,7 +116,7 @@ static void gtk_menu_bar_allocate (GtkCssGadget *gadget,
|
||||
GtkAllocation *out_clip,
|
||||
gpointer data);
|
||||
static gboolean gtk_menu_bar_render (GtkCssGadget *gadget,
|
||||
cairo_t *cr,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
@ -144,7 +144,7 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
|
||||
|
||||
widget_class->measure = gtk_menu_bar_measure_;
|
||||
widget_class->size_allocate = gtk_menu_bar_size_allocate;
|
||||
widget_class->draw = gtk_menu_bar_draw;
|
||||
widget_class->snapshot = gtk_menu_bar_snapshot;
|
||||
widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
|
||||
|
||||
menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
|
||||
@ -246,8 +246,8 @@ gtk_menu_bar_init (GtkMenuBar *menu_bar)
|
||||
widget,
|
||||
gtk_menu_bar_measure,
|
||||
gtk_menu_bar_allocate,
|
||||
gtk_menu_bar_render,
|
||||
NULL,
|
||||
gtk_menu_bar_render,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
|
||||
|
||||
static gboolean
|
||||
gtk_menu_bar_render (GtkCssGadget *gadget,
|
||||
cairo_t *cr,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
@ -582,18 +582,16 @@ gtk_menu_bar_render (GtkCssGadget *gadget,
|
||||
{
|
||||
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->draw (widget, cr);
|
||||
GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_menu_bar_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_menu_bar_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
gtk_css_gadget_draw (GTK_MENU_BAR (widget)->priv->gadget, cr);
|
||||
|
||||
return FALSE;
|
||||
gtk_css_gadget_snapshot (GTK_MENU_BAR (widget)->priv->gadget, snapshot);
|
||||
}
|
||||
|
||||
static GList *
|
||||
|
@ -254,7 +254,7 @@ gtk_menu_item_actionable_interface_init (GtkActionableInterface *iface)
|
||||
|
||||
static gboolean
|
||||
gtk_menu_item_render (GtkCssGadget *gadget,
|
||||
cairo_t *cr,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
@ -269,20 +269,18 @@ gtk_menu_item_render (GtkCssGadget *gadget,
|
||||
parent = gtk_widget_get_parent (widget);
|
||||
|
||||
if (priv->submenu && !GTK_IS_MENU_BAR (parent))
|
||||
gtk_css_gadget_draw (priv->arrow_gadget, cr);
|
||||
gtk_css_gadget_snapshot (priv->arrow_gadget, snapshot);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->draw (widget, cr);
|
||||
GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_menu_item_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
static void
|
||||
gtk_menu_item_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
gtk_css_gadget_draw (GTK_MENU_ITEM (widget)->priv->gadget, cr);
|
||||
|
||||
return FALSE;
|
||||
gtk_css_gadget_snapshot (GTK_MENU_ITEM (widget)->priv->gadget, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -590,7 +588,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
|
||||
|
||||
widget_class->destroy = gtk_menu_item_destroy;
|
||||
widget_class->size_allocate = gtk_menu_item_size_allocate;
|
||||
widget_class->draw = gtk_menu_item_draw;
|
||||
widget_class->snapshot = gtk_menu_item_snapshot;
|
||||
widget_class->realize = gtk_menu_item_realize;
|
||||
widget_class->unrealize = gtk_menu_item_unrealize;
|
||||
widget_class->map = gtk_menu_item_map;
|
||||
@ -783,8 +781,8 @@ gtk_menu_item_init (GtkMenuItem *menu_item)
|
||||
GTK_WIDGET (menu_item),
|
||||
gtk_menu_item_measure,
|
||||
gtk_menu_item_allocate,
|
||||
gtk_menu_item_render,
|
||||
NULL,
|
||||
gtk_menu_item_render,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -68,14 +68,14 @@ gtk_model_menu_item_activate (GtkMenuItem *item)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_menu_item_draw_indicator (GtkCheckMenuItem *check_item,
|
||||
cairo_t *cr)
|
||||
gtk_model_menu_item_snapshot_indicator (GtkCheckMenuItem *check_item,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkModelMenuItem *item = GTK_MODEL_MENU_ITEM (check_item);
|
||||
|
||||
if (item->has_indicator)
|
||||
GTK_CHECK_MENU_ITEM_CLASS (gtk_model_menu_item_parent_class)
|
||||
->draw_indicator (check_item, cr);
|
||||
->snapshot_indicator (check_item, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -474,7 +474,7 @@ gtk_model_menu_item_class_init (GtkModelMenuItemClass *class)
|
||||
GtkMenuItemClass *item_class = GTK_MENU_ITEM_CLASS (class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
check_class->draw_indicator = gtk_model_menu_item_draw_indicator;
|
||||
check_class->snapshot_indicator = gtk_model_menu_item_snapshot_indicator;
|
||||
|
||||
item_class->toggle_size_request = gtk_model_menu_item_toggle_size_request;
|
||||
item_class->activate = gtk_model_menu_item_activate;
|
||||
|
Loading…
Reference in New Issue
Block a user