}
_children.clear ();
+ _active = 0;
}
void select_all ()
/** Look at a y coordinate and find the children below y, and the ones either side.
* @param y y position.
* @param before Filled in with the child before, or 0.
- * @param before Filled in with the child under y, or 0.
+ * @param at Filled in with the child under y, or 0.
* @param after Filled in with the child after, or 0.
- * @return Fractional position in terms of child height.
+ * @return Fractional position in terms of child height, or -1 if not over a child.
*/
double get_children_around_position (int y, T** before, T** at, T** after) const
{
return -1;
}
- /* fractional position in terms of children */
- double const nf = double (y) / _children.front()->widget().get_allocation().get_height ();
-
*before = 0;
- int i = 0;
typename std::list<T*>::const_iterator j = _children.begin ();
- while (i < int (nf) && j != _children.end()) {
+
+ /* index of current child */
+ int i = 0;
+ /* top of current child */
+ double top = 0;
+ /* bottom of current child */
+ double bottom = (*j)->widget().get_allocation().get_height ();
+
+ while (y >= bottom && j != _children.end()) {
+
+ top = bottom;
+
*before = *j;
++i;
++j;
+
+ if (j != _children.end()) {
+ bottom += (*j)->widget().get_allocation().get_height ();
+ }
}
if (j == _children.end()) {
++j;
*after = j != _children.end() ? *j : 0;
- return nf;
+ return i + ((y - top) / (*at)->widget().get_allocation().get_height());
}
/** @param y y coordinate.
return r;
}
+
+ void set_spacing (int s) {
+ _internal_vbox.set_spacing (s);
+ }
/** Children have been reordered by a drag */
sigc::signal<void> Reordered;
_drag_source = this;
}
- /* Draw the drag icon; we go to these lengths so that we can have the icon
- * transparent if the window system supports it.
- */
- bool icon_expose (GdkEventExpose *)
+ /* Draw the drag icon */
+ bool icon_expose (GdkEventExpose* ev)
{
- cairo_t* cr = gdk_cairo_create (_drag_icon->get_window()->gobj());
-
- if (_have_alpha) {
- cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 0.5);
- } else {
- cairo_set_source_rgba (cr, 0, 0, 0, 1);
- }
-
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
- cairo_set_source_rgba (cr, 1, 1, 1, 0.8);
+ /* Just grab the child's widget and use that */
- cairo_text_extents_t ext;
- cairo_text_extents (cr, _drag_child->drag_text().c_str(), &ext);
-
- cairo_move_to (cr, 0, ext.height);
- cairo_show_text (cr, _drag_child->drag_text().c_str ());
- cairo_restore (cr);
- cairo_destroy (cr);
+ int w, h;
+ _drag_icon->get_size (w, h);
+
+ cairo_t* cr = gdk_cairo_create (_drag_icon->get_window()->gobj ());
+ Glib::RefPtr<Gdk::Pixmap> p = _drag_child->widget().get_snapshot();
+ gdk_cairo_set_source_pixmap (cr, p->gobj(), 0, 0);
+ cairo_rectangle (cr, 0, 0, w, h);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+
return false;
}
-
void drag_data_get (Glib::RefPtr<Gdk::DragContext> const &, Gtk::SelectionData & selection_data, guint, guint, T* child)
{
selection_data.set (selection_data.get_target(), 8, (const guchar *) &child, sizeof (&child));