}
save_ardour_state (); /* XXX cannot fail? yeah, right ... */
- editor->save_canvas_state ();
return 0;
}
{
_stepping_axis_view = 0;
}
-
-
-void
-Editor::save_canvas_state ()
-{
- XMLTree* tree = static_cast<ArdourCanvas::Canvas*>(_track_canvas)->get_state ();
- string path = string_compose ("%1/canvas-state.xml", _session->path());
- tree->write (path);
-}
_stepping_axis_view = v;
}
- void save_canvas_state ();
-
ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
ArdourCanvas::Group* get_time_bars_group () const;
ArdourCanvas::Group* get_track_canvas_group () const;
virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
- virtual void save_canvas_state () = 0;
-
/// Singleton instance, set up by Editor::Editor()
static PublicEditor* _instance;
set_epoch ();
}
-/** Construct a new Canvas from an XML tree
- * @param tree XML Tree.
- */
-Canvas::Canvas (XMLTree const * tree)
- : _root (this)
- , _log_renders (true)
- , _scroll_offset_x (0)
- , _scroll_offset_y (0)
-{
- set_epoch ();
-
- /* XXX: little bit hacky */
- _root.set_state (tree->root()->child ("Group"));
-
- XMLNodeList const & children = tree->root()->children ();
- for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- if ((*i)->name() == ("Render")) {
- _renders.push_back (
- Rect (
- atof ((*i)->property ("x0")->value().c_str()),
- atof ((*i)->property ("y0")->value().c_str()),
- atof ((*i)->property ("x1")->value().c_str()),
- atof ((*i)->property ("x1")->value().c_str())
- )
- );
- }
- }
-}
-
void
Canvas::scroll_to (Coord x, Coord y)
{
request_redraw (canvas_area);
}
-/** @return An XML description of the canvas and its objects */
-XMLTree *
-Canvas::get_state () const
-{
- XMLTree* tree = new XMLTree ();
- XMLNode* node = new XMLNode ("Canvas");
- node->add_child_nocopy (*_root.get_state ());
-
- for (list<Rect>::const_iterator i = _renders.begin(); i != _renders.end(); ++i) {
- XMLNode* render = new XMLNode ("Render");
- render->add_property ("x0", string_compose ("%1", i->x0));
- render->add_property ("y0", string_compose ("%1", i->y0));
- render->add_property ("x1", string_compose ("%1", i->x1));
- render->add_property ("y1", string_compose ("%1", i->y1));
- node->add_child_nocopy (*render);
- }
-
- tree->set_root (node);
- return tree;
-}
-
/** Construct a GtkCanvas */
GtkCanvas::GtkCanvas ()
: _current_item (0)
add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK);
}
-/** Construct a GtkCanvas from an XML tree.
- * @param tree XML Tree.
- */
-GtkCanvas::GtkCanvas (XMLTree const * tree)
- : Canvas (tree)
- , _current_item (0)
- , _grabbed_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);
-}
-
/** Handler for button presses on the canvas.
* @param ev GDK event.
*/
#include "pbd/signals.h"
#include "canvas/root_group.h"
-class XMLTree;
-
namespace ArdourCanvas
{
{
public:
Canvas ();
- Canvas (XMLTree const *);
virtual ~Canvas () {}
/** called to request a redraw of an area of the canvas */
void item_changed (Item *, boost::optional<Rect>);
void item_moved (Item *, boost::optional<Rect>);
- XMLTree* get_state () const;
-
- virtual Cairo::RefPtr<Cairo::Context> context () = 0;
+ virtual Cairo::RefPtr<Cairo::Context> context () = 0;
std::list<Rect> const & renders () const {
return _renders;
{
public:
GtkCanvas ();
- GtkCanvas (XMLTree const *);
void request_redraw (Rect const &);
void request_size (Duple);
void compute_bounding_box () const;
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
void set (Points const &);
public:
Fill (Group *);
- void add_fill_state (XMLNode *) const;
- void set_fill_state (XMLNode const *);
-
Color fill_color () const {
return _fill_color;
}
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
virtual void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
void add (Item *);
void remove (Item *);
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
private:
Cairo::Format _format;
#include "canvas/types.h"
-class XMLNode;
-
namespace ArdourCanvas
{
/** Update _bounding_box and _bounding_box_dirty */
virtual void compute_bounding_box () const = 0;
- virtual XMLNode* get_state () const = 0;
- virtual void set_state (XMLNode const *) = 0;
-
void grab ();
void ungrab ();
- void add_item_state (XMLNode *) const;
- void set_item_state (XMLNode const *);
-
void unparent ();
void reparent (Group *);
+++ /dev/null
-namespace ArdourCanvas
-{
-
-class Item;
-class Group;
-
-Item* create_item (Group *, XMLNode const *);
-
-}
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
void set (Duple, Duple);
void set_x0 (Coord);
void compute_bounding_box () const;
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *) {}
void set_height (Distance);
Outline (Group *);
virtual ~Outline () {}
- void add_outline_state (XMLNode *) const;
- void set_outline_state (XMLNode const *);
-
Color outline_color () const {
return _outline_color;
}
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
void set (Glib::RefPtr<Gdk::Pixbuf>);
void compute_bounding_box () const;
- void add_poly_item_state (XMLNode *) const;
- void set_poly_item_state (XMLNode const *);
-
virtual void set (Points const &);
Points const & get () const;
PolyLine (Group *);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
};
}
Polygon (Group *);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
};
}
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
Rect const & get () const {
return _rect;
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
void set (std::string const &);
void set_color (uint32_t);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
- XMLNode* get_state () const;
- void set_state (XMLNode const *);
-
void set_samples_per_pixel (double);
void set_height (Distance);
void set_channel (int);
}
}
-XMLNode *
-Curve::get_state () const
-{
- XMLNode* node = new XMLNode ("PolyLine");
- add_poly_item_state (node);
- add_outline_state (node);
- return node;
-}
-
-void
-Curve::set_state (XMLNode const * node)
-{
- set_poly_item_state (node);
- set_outline_state (node);
-}
-
void
Curve::render_path (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
{
set_source_rgba (context, _fill_color);
}
-
-void
-Fill::add_fill_state (XMLNode* node) const
-{
- node->add_property ("fill-color", string_compose ("%1", _fill_color));
- node->add_property ("fill", _fill ? "yes" : "no");
-}
-
-void
-Fill::set_fill_state (XMLNode const * node)
-{
- _fill_color = atoll (node->property("fill-color")->value().c_str());
- _fill = PBD::string_is_affirmative (node->property("fill")->value ().c_str());
-
- _bounding_box_dirty = true;
-}
#include "canvas/group.h"
#include "canvas/types.h"
#include "canvas/debug.h"
-#include "canvas/item_factory.h"
#include "canvas/item.h"
#include "canvas/canvas.h"
}
}
-XMLNode *
-Group::get_state () const
-{
- XMLNode* node = new XMLNode ("Group");
- for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
- node->add_child_nocopy (*(*i)->get_state ());
- }
-
- add_item_state (node);
- return node;
-}
-
-void
-Group::set_state (XMLNode const * node)
-{
- set_item_state (node);
-
- XMLNodeList const & children = node->children ();
- for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- /* this will create the item and add it to this group */
- create_item (this, *i);
- }
-}
-
void
Group::dump (ostream& o) const
{
_need_render = true;
}
-XMLNode *
-Image::get_state () const
-{
- /* XXX */
- return new XMLNode ("Image");
-}
-
-void
-Image::set_state (XMLNode const * /*node*/)
-{
- /* XXX */
-}
set_position (position() + movement);
}
-void
-Item::add_item_state (XMLNode* node) const
-{
- node->add_property ("x-position", string_compose ("%1", _position.x));
- node->add_property ("y-position", string_compose ("%1", _position.y));
- node->add_property ("visible", _visible ? "yes" : "no");
-}
-
-void
-Item::set_item_state (XMLNode const * node)
-{
- _position.x = atof (node->property("x-position")->value().c_str());
- _position.y = atof (node->property("y-position")->value().c_str());
- _visible = PBD::string_is_affirmative (node->property("visible")->value());
-}
-
void
Item::grab ()
{
+++ /dev/null
-#include "pbd/xml++.h"
-#include "canvas/item_factory.h"
-#include "canvas/group.h"
-#include "canvas/line.h"
-#include "canvas/rectangle.h"
-#include "canvas/poly_line.h"
-#include "canvas/polygon.h"
-#include "canvas/pixbuf.h"
-#include "canvas/wave_view.h"
-#include "canvas/text.h"
-#include "canvas/line_set.h"
-
-using namespace std;
-using namespace ArdourCanvas;
-
-Item*
-ArdourCanvas::create_item (Group* parent, XMLNode const * node)
-{
- Item* item = 0;
- if (node->name() == "Group") {
- item = new Group (parent);
- } else if (node->name() == "Line") {
- item = new Line (parent);
- } else if (node->name() == "Rectangle") {
- item = new Rectangle (parent);
- } else if (node->name() == "PolyLine") {
- item = new PolyLine (parent);
- } else if (node->name() == "Polygon") {
- item = new Polygon (parent);
- } else if (node->name() == "Pixbuf") {
- item = new Pixbuf (parent);
- } else if (node->name() == "WaveView") {
- item = new WaveView (parent, boost::shared_ptr<ARDOUR::AudioRegion> ());
- } else if (node->name() == "Text") {
- item = new Text (parent);
- } else if (node->name() == "LineSet") {
- item = new LineSet (parent);
- }
-
- assert (item);
- item->set_state (node);
- return item;
-}
DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
}
-
-XMLNode *
-Line::get_state () const
-{
- XMLNode* node = new XMLNode ("Line");
-#ifdef CANVAS_DEBUG
- if (!name.empty ()) {
- node->add_property ("name", name);
- }
-#endif
- node->add_property ("x0", string_compose ("%1", _points[0].x));
- node->add_property ("y0", string_compose ("%1", _points[0].y));
- node->add_property ("x1", string_compose ("%1", _points[1].x));
- node->add_property ("y1", string_compose ("%1", _points[1].y));
-
- add_item_state (node);
- add_outline_state (node);
- return node;
-}
-
-void
-Line::set_state (XMLNode const * node)
-{
- _points[0].x = atof (node->property("x0")->value().c_str());
- _points[0].y = atof (node->property("y0")->value().c_str());
- _points[1].x = atof (node->property("x1")->value().c_str());
- _points[1].y = atof (node->property("y1")->value().c_str());
-
- set_item_state (node);
- set_outline_state (node);
-
- _bounding_box_dirty = true;
-}
}
-XMLNode *
-LineSet::get_state () const
-{
- /* XXX */
- return new XMLNode ("LineSet");
-}
void
LineSet::compute_bounding_box () const
context->set_line_width (_outline_width);
}
-void
-Outline::add_outline_state (XMLNode* node) const
-{
- node->add_property ("outline-color", string_compose ("%1", _outline_color));
- node->add_property ("outline", _outline ? "yes" : "no");
- node->add_property ("outline-width", string_compose ("%1", _outline_width));
-}
-
-void
-Outline::set_outline_state (XMLNode const * node)
-{
- _outline_color = atoll (node->property("outline-color")->value().c_str());
- _outline = PBD::string_is_affirmative (node->property("outline")->value().c_str());
- _outline_width = atof (node->property("outline-width")->value().c_str());
-
- _bounding_box_dirty = true;
-}
return _pixbuf;
}
-XMLNode *
-Pixbuf::get_state () const
-{
- /* XXX */
- return new XMLNode ("Pixbuf");
-}
-
-void
-Pixbuf::set_state (XMLNode const * /*node*/)
-{
- /* XXX */
-}
return _points;
}
-void
-PolyItem::add_poly_item_state (XMLNode* node) const
-{
- add_item_state (node);
-
- for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
- XMLNode* p = new XMLNode ("Point");
- p->add_property ("x", string_compose ("%1", i->x));
- p->add_property ("y", string_compose ("%1", i->y));
- node->add_child_nocopy (*p);
- }
-}
-
-void
-PolyItem::set_poly_item_state (XMLNode const * node)
-{
- XMLNodeList const & children = node->children ();
- for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- Duple p;
- p.x = atof ((*i)->property("x")->value().c_str());
- p.y = atof ((*i)->property("y")->value().c_str());
- _points.push_back (p);
- }
-
- _bounding_box_dirty = true;
-}
-
void
PolyItem::dump (ostream& o) const
{
context->stroke ();
}
}
-
-
-XMLNode *
-PolyLine::get_state () const
-{
- XMLNode* node = new XMLNode ("PolyLine");
- add_poly_item_state (node);
- add_outline_state (node);
- return node;
-}
-
-void
-PolyLine::set_state (XMLNode const * node)
-{
- set_poly_item_state (node);
- set_outline_state (node);
-}
}
}
-XMLNode *
-Polygon::get_state () const
-{
- XMLNode* node = new XMLNode ("Polygon");
-#ifdef CANVAS_DEBUG
- if (!name.empty ()) {
- node->add_property ("name", name);
- }
-#endif
- add_poly_item_state (node);
- add_outline_state (node);
- add_fill_state (node);
- return node;
-}
-
-
-void
-Polygon::set_state (XMLNode const * node)
-{
- set_poly_item_state (node);
- set_outline_state (node);
- set_fill_state (node);
-}
set_outline_what ((What) what);
}
-XMLNode *
-Rectangle::get_state () const
-{
- XMLNode* node = new XMLNode ("Rectangle");
-#ifdef CANVAS_DEBUG
- if (!name.empty ()) {
- node->add_property ("name", name);
- }
-#endif
- node->add_property ("x0", string_compose ("%1", _rect.x0));
- node->add_property ("y0", string_compose ("%1", _rect.y0));
- node->add_property ("x1", string_compose ("%1", _rect.x1));
- node->add_property ("y1", string_compose ("%1", _rect.y1));
- node->add_property ("outline-what", string_compose ("%1", _outline_what));
-
- add_item_state (node);
- add_outline_state (node);
- add_fill_state (node);
- return node;
-}
-
-void
-Rectangle::set_state (XMLNode const * node)
-{
- _rect.x0 = atof (node->property("x0")->value().c_str());
- _rect.y0 = atof (node->property("y0")->value().c_str());
- _rect.x1 = atof (node->property("x1")->value().c_str());
- _rect.y1 = atof (node->property("y1")->value().c_str());
- _outline_what = (What) atoi (node->property("outline-what")->value().c_str());
-
- set_item_state (node);
- set_outline_state (node);
- set_fill_state (node);
-
- _bounding_box_dirty = true;
-}
context->fill ();
}
-XMLNode *
-Text::get_state () const
-{
- XMLNode* node = new XMLNode ("Text");
-#ifdef CANVAS_DEBUG
- if (!name.empty ()) {
- node->add_property ("name", name);
- }
-#endif
- return node;
-}
-
-void
-Text::set_state (XMLNode const * /*node*/)
-{
- /* XXX */
-}
-
void
Text::set_alignment (Pango::Alignment alignment)
{
_bounding_box_dirty = false;
}
-XMLNode *
-WaveView::get_state () const
-{
- /* XXX */
- return new XMLNode ("WaveView");
-}
-
-void
-WaveView::set_state (XMLNode const * /*node*/)
-{
- /* XXX */
-}
-
void
WaveView::set_height (Distance height)
{
'flag.cc',
'group.cc',
'image.cc',
- 'item_factory.cc',
'line.cc',
'line_set.cc',
'lookup_table.cc',