diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index bd7b780800..ceaa366c35 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -46,18 +46,6 @@ Canvas::Canvas () set_epoch (); } -Canvas::Canvas (const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : _root (this) - , _scroll_offset_x (0) - , _scroll_offset_y (0) -{ - set_epoch (); - const XMLNodeList& children = definition.children(); - for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { - XMLUI::create_item (root(), **i, styles, named_items); - } -} - void Canvas::scroll_to (Coord x, Coord y) { @@ -293,19 +281,6 @@ GtkCanvas::GtkCanvas () Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); } -GtkCanvas::GtkCanvas (const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Canvas(definition, styles, named_items) - , _current_item (0) - , _new_current_item (0) - , _grabbed_item (0) - , _focused_item (0) -{ - /* these are the events we want to know about */ - add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | - Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); -} - - void GtkCanvas::pick_current_item (int state) { @@ -780,11 +755,8 @@ GtkCanvas::request_size (Duple size) if (req.y > INT_MAX) { req.y = INT_MAX; } - int applied_width; - int applied_height; - get_size_request(applied_width, applied_height); - set_size_request (applied_width == -1 ? req.x : applied_width, - applied_height == -1 ? req.y : applied_height ); + + set_size_request (req.x, req.y); } /** `Grab' an item, so that all events are sent to that item until it is `ungrabbed'. diff --git a/libs/canvas/canvas/canvas.h b/libs/canvas/canvas/canvas.h index d9260d73cf..b15c2f4d54 100644 --- a/libs/canvas/canvas/canvas.h +++ b/libs/canvas/canvas/canvas.h @@ -38,11 +38,9 @@ #include "canvas/root_group.h" -#include "canvas/xml_ui.h" - namespace ArdourCanvas { -using namespace XMLUI; + class Rect; class Group; @@ -60,7 +58,6 @@ class LIBCANVAS_API Canvas { public: Canvas (); - Canvas (const XMLNode&, const XMLNodeMap&, std::map&); virtual ~Canvas () {} /** called to request a redraw of an area of the canvas */ @@ -137,7 +134,6 @@ class LIBCANVAS_API GtkCanvas : public Canvas, public Gtk::EventBox { public: GtkCanvas (); - GtkCanvas (const XMLNode&, const XMLNodeMap&, std::map&); void request_redraw (Rect const &); void request_size (Duple); diff --git a/libs/canvas/canvas/fill.h b/libs/canvas/canvas/fill.h index 3e083ed366..56044de4bd 100644 --- a/libs/canvas/canvas/fill.h +++ b/libs/canvas/canvas/fill.h @@ -27,13 +27,11 @@ #include "canvas/item.h" namespace ArdourCanvas { -using namespace XMLUI; class LIBCANVAS_API Fill : virtual public Item { public: Fill (Group *); - Fill (Group *, const XMLNode&, const XMLNodeMap&, std::map&); virtual void set_fill_color (Color); virtual void set_fill (bool); diff --git a/libs/canvas/canvas/group.h b/libs/canvas/canvas/group.h index 11873edc46..94aabfded6 100644 --- a/libs/canvas/canvas/group.h +++ b/libs/canvas/canvas/group.h @@ -28,17 +28,13 @@ #include "canvas/types.h" #include "canvas/lookup_table.h" -#include "canvas/xml_ui.h" - namespace ArdourCanvas { -using namespace XMLUI; class LIBCANVAS_API Group : public Item { public: explicit Group (Group *); explicit Group (Group *, Duple); - explicit Group (Group *, const XMLNode&, const XMLNodeMap&, std::map&); ~Group (); void render (Rect const &, Cairo::RefPtr) const; diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index 445d3c5448..d7d4ba7254 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -30,11 +30,9 @@ #include "canvas/visibility.h" #include "canvas/types.h" -#include "canvas/xml_ui.h" namespace ArdourCanvas { -using namespace XMLUI; class Canvas; class Group; @@ -50,13 +48,12 @@ class Rect; * Any item that is being displayed on a canvas has a pointer to that canvas, * and all except the `root group' have a pointer to their parent group. */ - + class LIBCANVAS_API Item { public: Item (Canvas *); Item (Group *); - Item (Group *, const XMLNode&, const XMLNodeMap&, std::map&); Item (Group *, Duple); virtual ~Item (); diff --git a/libs/canvas/canvas/outline.h b/libs/canvas/canvas/outline.h index c75d635141..972c07b11c 100644 --- a/libs/canvas/canvas/outline.h +++ b/libs/canvas/canvas/outline.h @@ -32,7 +32,6 @@ class LIBCANVAS_API Outline : virtual public Item { public: Outline (Group *); - Outline (Group *, const XMLNode&, const XMLNodeMap&, std::map&); virtual ~Outline () {} Color outline_color () const { diff --git a/libs/canvas/canvas/pixbuf.h b/libs/canvas/canvas/pixbuf.h index 43c3ad790c..3974b560a9 100644 --- a/libs/canvas/canvas/pixbuf.h +++ b/libs/canvas/canvas/pixbuf.h @@ -24,20 +24,17 @@ #include "canvas/visibility.h" #include "canvas/item.h" -#include "canvas/xml_ui.h" namespace Gdk { class Pixbuf; } namespace ArdourCanvas { -using namespace XMLUI; class LIBCANVAS_API Pixbuf : public Item { public: Pixbuf (Group *); - Pixbuf (Group *, const XMLNode&, const XMLNodeMap&, std::map&); void render (Rect const &, Cairo::RefPtr) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/rectangle.h b/libs/canvas/canvas/rectangle.h index 2ab703a36f..91f23f9336 100644 --- a/libs/canvas/canvas/rectangle.h +++ b/libs/canvas/canvas/rectangle.h @@ -33,7 +33,6 @@ class LIBCANVAS_API Rectangle : virtual public Item, public Outline, public Fill { public: Rectangle (Group *); - Rectangle (Group *, const XMLNode&, const XMLNodeMap&, std::map&); Rectangle (Group *, Rect const &); void render (Rect const &, Cairo::RefPtr) const; diff --git a/libs/canvas/canvas/text.h b/libs/canvas/canvas/text.h index 7543477e97..59d2007ceb 100644 --- a/libs/canvas/canvas/text.h +++ b/libs/canvas/canvas/text.h @@ -27,14 +27,12 @@ #include "canvas/item.h" namespace ArdourCanvas { -using namespace XMLUI; class LIBCANVAS_API Text : public Item { public: Text (Group *); - Text (Group *, const XMLNode&, const XMLNodeMap&, std::map&); - ~Text(); + ~Text(); void render (Rect const &, Cairo::RefPtr) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h index f176a4f6d5..2800ccc91b 100644 --- a/libs/canvas/canvas/types.h +++ b/libs/canvas/canvas/types.h @@ -85,13 +85,6 @@ struct LIBCANVAS_API Rect , y1 (y1_) {} - Rect (const Duple& p0, const Duple &p1) - : x0 (p0.x) - , y0 (p0.y) - , x1 (p1.x) - , y1 (p1.y) - {} - Coord x0; Coord y0; Coord x1; diff --git a/libs/canvas/canvas/xml_ui.h b/libs/canvas/canvas/xml_ui.h index 0b73b98efa..d0d1f33375 100644 --- a/libs/canvas/canvas/xml_ui.h +++ b/libs/canvas/canvas/xml_ui.h @@ -59,8 +59,10 @@ namespace XMLUI { extern LIBCANVAS_API double xml_y (const XMLNode& node, const XMLNodeMap& styles, double default_value = 0); extern LIBCANVAS_API Pango::Alignment xml_text_alignment (const XMLNode& node, const XMLNodeMap& styles, Pango::Alignment default_value = Pango::ALIGN_LEFT); +#ifdef ARDOUR_CANVAS_HAS_XML_UI extern LIBCANVAS_API ArdourCanvas::Item* create_item (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map &named_items); +#endif } } -#endif //__CANVAS_XML_UI_H__ \ No newline at end of file +#endif //__CANVAS_XML_UI_H__ diff --git a/libs/canvas/fill.cc b/libs/canvas/fill.cc index e803d68d4c..41c616a0f9 100644 --- a/libs/canvas/fill.cc +++ b/libs/canvas/fill.cc @@ -37,15 +37,6 @@ Fill::Fill (Group* parent) } -Fill::Fill (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (parent, definition, styles, named_items) - , _fill_color (xml_property(definition, "fillcolor", styles, 0x000000ff)) - , _fill (xml_property(definition, "fill", styles, true)) - , _transparent (xml_property(definition, "transparent", styles, false)) -{ - -} - void Fill::set_fill_color (Color color) { diff --git a/libs/canvas/group.cc b/libs/canvas/group.cc index 8f29aea633..fbe252a17c 100644 --- a/libs/canvas/group.cc +++ b/libs/canvas/group.cc @@ -56,16 +56,6 @@ Group::Group (Group* parent, Duple position) } -Group::Group (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (parent, definition, styles, named_items) - , _lut (0) -{ - const XMLNodeList& children = definition.children(); - for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { - XMLUI::create_item (this, **i, styles, named_items); - } -} - Group::~Group () { clear_items (true); diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index e91cb1b6f8..674daa4275 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -42,39 +42,14 @@ Item::Item (Canvas* canvas) Item::Item (Group* parent) : _canvas (parent->canvas ()) , _parent (parent) - , _visible (true) - , _bounding_box_dirty (true) - , _ignore_events (false) { init (); } -Item::Item (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : _canvas (parent->canvas ()) - , _parent (parent) - , _position(xml_x (definition, styles), - xml_y (definition, styles)) - , _visible (xml_property(definition, "visible", styles, true)) - , _bounding_box_dirty (true) - , _ignore_events (false) -{ - std::string item_id = xml_id (definition); - if (!item_id.empty()) { - named_items[item_id] = this; - } - - _position = Duple (xml_x (definition, styles), - xml_y (definition, styles)); - init (); -} - Item::Item (Group* parent, Duple position) : _canvas (parent->canvas()) , _parent (parent) , _position (position) - , _visible (true) - , _bounding_box_dirty (true) - , _ignore_events (false) { init (); } @@ -82,6 +57,9 @@ Item::Item (Group* parent, Duple position) void Item::init () { + _visible = true; + _bounding_box_dirty = true; + _ignore_events = false; if (_parent) { _parent->add (this); diff --git a/libs/canvas/outline.cc b/libs/canvas/outline.cc index 6b24601107..be8b924df2 100644 --- a/libs/canvas/outline.cc +++ b/libs/canvas/outline.cc @@ -38,16 +38,6 @@ Outline::Outline (Group* parent) } -Outline::Outline (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (parent, definition, styles, named_items) - , _outline_color (xml_property(definition, "linecolor", styles, 0x000000ff)) - , _outline_width (xml_property(definition, "linewidth", styles, 1.0)) - , _outline (xml_property(definition, "contour", styles, true)) -{ - -} - - void Outline::set_outline_color (Color color) { diff --git a/libs/canvas/pixbuf.cc b/libs/canvas/pixbuf.cc index cc92994739..62d9357c61 100644 --- a/libs/canvas/pixbuf.cc +++ b/libs/canvas/pixbuf.cc @@ -16,23 +16,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -//#include "gtkmm/messagedialog.h" #include #include #include "canvas/pixbuf.h" -#include "pbd/error.h" -#include "pbd/compose.h" -#include "pbd/search_path.h" -#include "pbd/file_utils.h" -#include "ardour/filesystem_paths.h" using namespace std; using namespace ArdourCanvas; -using namespace PBD; - -//#define dbg_msg(a) Gtk::MessageDialog (a, "ArdourCanvas::Pixbuf").run(); Pixbuf::Pixbuf (Group* g) : Item (g) @@ -40,48 +31,10 @@ Pixbuf::Pixbuf (Group* g) } -Pixbuf::Pixbuf (Group* g, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (g, definition, styles, named_items) -{ - std::string imagename = xml_property(definition, "file", styles, ""); - if (!imagename.empty()) - { - Searchpath spath(ARDOUR::ardour_data_search_path()); - - std::string dirname = Glib::path_get_dirname (imagename); - std::string filename = Glib::path_get_basename (imagename); - if (!dirname.empty()) { - spath.add_subdirectory_to_paths(dirname); - } - - std::string data_file_path; - - if (find_file_in_search_path (spath, filename, data_file_path)) { - try { - _pixbuf = Gdk::Pixbuf::create_from_file (data_file_path); - } catch (const Gdk::PixbufError &e) { - cerr << "Caught PixbufError: " << e.what() << endl; - } catch (...) { - cerr << string_compose ("Caught exception while loading icon named %1", imagename) << endmsg; - } - } - } -} - void -Pixbuf::render (Rect const & area, Cairo::RefPtr context) const +Pixbuf::render (Rect const & /*area*/, Cairo::RefPtr context) const { - Rect self = item_to_window (Rect (position(), position().translate (Duple (_pixbuf->get_width(), _pixbuf->get_height())))); - boost::optional r = self.intersection (area); - - if (!r) { - return; - } - - Rect draw = r.get (); - - context->rectangle (draw.x0, draw.y0, draw.width(), draw.height()); - Gdk::Cairo::set_source_pixbuf (context, _pixbuf, draw.x0, draw.y0); + Gdk::Cairo::set_source_pixbuf (context, _pixbuf, 0, 0); context->paint (); } diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index aaa442f083..57c26874c4 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -38,18 +38,6 @@ Rectangle::Rectangle (Group* parent) { } -Rectangle::Rectangle (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (parent, definition, styles, named_items) - , Outline (parent, definition, styles, named_items) - , Fill (parent, definition, styles, named_items) - , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) -{ - //_rect.x0 = xml_property(definition, "x", styles, 0.0); - //_rect.y0 = xml_property(definition, "y", styles, 0.0); - _rect.x1 = _rect.x0 + xml_property(definition, "width", styles, 0.0); - _rect.y1 = _rect.y0 + xml_property(definition, "height", styles, 0.0); -} - Rectangle::Rectangle (Group* parent, Rect const & rect) : Item (parent) , Outline (parent) diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc index 0dd5c9ad96..438413080a 100644 --- a/libs/canvas/text.cc +++ b/libs/canvas/text.cc @@ -44,20 +44,6 @@ Text::Text (Group* parent) } -Text::Text (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) - : Item (parent, definition, styles, named_items) - , _color (xml_property(definition, "color", styles, 0x000000ff)) - , _font_description ((xml_property(definition, "font", styles, "") == "") ? 0 : - new Pango::FontDescription (xml_property(definition, "font", styles, ""))) - , _alignment (xml_text_alignment(definition, styles, Pango::ALIGN_LEFT)) - , _width (xml_property(definition, "width", styles, 0.0)) - , _height (xml_property(definition, "heigt", styles, 0.0)) - , _text (xml_property(definition, "text", styles, "")) - , _need_redraw (false) - , _clamped_width (COORD_MAX) -{ -} - Text::~Text () { delete _font_description; diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index e6f0fda71e..fa2c617d7b 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -335,8 +335,8 @@ WaveView::draw_image (PeakData* _peaks, int n_peaks) const /* ensure single-pixel lines */ - context->set_line_width (1.1); //VK: 0.5); - context->translate (1.1, 0.0); //VK: (0.5, 0.0); + context->set_line_width (0.5); + context->translate (0.5, 0.0); /* draw the lines */ diff --git a/libs/canvas/wscript b/libs/canvas/wscript index 6c0a469a86..4f91094997 100644 --- a/libs/canvas/wscript +++ b/libs/canvas/wscript @@ -55,8 +55,8 @@ canvas_sources = [ 'types.cc', 'utils.cc', 'wave_view.cc', - 'xml_ui.cc', 'xfade_curve.cc', + 'xml_ui.cc', ] def options(opt): @@ -66,7 +66,7 @@ def configure(conf): conf.load ('compiler_cxx') autowaf.configure(conf) autowaf.build_version_files(path_prefix+'canvas/version.h', path_prefix+'version.cc', - 'libcanvas', conf.env['MAJOR'], conf.env['MINOR'], conf.env['MICRO'], + 'libcanvas', conf.env['MAJOR'], conf.env['MINOR'], 0, 'LIBCANVAS_API', 'canvas/visibility.h') autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4') @@ -89,7 +89,7 @@ def build(bld): obj.vnum = CANVAS_LIB_VERSION obj.install_path = bld.env['LIBDIR'] obj.defines += [ 'PACKAGE="' + I18N_PACKAGE + '"' ] - + if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']: manual_tests = ''' diff --git a/libs/canvas/xml_ui.cc b/libs/canvas/xml_ui.cc index 799ee3c15d..ef71b2f241 100644 --- a/libs/canvas/xml_ui.cc +++ b/libs/canvas/xml_ui.cc @@ -227,6 +227,7 @@ Pango::Alignment xml_text_alignment (const XMLNode& node, const XMLNodeMap& styl return default_value; } +#ifdef ARDOUR_CANVAS_HAS_XML_UI ArdourCanvas::Item* create_item (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, std::map& named_items) { @@ -257,7 +258,7 @@ create_item (Group* parent, const XMLNode& definition, const XMLNodeMap& styles, return child; } - +#endif } }