summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorHans Baier <hansfbaier@googlemail.com>2008-04-21 16:42:55 +0000
committerHans Baier <hansfbaier@googlemail.com>2008-04-21 16:42:55 +0000
commit7afccaa9fe6601c5809d61e637683a107063310b (patch)
tree942f7275505e1a0285446610b2d15f1bb3d225df /gtk2_ardour
parentc72bf18bf472e665a51a8383b00eb21b40805d39 (diff)
* fixed display bug: changing the height on tracks doesnt rescale CanvasHits
git-svn-id: svn://localhost/ardour2/branches/3.0@3278 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/diamond.cc8
-rw-r--r--gtk2_ardour/diamond.h2
-rw-r--r--gtk2_ardour/midi_region_view.cc54
3 files changed, 44 insertions, 20 deletions
diff --git a/gtk2_ardour/diamond.cc b/gtk2_ardour/diamond.cc
index 53341cf246..04fdd509c2 100644
--- a/gtk2_ardour/diamond.cc
+++ b/gtk2_ardour/diamond.cc
@@ -25,11 +25,17 @@ using namespace Gnome::Art;
Diamond::Diamond(Group& group, double height)
: Polygon(group)
{
+ set_height(height);
+}
+
+void
+Diamond::set_height(double height)
+{
Points points;
points.push_back(Point(0, height*2.0));
points.push_back(Point(height, height));
points.push_back(Point(0, 0));
points.push_back(Point(-height, height));
- property_points() = points;
+ property_points() = points;
}
diff --git a/gtk2_ardour/diamond.h b/gtk2_ardour/diamond.h
index 14cec449f7..32544f4880 100644
--- a/gtk2_ardour/diamond.h
+++ b/gtk2_ardour/diamond.h
@@ -30,6 +30,8 @@ namespace Canvas {
class Diamond : public Polygon {
public:
Diamond(Group& group, double height);
+
+ void set_height(double height);
};
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 36defd7a57..858f59af69 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -40,6 +40,7 @@
#include "midi_time_axis.h"
#include "simpleline.h"
#include "canvas-hit.h"
+#include "canvas-note.h"
#include "public_editor.h"
#include "ghostregion.h"
#include "midi_time_axis.h"
@@ -559,31 +560,46 @@ MidiRegionView::set_y_position_and_height (double y, double h)
_model->read_lock();
for (std::vector<CanvasMidiEvent*>::const_iterator i = _events.begin(); i != _events.end(); ++i) {
- CanvasNote* note = dynamic_cast<CanvasNote*>(*i);
- if (note && note->note()) {
- if (note->note()->note() < midi_stream_view()->lowest_note() ||
- note->note()->note() > midi_stream_view()->highest_note()) {
- if (canvas_item_visible(note)) {
- note->hide();
+ CanvasMidiEvent* event = *i;
+ Item* item = dynamic_cast<Item*>(event);
+ assert(item);
+ if (event && event->note()) {
+ if (event->note()->note() < midi_stream_view()->lowest_note() ||
+ event->note()->note() > midi_stream_view()->highest_note()) {
+
+ if (canvas_item_visible(item)) {
+ item->hide();
}
- }
- else {
- const double y1 = midi_stream_view()->note_to_y(note->note()->note());
- const double y2 = y1 + floor(midi_stream_view()->note_height());
-
- if (!canvas_item_visible(note)) {
- note->show();
+ } else {
+ if (!canvas_item_visible(item)) {
+ item->show();
}
- note->hide_velocity();
- note->property_y1() = y1;
- note->property_y2() = y2;
- if(note->selected()) {
- note->show_velocity();
+ event->hide_velocity();
+ if(CanvasNote* note = dynamic_cast<CanvasNote*>(event)) {
+ const double y1 = midi_stream_view()->note_to_y(event->note()->note());
+ const double y2 = y1 + floor(midi_stream_view()->note_height());
+
+ note->property_y1() = y1;
+ note->property_y2() = y2;
+ }
+ if(CanvasHit* hit = dynamic_cast<CanvasHit*>(event)) {
+ double x = trackview.editor.frame_to_pixel((nframes_t)
+ event->note()->time() - _region->start());
+ const double diamond_size = midi_stream_view()->note_height() / 2.0;
+ double y = midi_stream_view()->note_to_y(event->note()->note())
+ + ((diamond_size-2.0) / 4.0);
+
+ hit->set_height(diamond_size);
+ hit->move(x-hit->x1(), y-hit->y1());
+ hit->show();
+ }
+ if(event->selected()) {
+ event->show_velocity();
+ }
}
}
}
- }
_model->read_unlock();
}