2008-12-23 16:05:50 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2008 Paul Davis
|
|
|
|
Author: Dave Robillard
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ardour_interactive_item_h__
|
|
|
|
#define __ardour_interactive_item_h__
|
|
|
|
|
2008-12-23 20:24:49 -05:00
|
|
|
#include <libgnomecanvasmm/text.h>
|
|
|
|
#include "simplerect.h"
|
|
|
|
|
2008-12-23 16:05:50 -05:00
|
|
|
namespace Gnome {
|
|
|
|
namespace Canvas {
|
|
|
|
|
|
|
|
|
|
|
|
/** A canvas item that handles events.
|
|
|
|
* This is required so ardour can custom deliver events to specific items
|
|
|
|
* (e.g. to delineate scroll events) since Gnome::Canvas::Item::on_event
|
|
|
|
* is protected.
|
|
|
|
*/
|
|
|
|
class InteractiveItem {
|
|
|
|
public:
|
|
|
|
virtual bool on_event(GdkEvent* ev) = 0;
|
|
|
|
};
|
|
|
|
|
2008-12-23 20:24:49 -05:00
|
|
|
/** A canvas text that forwards events to its parent.
|
|
|
|
*/
|
|
|
|
class InteractiveText : public Text, public InteractiveItem {
|
|
|
|
public:
|
2008-12-24 05:52:19 -05:00
|
|
|
InteractiveText(Group& parent, InteractiveItem* parent_item, double x, double y, const Glib::ustring& text)
|
2008-12-23 20:24:49 -05:00
|
|
|
: Text(parent, x, y, text)
|
2008-12-24 05:52:19 -05:00
|
|
|
, _parent_item(parent_item)
|
|
|
|
{}
|
2008-12-23 20:24:49 -05:00
|
|
|
|
2008-12-24 05:52:19 -05:00
|
|
|
InteractiveText(Group& parent, InteractiveItem* parent_item)
|
|
|
|
: Text(parent)
|
|
|
|
, _parent_item(parent_item)
|
|
|
|
{}
|
2008-12-23 20:24:49 -05:00
|
|
|
|
|
|
|
bool on_event(GdkEvent* ev) {
|
2008-12-24 05:52:19 -05:00
|
|
|
if(_parent_item) {
|
|
|
|
return _parent_item->on_event(ev);
|
2008-12-23 20:24:49 -05:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-12-24 05:52:19 -05:00
|
|
|
|
2008-12-23 20:24:49 -05:00
|
|
|
protected:
|
2008-12-24 05:52:19 -05:00
|
|
|
InteractiveItem* _parent_item;
|
2008-12-23 20:24:49 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class InteractiveRect: public SimpleRect, public InteractiveItem
|
|
|
|
{
|
|
|
|
public:
|
2009-05-04 20:08:30 -04:00
|
|
|
InteractiveRect(Group& parent, InteractiveItem* parent_item,
|
|
|
|
double x1, double y1, double x2, double y2)
|
2008-12-24 05:52:19 -05:00
|
|
|
: SimpleRect(parent, x1, y1, x2, y2)
|
|
|
|
, _parent_item(parent_item)
|
2009-05-04 20:08:30 -04:00
|
|
|
{}
|
2008-12-23 20:24:49 -05:00
|
|
|
|
|
|
|
bool on_event(GdkEvent* ev) {
|
2009-05-04 20:08:30 -04:00
|
|
|
if (_parent_item) {
|
2008-12-24 05:52:19 -05:00
|
|
|
return _parent_item->on_event(ev);
|
2008-12-23 20:24:49 -05:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-24 05:52:19 -05:00
|
|
|
|
2008-12-23 20:24:49 -05:00
|
|
|
protected:
|
2008-12-24 05:52:19 -05:00
|
|
|
InteractiveItem* _parent_item;
|
2008-12-23 20:24:49 -05:00
|
|
|
};
|
2008-12-23 16:05:50 -05:00
|
|
|
|
|
|
|
} /* namespace Canvas */
|
|
|
|
} /* namespace Gnome */
|
|
|
|
|
|
|
|
#endif /* __ardour_interactive_item_h__ */
|