static void clutter_flow_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) { ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv; ClutterLayoutManagerClass *parent_class; priv->container = container; if (priv->container != NULL) { ClutterRequestMode request_mode; /* we need to change the :request-mode of the container * to match the orientation */ request_mode = (priv->orientation == CLUTTER_FLOW_HORIZONTAL) ? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH : CLUTTER_REQUEST_WIDTH_FOR_HEIGHT; clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container), request_mode); } parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_flow_layout_parent_class); parent_class->set_container (manager, container); }
/* Re-layout and allocate children of container we manage */ static void _xfdashboard_box_layout_allocate(ClutterLayoutManager *inLayoutManager, ClutterContainer *inContainer, const ClutterActorBox *inAllocation, ClutterAllocationFlags inFlags) { ClutterTextDirection textDirection; ClutterActor *child; ClutterActorIter iter; ClutterActorBox childBox; gfloat containerWidth; g_return_if_fail(XFDASHBOARD_IS_BOX_LAYOUT(inLayoutManager)); g_return_if_fail(CLUTTER_IS_CONTAINER(inContainer)); /* Chain up to calculate and store the allocation of children */ CLUTTER_LAYOUT_MANAGER_CLASS(xfdashboard_box_layout_parent_class)->allocate(inLayoutManager, inContainer, inAllocation, inFlags); /* Right-to-left text direction only affects horizontal orientation. * If orientation is not horizontal or text direction is not right-to-left * then there is nothing to do. */ if(clutter_box_layout_get_orientation(CLUTTER_BOX_LAYOUT(inLayoutManager))!=CLUTTER_ORIENTATION_HORIZONTAL) { return; } textDirection=clutter_actor_get_text_direction(CLUTTER_ACTOR(inContainer)); if(textDirection==CLUTTER_TEXT_DIRECTION_DEFAULT) textDirection=clutter_get_default_text_direction(); if(textDirection!=CLUTTER_TEXT_DIRECTION_RTL) { return; } /* Iterate through children and recalculate x-coordination of each * children allocation by "mirroring" x-coordinate. */ containerWidth=clutter_actor_box_get_width(inAllocation); clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inContainer)); while(clutter_actor_iter_next(&iter, &child)) { gfloat x1, x2; /* Get position and size of child */ clutter_actor_get_allocation_box(child, &childBox); /* Set new allocation of child */ x1=containerWidth-childBox.x2; x2=containerWidth-childBox.x1; childBox.x1=x1; childBox.x2=x2; clutter_actor_allocate(child, &childBox, inFlags); } }
/* Class initialization * Override functions in parent classes and define properties * and signals */ static void xfdashboard_box_layout_class_init(XfdashboardBoxLayoutClass *klass) { ClutterLayoutManagerClass *layoutClass=CLUTTER_LAYOUT_MANAGER_CLASS(klass); /* Override functions */ layoutClass->allocate=_xfdashboard_box_layout_allocate; }
static void clutter_bin_layout_class_init (ClutterBinLayoutClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterLayoutManagerClass *layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); g_type_class_add_private (klass, sizeof (ClutterBinLayoutPrivate)); /** * ClutterBinLayout:x-align: * * The default horizontal alignment policy for actors managed * by the #ClutterBinLayout * * Since: 1.2 * * Deprecated: 1.12: Use the #ClutterActor:x-expand and the * #ClutterActor:x-align properties on #ClutterActor instead. */ bin_props[PROP_X_ALIGN] = g_param_spec_enum ("x-align", P_("Horizontal Alignment"), P_("Default horizontal alignment for the actors " "inside the layout manager"), CLUTTER_TYPE_BIN_ALIGNMENT, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_PARAM_READWRITE); /** * ClutterBinLayout:y-align: * * The default vertical alignment policy for actors managed * by the #ClutterBinLayout * * Since: 1.2 * * Deprecated: 1.12: Use the #ClutterActor:y-expand and the * #ClutterActor:y-align properties on #ClutterActor instead. */ bin_props[PROP_Y_ALIGN] = g_param_spec_enum ("y-align", P_("Vertical Alignment"), P_("Default vertical alignment for the actors " "inside the layout manager"), CLUTTER_TYPE_BIN_ALIGNMENT, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_PARAM_READWRITE); gobject_class->set_property = clutter_bin_layout_set_property; gobject_class->get_property = clutter_bin_layout_get_property; g_object_class_install_properties (gobject_class, PROP_LAST, bin_props); layout_class->get_preferred_width = clutter_bin_layout_get_preferred_width; layout_class->get_preferred_height = clutter_bin_layout_get_preferred_height; layout_class->allocate = clutter_bin_layout_allocate; layout_class->create_child_meta = clutter_bin_layout_create_child_meta; layout_class->get_child_meta_type = clutter_bin_layout_get_child_meta_type; layout_class->set_container = clutter_bin_layout_set_container; }
static void clutter_fixed_layout_class_init (ClutterFixedLayoutClass *klass) { ClutterLayoutManagerClass *manager_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); manager_class->get_preferred_width = clutter_fixed_layout_get_preferred_width; manager_class->get_preferred_height = clutter_fixed_layout_get_preferred_height; manager_class->allocate = clutter_fixed_layout_allocate; }
static void clutter_table_layout_class_init (ClutterTableLayoutClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterLayoutManagerClass *layout_class; GParamSpec *pspec; layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); gobject_class->set_property = clutter_table_layout_set_property; gobject_class->get_property = clutter_table_layout_get_property; gobject_class->finalize = clutter_table_layout_finalize; layout_class->get_preferred_width = clutter_table_layout_get_preferred_width; layout_class->get_preferred_height = clutter_table_layout_get_preferred_height; layout_class->allocate = clutter_table_layout_allocate; layout_class->set_container = clutter_table_layout_set_container; layout_class->get_child_meta_type = clutter_table_layout_get_child_meta_type; g_type_class_add_private (klass, sizeof (ClutterTableLayoutPrivate)); /** * ClutterTableLayout:column-spacing: * * The spacing between columns of the #ClutterTableLayout, in pixels * * */ pspec = g_param_spec_uint ("column-spacing", P_("Column Spacing"), P_("Spacing between columns"), 0, G_MAXUINT, 0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_COLUMN_SPACING, pspec); /** * ClutterTableLayout:row-spacing: * * The spacing between rows of the #ClutterTableLayout, in pixels * * */ pspec = g_param_spec_uint ("row-spacing", P_("Row Spacing"), P_("Spacing between rows"), 0, G_MAXUINT, 0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_ROW_SPACING, pspec); }
static void clutter_bin_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) { ClutterBinLayoutPrivate *priv; ClutterLayoutManagerClass *parent_class; priv = CLUTTER_BIN_LAYOUT (manager)->priv; priv->container = container; parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_bin_layout_parent_class); parent_class->set_container (manager, container); }
/* Class initialization * Override functions in parent classes and define properties * and signals */ static void xfdashboard_fill_box_layout_class_init(XfdashboardFillBoxLayoutClass *klass) { ClutterLayoutManagerClass *layoutClass=CLUTTER_LAYOUT_MANAGER_CLASS(klass); GObjectClass *gobjectClass=G_OBJECT_CLASS(klass); /* Override functions */ layoutClass->get_preferred_width=_xfdashboard_fill_box_layout_get_preferred_width; layoutClass->get_preferred_height=_xfdashboard_fill_box_layout_get_preferred_height; layoutClass->allocate=_xfdashboard_fill_box_layout_allocate; gobjectClass->set_property=_xfdashboard_fill_box_layout_set_property; gobjectClass->get_property=_xfdashboard_fill_box_layout_get_property; /* Set up private structure */ g_type_class_add_private(klass, sizeof(XfdashboardFillBoxLayoutPrivate)); /* Define properties */ XfdashboardFillBoxLayoutProperties[PROP_ORIENTATION]= g_param_spec_enum("orientation", _("Orientation"), _("The orientation to layout children"), CLUTTER_TYPE_ORIENTATION, CLUTTER_ORIENTATION_HORIZONTAL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardFillBoxLayoutProperties[PROP_SPACING]= g_param_spec_float("spacing", _("spacing"), _("The spacing between children"), 0.0f, G_MAXFLOAT, 0.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardFillBoxLayoutProperties[PROP_HOMOGENEOUS]= g_param_spec_boolean("homogeneous", _("Homogeneous"), _("Whether the layout should be homogeneous, i.e. all children get the same size"), FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); XfdashboardFillBoxLayoutProperties[PROP_KEEP_ASPECT]= g_param_spec_boolean("keep-aspect", _("Keep aspect"), _("Whether all children should keep their aspect"), FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardFillBoxLayoutProperties); }
static void clutter_flow_layout_class_init (ClutterFlowLayoutClass *klass) { GObjectClass *gobject_class; ClutterLayoutManagerClass *layout_class; gobject_class = G_OBJECT_CLASS (klass); layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); layout_class->get_preferred_width = clutter_flow_layout_get_preferred_width; layout_class->get_preferred_height = clutter_flow_layout_get_preferred_height; layout_class->allocate = clutter_flow_layout_allocate; layout_class->set_container = clutter_flow_layout_set_container; /** * ClutterFlowLayout:orientation: * * The orientation of the #ClutterFlowLayout. The children * of the layout will be layed out following the orientation. * * This property also controls the overflowing directions * * Since: 1.2 */ flow_properties[PROP_ORIENTATION] = g_param_spec_enum ("orientation", P_("Orientation"), P_("The orientation of the layout"), CLUTTER_TYPE_FLOW_ORIENTATION, CLUTTER_FLOW_HORIZONTAL, CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); /** * ClutterFlowLayout:homogeneous: * * Whether each child inside the #ClutterFlowLayout should receive * the same allocation * * Since: 1.2 */ flow_properties[PROP_HOMOGENEOUS] = g_param_spec_boolean ("homogeneous", P_("Homogeneous"), P_("Whether each item should receive the same allocation"), FALSE, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:column-spacing: * * The spacing between columns, in pixels; the value of this * property is honoured by horizontal non-overflowing layouts * and by vertical overflowing layouts * * Since: 1.2 */ flow_properties[PROP_COLUMN_SPACING] = g_param_spec_float ("column-spacing", P_("Column Spacing"), P_("The spacing between columns"), 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:row-spacing: * * The spacing between rows, in pixels; the value of this * property is honoured by vertical non-overflowing layouts and * by horizontal overflowing layouts * * Since: 1.2 */ flow_properties[PROP_ROW_SPACING] = g_param_spec_float ("row-spacing", P_("Row Spacing"), P_("The spacing between rows"), 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:min-column-width: * * Minimum width for each column in the layout, in pixels * * Since: 1.2 */ flow_properties[PROP_MIN_COLUMN_WIDTH] = g_param_spec_float ("min-column-width", P_("Minimum Column Width"), P_("Minimum width for each column"), 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:max-column-width: * * Maximum width for each column in the layout, in pixels. If * set to -1 the width will be the maximum child width * * Since: 1.2 */ flow_properties[PROP_MAX_COLUMN_WIDTH] = g_param_spec_float ("max-column-width", P_("Maximum Column Width"), P_("Maximum width for each column"), -1.0, G_MAXFLOAT, -1.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:min-row-height: * * Minimum height for each row in the layout, in pixels * * Since: 1.2 */ flow_properties[PROP_MIN_ROW_HEGHT] = g_param_spec_float ("min-row-height", P_("Minimum Row Height"), P_("Minimum height for each row"), 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:max-row-height: * * Maximum height for each row in the layout, in pixels. If * set to -1 the width will be the maximum child height * * Since: 1.2 */ flow_properties[PROP_MAX_ROW_HEIGHT] = g_param_spec_float ("max-row-height", P_("Maximum Row Height"), P_("Maximum height for each row"), -1.0, G_MAXFLOAT, -1.0, CLUTTER_PARAM_READWRITE); /** * ClutterFlowLayout:snap-to-grid: * * Whether the #ClutterFlowLayout should arrange its children * on a grid * * Since: 1.16 */ flow_properties[PROP_SNAP_TO_GRID] = g_param_spec_boolean ("snap-to-grid", P_("Snap to grid"), P_("Snap to grid"), TRUE, CLUTTER_PARAM_READWRITE); gobject_class->finalize = clutter_flow_layout_finalize; gobject_class->set_property = clutter_flow_layout_set_property; gobject_class->get_property = clutter_flow_layout_get_property; g_object_class_install_properties (gobject_class, N_PROPERTIES, flow_properties); }
/* Class initialization * Override functions in parent classes and define properties * and signals */ static void xfdashboard_scaled_table_layout_class_init(XfdashboardScaledTableLayoutClass *klass) { ClutterLayoutManagerClass *layoutClass=CLUTTER_LAYOUT_MANAGER_CLASS(klass); GObjectClass *gobjectClass=G_OBJECT_CLASS(klass); /* Override functions */ layoutClass->get_preferred_width=_xfdashboard_scaled_table_layout_get_preferred_width; layoutClass->get_preferred_height=_xfdashboard_scaled_table_layout_get_preferred_height; layoutClass->allocate=_xfdashboard_scaled_table_layout_allocate; gobjectClass->set_property=_xfdashboard_scaled_table_layout_set_property; gobjectClass->get_property=_xfdashboard_scaled_table_layout_get_property; /* Set up private structure */ g_type_class_add_private(klass, sizeof(XfdashboardScaledTableLayoutPrivate)); /* Define properties */ XfdashboardScaledTableLayoutProperties[PROP_ROW_SPACING]= g_param_spec_float("row-spacing", _("Row spacing"), _("The spacing between rows in table"), 0.0f, G_MAXFLOAT, 0.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_COLUMN_SPACING]= g_param_spec_float("column-spacing", _("Column spacing"), _("The spacing between columns in table"), 0.0f, G_MAXFLOAT, 0.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_RELATIVE_SCALE]= g_param_spec_boolean("relative-scale", _("Relative scale"), _("Whether all children should be scaled relatively to largest child"), FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_PREVENT_UPSCALING]= g_param_spec_boolean("prevent-upscaling", _("Prevent upscaling"), _("Whether this layout manager should prevent upsclaing any child beyond its real size"), FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_NUMBER_CHILDREN]= g_param_spec_float("number-children", _("Number children"), _("Current number of child actors in this layout"), 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_ROWS]= g_param_spec_float("rows", _("Rows"), _("Current number of rows in this layout"), 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); XfdashboardScaledTableLayoutProperties[PROP_COLUMNS]= g_param_spec_float("columns", _("Columns"), _("Current number of columns in this layout"), 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardScaledTableLayoutProperties); }
static void clutter_flow_layout_class_init (ClutterFlowLayoutClass *klass) { GObjectClass *gobject_class; ClutterLayoutManagerClass *layout_class; GParamSpec *pspec; g_type_class_add_private (klass, sizeof (ClutterFlowLayoutPrivate)); gobject_class = G_OBJECT_CLASS (klass); layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); gobject_class->set_property = clutter_flow_layout_set_property; gobject_class->get_property = clutter_flow_layout_get_property; gobject_class->finalize = clutter_flow_layout_finalize; layout_class->get_preferred_width = clutter_flow_layout_get_preferred_width; layout_class->get_preferred_height = clutter_flow_layout_get_preferred_height; layout_class->allocate = clutter_flow_layout_allocate; layout_class->set_container = clutter_flow_layout_set_container; /** * ClutterFlowLayout:orientation: * * The orientation of the #ClutterFlowLayout. The children * of the layout will be layed out following the orientation. * * This property also controls the overflowing directions * * Since: 1.2 */ pspec = g_param_spec_enum ("orientation", "Orientation", "The orientation of the layout", CLUTTER_TYPE_FLOW_ORIENTATION, CLUTTER_FLOW_HORIZONTAL, CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property (gobject_class, PROP_ORIENTATION, pspec); /** * ClutterFlowLayout:homogeneous: * * Whether each child inside the #ClutterFlowLayout should receive * the same allocation * * Since: 1.2 */ pspec = g_param_spec_boolean ("homogeneous", "Homogeneous", "Whether each item should receive the " "same allocation", FALSE, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_HOMOGENEOUS, pspec); /** * ClutterFlowLayout:column-spacing: * * The spacing between columns, in pixels; the value of this * property is honoured by horizontal non-overflowing layouts * and by vertical overflowing layouts * * Since: 1.2 */ pspec = g_param_spec_float ("column-spacing", "Column Spacing", "The spacing between columns", 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_COLUMN_SPACING, pspec); /** * ClutterFlowLayout:row-spacing: * * The spacing between rows, in pixels; the value of this * property is honoured by vertical non-overflowing layouts and * by horizontal overflowing layouts * * Since: 1.2 */ pspec = g_param_spec_float ("row-spacing", "Row Spacing", "The spacing between rows", 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_ROW_SPACING, pspec); /** * ClutterFlowLayout:min-column-width: * * Minimum width for each column in the layout, in pixels * * Since: 1.2 */ pspec = g_param_spec_float ("min-column-width", "Minimum Column Width", "Minimum width for each column", 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_MIN_COLUMN_WIDTH, pspec); /** * ClutterFlowLayout:max-column-width: * * Maximum width for each column in the layout, in pixels. If * set to -1 the width will be the maximum child width * * Since: 1.2 */ pspec = g_param_spec_float ("max-column-width", "Maximum Column Width", "Maximum width for each column", -1.0, G_MAXFLOAT, -1.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_MAX_COLUMN_WIDTH, pspec); /** * ClutterFlowLayout:min-row-height: * * Minimum height for each row in the layout, in pixels * * Since: 1.2 */ pspec = g_param_spec_float ("min-row-height", "Minimum Row Height", "Minimum height for each row", 0.0, G_MAXFLOAT, 0.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_MIN_ROW_HEGHT, pspec); /** * ClutterFlowLayout:max-row-height: * * Maximum height for each row in the layout, in pixels. If * set to -1 the width will be the maximum child height * * Since: 1.2 */ pspec = g_param_spec_float ("max-row-height", "Maximum Row Height", "Maximum height for each row", -1.0, G_MAXFLOAT, -1.0, CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_MAX_ROW_HEIGHT, pspec); }