From Glom
< Development‎ | Plans
Revision as of 15:48, 23 November 2010 by Isijujemiru (Talk | contribs)

Jump to: navigation, search

This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page


Glom drag-and-drop layout editing


The goal is to add a pallete of layout items (fields, portals, buttons, etc) and allow them to be dragged onto the layout, showing visual feedback as they are moved around, before being dropped.

Implementation proposal

Currently a dialog exists for editing layout details (Dialog_Layout_Details), which is invoked by Box_Data_Details. Layouts consist of multiple LayoutItems, which are contained by a FlowTableWithFields. FlowTable instances emit on_flowtable_layout_changed() signals (inherited from LayoutWidgetBase), which should be handled by methods of classes that contain a FlowTable, such as Box_Data_Details. Also, FlowTableWithFields has methods for adding layout items. In addition to (or instead of) a static layout editing dialog, a "floating" window as a palette of layout items, like in common GUI designer such as Glade, can be added. It can be activated by a simple button click, when in Developer mode. It can contain buttons with images to differentiate types of items.

Visual feedback can be provided by setting different icons, to be displayed while dragging an item, to appropriate pallette buttons, via drag_source_set_icon(). There could be a new class to differentiate this button from a "regular" GTK+ button, PalleteButton. Additional visual feedback, if needed, could be arranged by handling drag_motion and drag_leave signals. The received x and y coordinates can then be used to draw a preview of a new item that would be added (rectangle-shaped contours), in an on_drag_motion signal handler. Between PalleteButtons and FlowTables a compatible Gtk::TargetEntry needs to be set (what type exactly: Gtk::Widget, string, LayoutWidgetBase::enumType? - probably the last one). FlowTable (or FlowTableWithFields) should then also implement a drag_data_received signal handler where it would add the new item, and rearrange existing if necessary. User might decide to drop an item anywhere, which includes area already occupied by another item, so based on its' position and the passed coordinates a FlowTable should calculate where exactly can a new item's starting position be. Perhaps adding utility functions to retrieve the closest layout item to specified coordinates would be helpful here.

For a start a simple window containing a FlowTable with different widgets (like in can be created and another one to act as a very simple palette of one or two layout items (eg a text field and a button). The first window would accept items from the pallete (automatically rearrange items in the container, grow the window if necessary and display dropped items, with verbose g_debug() messages). From that point the same drag and drop principle can be expanded to work with Glom's data details windows.

This proposal was originally posted as a Google Summer of Code application by Marko Anastasov.


Most of this is now implemented in trunk but a lot of issues remain. Tracking them here to not forget about them.


  • Investigate why database does not work with newly created layouts