canvas: manually remove changes from 6f91dc0799 and implement same goal in a different way
The AudioClipEditor features a scroll bar that is a part of the canvas. Because scroll groups are at the top level of a canvas, the scroll bar is necessary within a scroll group, which causes it to get confused about the difference between its own position within the canvas and that of the scroll group. This commit introduces a per-Item flag, _scroll_translation, which is true by default. If false, the item will not have coordinates translated to reflect scroll group position.
This commit is contained in:
@@ -299,7 +299,6 @@ Canvas::window_to_canvas (Duple const & d) const
|
||||
{
|
||||
ScrollGroup* best_group = 0;
|
||||
ScrollGroup* sg = 0;
|
||||
bool grabbed_item_inside = false;
|
||||
|
||||
/* if the coordinates are negative, clamp to zero and find the item
|
||||
* that covers that "edge" position.
|
||||
@@ -333,8 +332,6 @@ Canvas::window_to_canvas (Duple const & d) const
|
||||
|
||||
best_group = sg;
|
||||
|
||||
grabbed_item_inside = check_grabbed_item_inside (sg);
|
||||
|
||||
if (sg->sensitivity() == (ScrollGroup::ScrollsVertically | ScrollGroup::ScrollsHorizontally)) {
|
||||
/* Can't do any better than this. */
|
||||
break;
|
||||
@@ -343,7 +340,7 @@ Canvas::window_to_canvas (Duple const & d) const
|
||||
}
|
||||
}
|
||||
|
||||
if (best_group && (!have_grab() || grabbed_item_inside)) {
|
||||
if (best_group && (!have_grab() || grab_can_translate ())) {
|
||||
return d.translate (best_group->scroll_offset());
|
||||
}
|
||||
|
||||
@@ -1518,13 +1515,14 @@ GtkCanvas::resize_handler ()
|
||||
}
|
||||
|
||||
bool
|
||||
GtkCanvas::check_grabbed_item_inside (Item* possible_parent) const
|
||||
GtkCanvas::grab_can_translate () const
|
||||
{
|
||||
if (!_grabbed_item) {
|
||||
return false;
|
||||
/* weird, but correct! */
|
||||
return true;
|
||||
}
|
||||
|
||||
return _grabbed_item->is_descendant_of (*possible_parent);
|
||||
return _grabbed_item->scroll_translation ();
|
||||
}
|
||||
|
||||
/** Create a GtkCanvaSViewport.
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
virtual void unfocus (Item*) = 0;
|
||||
|
||||
virtual bool have_grab() const { return false; }
|
||||
virtual bool check_grabbed_item_inside (Item*) const { return false; }
|
||||
virtual bool grab_can_translate () const { return true; }
|
||||
|
||||
void render (Rect const &, Cairo::RefPtr<Cairo::Context> const &) const;
|
||||
|
||||
@@ -218,7 +218,7 @@ public:
|
||||
void unfocus (Item*);
|
||||
|
||||
bool have_grab() const { return _grabbed_item; }
|
||||
bool check_grabbed_item_inside (Item*) const;
|
||||
bool grab_can_translate () const;
|
||||
|
||||
Rect visible_area () const;
|
||||
Coord width() const;
|
||||
|
||||
@@ -285,6 +285,9 @@ public:
|
||||
bool resize_queued() const { return _resize_queued; }
|
||||
void queue_resize();
|
||||
|
||||
bool scroll_translation() const { return _scroll_translation; }
|
||||
void disable_scroll_translation ();
|
||||
|
||||
/* only derived containers need to implement this, but this
|
||||
is where they compute the sizes and position and their
|
||||
children. A fixed-layout container (i.e. one where every child
|
||||
@@ -369,7 +372,8 @@ private:
|
||||
|
||||
std::string _tooltip;
|
||||
bool _ignore_events;
|
||||
|
||||
bool _scroll_translation;
|
||||
|
||||
void find_scroll_parent ();
|
||||
void propagate_show_hide ();
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ Item::Item (Canvas* canvas)
|
||||
, _requested_width (-1)
|
||||
, _requested_height (-1)
|
||||
, _ignore_events (false)
|
||||
, _scroll_translation (true)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
|
||||
}
|
||||
@@ -68,6 +69,7 @@ Item::Item (Item* parent)
|
||||
, _requested_width (-1)
|
||||
, _requested_height (-1)
|
||||
, _ignore_events (false)
|
||||
, _scroll_translation (true)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
|
||||
|
||||
@@ -1342,3 +1344,9 @@ Item::set_pack_options (PackOptions po)
|
||||
/* must be called before adding/packing Item in a Container */
|
||||
_pack_options = po;
|
||||
}
|
||||
|
||||
void
|
||||
Item::disable_scroll_translation ()
|
||||
{
|
||||
_scroll_translation = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user