13
0

prevent trim cursors appearing, and prevent note trimming, when in a MIDI note that is too small on-screen. avoids silliness with trim cursors appearing while drawing small notes on screen, though really, it would nice to avoid them appearing ever in a note that was just added. not sure how to do that.

git-svn-id: svn://localhost/ardour2/branches/3.0@9077 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-03-05 23:00:49 +00:00
parent fb2ef7cb9a
commit f649d775bc
6 changed files with 30 additions and 17 deletions

View File

@ -41,10 +41,10 @@ public:
void show() { Diamond::show(); } void show() { Diamond::show(); }
void hide() { Diamond::hide(); } void hide() { Diamond::hide(); }
double x1() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x1; } double x1() const { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x1; }
double y1() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return y1; } double y1() const { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return y1; }
double x2() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x2; } double x2() const { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x2; }
double y2() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return y2; } double y2() const { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return y2; }
void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; } void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; }
void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; } void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; }

View File

@ -292,7 +292,14 @@ CanvasNoteEvent::set_mouse_fractions (GdkEvent* ev)
_mouse_y_fraction = yf; _mouse_y_fraction = yf;
if (notify) { if (notify) {
_region.note_mouse_position (_mouse_x_fraction, _mouse_y_fraction, set_cursor); if (big_enough_to_trim()) {
_region.note_mouse_position (_mouse_x_fraction, _mouse_y_fraction, set_cursor);
} else {
/* pretend the mouse is in the middle, because this is not big enough
to trim right now.
*/
_region.note_mouse_position (0.5, 0.5, set_cursor);
}
} }
} }
@ -347,6 +354,12 @@ CanvasNoteEvent::mouse_near_ends () const
(_mouse_x_fraction >= 0.75 && _mouse_x_fraction < 1.0); (_mouse_x_fraction >= 0.75 && _mouse_x_fraction < 1.0);
} }
bool
CanvasNoteEvent::big_enough_to_trim () const
{
return (x2() - x1()) > 10; /* canvas units, really pixels */
}
} // namespace Canvas } // namespace Canvas
} // namespace Gnome } // namespace Gnome

View File

@ -95,10 +95,10 @@ class CanvasNoteEvent : virtual public sigc::trackable
virtual void set_outline_color(uint32_t c) = 0; virtual void set_outline_color(uint32_t c) = 0;
virtual void set_fill_color(uint32_t c) = 0; virtual void set_fill_color(uint32_t c) = 0;
virtual double x1() = 0; virtual double x1() const = 0;
virtual double y1() = 0; virtual double y1() const = 0;
virtual double x2() = 0; virtual double x2() const = 0;
virtual double y2() = 0; virtual double y2() const = 0;
float mouse_x_fraction() const { return _mouse_x_fraction; } float mouse_x_fraction() const { return _mouse_x_fraction; }
float mouse_y_fraction() const { return _mouse_y_fraction; } float mouse_y_fraction() const { return _mouse_y_fraction; }
@ -143,6 +143,7 @@ class CanvasNoteEvent : virtual public sigc::trackable
static const uint32_t midi_channel_colors[16]; static const uint32_t midi_channel_colors[16];
bool mouse_near_ends () const; bool mouse_near_ends () const;
bool big_enough_to_trim () const;
protected: protected:
enum State { None, Pressed, Dragging }; enum State { None, Pressed, Dragging };

View File

@ -39,10 +39,10 @@ class CanvasNote : public SimpleRect, public CanvasNoteEvent
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>(), const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>(),
bool with_events = true); bool with_events = true);
double x1() { return property_x1(); } double x1() const { return property_x1(); }
double y1() { return property_y1(); } double y1() const { return property_y1(); }
double x2() { return property_x2(); } double x2() const { return property_x2(); }
double y2() { return property_y2(); } double y2() const { return property_y2(); }
void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; hide(); show(); } void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; hide(); show(); }
void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; hide(); show(); } void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; hide(); show(); }

View File

@ -713,8 +713,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
if (internal_editing()) { if (internal_editing()) {
/* trim notes if we're in internal edit mode and near the ends of the note */ /* trim notes if we're in internal edit mode and near the ends of the note */
ArdourCanvas::CanvasNote* cn = dynamic_cast<ArdourCanvas::CanvasNote*> (item); ArdourCanvas::CanvasNote* cn = dynamic_cast<ArdourCanvas::CanvasNote*> (item);
cerr << "NoteItem button press, cursor = " << current_canvas_cursor << endl; if (cn->big_enough_to_trim() && cn->mouse_near_ends()) {
if (cn->mouse_near_ends()) {
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
} else { } else {
_drags->set (new NoteDrag (this, item), event); _drags->set (new NoteDrag (this, item), event);