13
0

* 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
This commit is contained in:
Hans Baier 2008-04-21 16:42:55 +00:00
parent c72bf18bf4
commit 7afccaa9fe
3 changed files with 44 additions and 20 deletions

View File

@ -24,12 +24,18 @@ 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;
}

View File

@ -30,6 +30,8 @@ namespace Canvas {
class Diamond : public Polygon {
public:
Diamond(Group& group, double height);
void set_height(double height);
};

View File

@ -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();
}