_tip="Align objects to bottoms"
pixtype="stock" pixname="gl_stock_align_bottom"/>
+ <cmd name="ToolsCenterHorizontal"
+ _tip="Center objects to horizontal label center"
+ pixtype="stock" pixname="gl_stock_center_horiz"/>
+
+ <cmd name="ToolsCenterVertical"
+ _tip="Center objects to vertical label center"
+ pixtype="stock" pixname="gl_stock_center_vert"/>
+
<cmd name="HelpContents" _label="Contents" _tip="Open the glabels manual"
accel="F1" pixtype="stock" pixname="gtk-help"/>
</submenu>
<submenu name="AlignHoriz" _label="Align _Horizontal">
- <menuitem name="ToolsAlignLeft" verb="" _label="_Left"/>
- <menuitem name="ToolsAlignHCenter" verb="" _label="_Center"/>
- <menuitem name="ToolsAlignRight" verb="" _label="_Right"/>
+ <menuitem name="ToolsAlignLeft" verb="" _label="_Lefts"/>
+ <menuitem name="ToolsAlignHCenter" verb="" _label="_Centers"/>
+ <menuitem name="ToolsAlignRight" verb="" _label="_Rights"/>
+ <menuitem name="ToolsCenterHorizontal" verb="" _label="Label Ce_nter"/>
</submenu>
<submenu name="AlignVert" _label="Align _Vertical">
- <menuitem name="ToolsAlignTop" verb="" _label="_Top"/>
- <menuitem name="ToolsAlignVCenter" verb="" _label="_Center"/>
- <menuitem name="ToolsAlignBottom" verb="" _label="_Bottom"/>
+ <menuitem name="ToolsAlignTop" verb="" _label="_Tops"/>
+ <menuitem name="ToolsAlignVCenter" verb="" _label="_Centers"/>
+ <menuitem name="ToolsAlignBottom" verb="" _label="_Bottoms"/>
+ <menuitem name="ToolsCenterVertical" verb="" _label="Label Ce_nter"/>
</submenu>
<separator/>
}
}
+/*****************************************************************************/
+/* Center objects horizontally callback. */
+/*****************************************************************************/
+void
+gl_tools_center_objects_horiz (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname)
+
+{
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_center_selection_horiz (GL_VIEW(window->view));
+ }
+}
+
+/*****************************************************************************/
+/* Center objects vertically callback. */
+/*****************************************************************************/
+void
+gl_tools_center_objects_vert (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname)
+
+{
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_center_selection_vert (GL_VIEW(window->view));
+ }
+}
+
gpointer user_data,
const gchar *verbname);
+void gl_tools_center_objects_horiz (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
+void gl_tools_center_objects_vert (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
G_END_DECLS
#endif
BONOBO_UI_VERB ("ToolsAlignTop", gl_tools_align_objects_top),
BONOBO_UI_VERB ("ToolsAlignBottom", gl_tools_align_objects_bottom),
BONOBO_UI_VERB ("ToolsAlignVCenter", gl_tools_align_objects_vcenter),
+ BONOBO_UI_VERB ("ToolsCenterHorizontal", gl_tools_center_objects_horiz),
+ BONOBO_UI_VERB ("ToolsCenterVertical", gl_tools_center_objects_vert),
BONOBO_UI_VERB ("SettingsPreferences", gl_cmd_settings_preferences),
BONOBO_UI_VERB ("HelpContents", gl_cmd_help_contents),
BONOBO_UI_VERB ("About", gl_cmd_help_about),
"/commands/ToolsAlignTop",
"/commands/ToolsAlignBottom",
"/commands/ToolsAlignVCenter",
+ "/commands/ToolsCenterHorizontal",
+ "/commands/ToolsCenterVertical",
"/menu/Objects/CreateObjects",
"/menu/Objects/Order",
"/menu/Objects/RotateFlip",
"/commands/ToolsRotateRight",
"/commands/ToolsFlipHorizontal",
"/commands/ToolsFlipVertical",
+ "/commands/ToolsCenterHorizontal",
+ "/commands/ToolsCenterVertical",
"/menu/Objects/Order",
"/menu/Objects/RotateFlip",
+ "/menu/Objects/AlignHoriz",
+ "/menu/Objects/AlignVert",
NULL
};
"/commands/ToolsAlignTop",
"/commands/ToolsAlignBottom",
"/commands/ToolsAlignVCenter",
- "/menu/Objects/AlignHoriz",
- "/menu/Objects/AlignVert",
NULL
};
gl_debug (DEBUG_VIEW, "END");
}
+/*****************************************************************************/
+/* Center selected objects to in center of label. */
+/*****************************************************************************/
+void
+gl_view_center_selection_horiz (glView *view)
+{
+ GList *p;
+ glViewObject *view_object;
+ glLabelObject *object;
+ gdouble dx, x_label_center, x_obj_center, x1, y1, x2, y2, w, h;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (GL_IS_VIEW (view));
+
+ g_return_if_fail (!gl_view_is_selection_empty (view));
+
+ gl_label_get_size (view->label, &w, &h);
+ x_label_center = w / 2.0;
+
+ /* adjust the object positions */
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+ view_object = GL_VIEW_OBJECT (p->data);
+ object = gl_view_object_get_object (view_object);
+ gl_label_object_get_extent (object, &x1, &y1, &x2, &y2);
+ x_obj_center = (x1 + x2) / 2.0;
+ dx = x_label_center - x_obj_center;
+ gl_label_object_set_position_relative (object, dx, 0.0);
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/*****************************************************************************/
+/* Center selected objects to in center of label. */
+/*****************************************************************************/
+void
+gl_view_center_selection_vert (glView *view)
+{
+ GList *p;
+ glViewObject *view_object;
+ glLabelObject *object;
+ gdouble dy, y_label_center, y_obj_center, x1, y1, x2, y2, w, h;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (GL_IS_VIEW (view));
+
+ g_return_if_fail (!gl_view_is_selection_empty (view));
+
+ gl_label_get_size (view->label, &w, &h);
+ y_label_center = h / 2.0;
+
+ /* adjust the object positions */
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+ view_object = GL_VIEW_OBJECT (p->data);
+ object = gl_view_object_get_object (view_object);
+ gl_label_object_get_extent (object, &x1, &y1, &x2, &y2);
+ y_obj_center = (y1 + y2) / 2.0;
+ dy = y_label_center - y_obj_center;
+ gl_label_object_set_position_relative (object, 0.0, dy);
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
/*****************************************************************************/
/* "Cut" selected items and place in clipboard selections. */
/*****************************************************************************/
void gl_view_align_selection_vcenter (glView *view);
+void gl_view_center_selection_horiz (glView *view);
+
+void gl_view_center_selection_vert (glView *view);
+
void gl_view_cut (glView *view);
void gl_view_copy (glView *view);