X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fcanvas-flag.h;h=95c2176e4094314a87020b424f18463a30f93226;hb=8b5f990267622100b3a1a7ff6fa346282aca4dda;hp=0f45667614831f2839d81bd6949e7bc9347948b5;hpb=f03a87a132feb525a743de675d0439e981ab329a;p=ardour.git diff --git a/gtk2_ardour/canvas-flag.h b/gtk2_ardour/canvas-flag.h index 0f45667614..95c2176e40 100644 --- a/gtk2_ardour/canvas-flag.h +++ b/gtk2_ardour/canvas-flag.h @@ -1,103 +1,70 @@ +/* + Copyright (C) 2012 Paul Davis + + 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 CANVASFLAG_H_ #define CANVASFLAG_H_ +#include +#include #include -#include #include -#include - #include "simplerect.h" #include "simpleline.h" +#include "canvas.h" class MidiRegionView; namespace Gnome { namespace Canvas { -class CanvasFlagRect; -class CanvasFlagText; - class CanvasFlag : public Group { public: - CanvasFlag( - MidiRegionView& region, - Group& parent, - double height, - guint outline_color_rgba = 0xc0c0c0ff, - guint fill_color_rgba = 0x07070707, - double x = 0.0, - double y = 0.0 - ) : Group(parent, x, y) - , _text(0) - , _height(height) - , _outline_color_rgba(outline_color_rgba) - , _fill_color_rgba(fill_color_rgba) - , _region(region) - , _line(0) - , _rect(0) - {} - + CanvasFlag (MidiRegionView& region, + Group& parent, + double height, + guint outline_color_rgba = 0xc0c0c0ff, + guint fill_color_rgba = 0x07070707, + double x = 0.0, + double y = 0.0); + virtual ~CanvasFlag(); - - virtual bool on_event(GdkEvent* ev); - void set_text(string& a_text); + virtual void set_text(const std::string& a_text); + virtual void set_height (double); -protected: - CanvasFlagText* _text; - double _height; - guint _outline_color_rgba; - guint _fill_color_rgba; - -private: - void delete_allocated_objects(); - - MidiRegionView& _region; - SimpleLine* _line; - CanvasFlagRect* _rect; -}; + int width () const { return name_pixbuf_width + 10.0; } -class CanvasFlagText: public Text -{ -public: - CanvasFlagText(Group& parent, double x, double y, const Glib::ustring& text) - : Text(parent, x, y, text) { - _parent = dynamic_cast(&parent); -; - } - - virtual bool on_event(GdkEvent* ev) { - if(_parent) { - return _parent->on_event(ev); - } else { - return false; - } - } +protected: + ArdourCanvas::Pixbuf* _name_pixbuf; + double _height; + guint _outline_color_rgba; + guint _fill_color_rgba; + MidiRegionView& _region; + int name_pixbuf_width; private: - CanvasFlag* _parent; -}; - -class CanvasFlagRect: public SimpleRect -{ -public: - CanvasFlagRect(Group& parent, double x1, double y1, double x2, double y2) - : SimpleRect(parent, x1, y1, x2, y2) { - _parent = dynamic_cast(&parent); - } - - virtual bool on_event(GdkEvent* ev) { - if(_parent) { - return _parent->on_event(ev); - } else { - return false; - } - } + void delete_allocated_objects(); -private: - CanvasFlag* _parent; + SimpleLine* _line; + SimpleRect* _rect; };