derive ArdourCanvas::Ruler from Rectangle
This commit is contained in:
parent
0762708d83
commit
87a6f633a1
@ -24,14 +24,12 @@
|
||||
|
||||
#include <pangomm/fontdescription.h>
|
||||
|
||||
#include "canvas/item.h"
|
||||
#include "canvas/fill.h"
|
||||
#include "canvas/outline.h"
|
||||
#include "canvas/rectangle.h"
|
||||
|
||||
namespace ArdourCanvas
|
||||
{
|
||||
|
||||
class LIBCANVAS_API Ruler : virtual public Item, public Fill, public Outline
|
||||
class LIBCANVAS_API Ruler : public Rectangle
|
||||
{
|
||||
public:
|
||||
struct Mark {
|
||||
@ -58,17 +56,15 @@ public:
|
||||
};
|
||||
|
||||
Ruler (Group *, const Metric& m);
|
||||
Ruler (Group *, const Metric& m, Rect const&);
|
||||
|
||||
void set_range (double lower, double upper);
|
||||
void set_size (Rect const&);
|
||||
void set_font_description (Pango::FontDescription);
|
||||
|
||||
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
||||
void compute_bounding_box () const;
|
||||
|
||||
private:
|
||||
const Metric& _metric;
|
||||
Rect _rect;
|
||||
|
||||
/* lower and upper and sample positions, which are also canvas coordinates
|
||||
*/
|
||||
|
@ -33,8 +33,17 @@ using namespace ArdourCanvas;
|
||||
|
||||
Ruler::Ruler (Group *p, const Metric& m)
|
||||
: Item (p)
|
||||
, Fill (p)
|
||||
, Outline (p)
|
||||
, Rectangle (p)
|
||||
, _metric (m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
||||
Ruler::Ruler (Group *p, const Metric& m, Rect const& r)
|
||||
: Item (p)
|
||||
, Rectangle (p, r)
|
||||
, _metric (m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
@ -60,27 +69,6 @@ Ruler::set_font_description (Pango::FontDescription fd)
|
||||
end_visual_change ();
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::set_size (Rect const & area)
|
||||
{
|
||||
if (_rect != area) {
|
||||
begin_visual_change ();
|
||||
_rect = area;
|
||||
_bounding_box_dirty = true;
|
||||
end_visual_change ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::compute_bounding_box () const
|
||||
{
|
||||
if (!_rect.empty()) {
|
||||
_bounding_box = _rect;
|
||||
}
|
||||
|
||||
_bounding_box_dirty = false;
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||
{
|
||||
@ -89,7 +77,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||
return;
|
||||
}
|
||||
|
||||
Rect self (item_to_window (_rect));
|
||||
Rect self (item_to_window (get()));
|
||||
boost::optional<Rect> i = self.intersection (area);
|
||||
|
||||
if (!i) {
|
||||
@ -118,8 +106,14 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||
|
||||
/* draw line on lower edge as a separator */
|
||||
|
||||
if (_outline_width == 1.0) {
|
||||
/* Cairo single pixel line correction */
|
||||
cr->move_to (self.x0, self.y1-0.5);
|
||||
cr->line_to (self.x1, self.y1-0.5);
|
||||
} else {
|
||||
cr->move_to (self.x0, self.y1);
|
||||
cr->line_to (self.x1, self.y1);
|
||||
}
|
||||
cr->stroke ();
|
||||
|
||||
/* draw ticks + text */
|
||||
@ -136,6 +130,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||
pos.y = self.y1; /* bottom edge */
|
||||
|
||||
if (_outline_width == 1.0) {
|
||||
/* Cairo single pixel line correction */
|
||||
cr->move_to (pos.x + 0.5, pos.y);
|
||||
} else {
|
||||
cr->move_to (pos.x, pos.y);
|
||||
|
Loading…
Reference in New Issue
Block a user