Modify region trim cursor if a region can only be trimmed in one direction.

git-svn-id: svn://localhost/ardour2/branches/3.0@8045 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington
2010-11-15 22:55:39 +00:00
parent 90172686b9
commit ee76685f8d
7 changed files with 40 additions and 31 deletions

View File

@@ -214,6 +214,8 @@ Gdk::Cursor* Editor::selector_cursor = 0;
Gdk::Cursor* Editor::trimmer_cursor = 0;
Gdk::Cursor* Editor::left_side_trim_cursor = 0;
Gdk::Cursor* Editor::right_side_trim_cursor = 0;
Gdk::Cursor* Editor::left_side_trim_right_only_cursor = 0;
Gdk::Cursor* Editor::right_side_trim_left_only_cursor = 0;
Gdk::Cursor* Editor::fade_in_cursor = 0;
Gdk::Cursor* Editor::fade_out_cursor = 0;
Gdk::Cursor* Editor::grabber_cursor = 0;
@@ -1311,6 +1313,16 @@ Editor::build_cursors ()
right_side_trim_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 23, 11);
}
{
Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_left_cursor_right_only"));
left_side_trim_right_only_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 5, 11);
}
{
Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_right_cursor_left_only"));
right_side_trim_left_only_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 23, 11);
}
{
Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("fade_in_cursor"));
fade_in_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 0, 0);

View File

@@ -456,6 +456,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
static Gdk::Cursor* trimmer_cursor;
static Gdk::Cursor* right_side_trim_cursor;
static Gdk::Cursor* left_side_trim_cursor;
static Gdk::Cursor* right_side_trim_left_only_cursor;
static Gdk::Cursor* left_side_trim_right_only_cursor;
static Gdk::Cursor* fade_in_cursor;
static Gdk::Cursor* fade_out_cursor;
static Gdk::Cursor* selector_cursor;

View File

@@ -1575,31 +1575,16 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
break;
case RegionViewNameHighlight:
if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) {
if (is_drawable() && mouse_mode == MouseObject && !internal_editing() && entered_regionview) {
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
_over_region_trim_target = true;
}
break;
case LeftFrameHandle:
if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) {
if (entered_regionview) {
Trimmable::CanTrim ct = entered_regionview->region()->can_trim();
if ((ct & Trimmable::EndTrimEarlier) || (ct & Trimmable::EndTrimLater)) {
set_canvas_cursor (left_side_trim_cursor);
}
}
}
break;
case RightFrameHandle:
if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) {
if (entered_regionview) {
Trimmable::CanTrim ct = entered_regionview->region()->can_trim();
if ((ct & Trimmable::FrontTrimEarlier) || (ct & Trimmable::FrontTrimLater)) {
set_canvas_cursor (right_side_trim_cursor);
}
}
if (is_drawable() && mouse_mode == MouseObject && !internal_editing() && entered_regionview) {
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
}
break;
@@ -2728,11 +2713,21 @@ Editor::set_canvas_cursor_for_region_view (double x, RegionView* rv)
double x1, x2, y1, y2;
g->get_bounds (x1, y1, x2, y2);
/* Halfway across the region */
double const h = (x1 + x2) / 2;
if (x1 < x && x <= h) {
set_canvas_cursor (left_side_trim_cursor);
} else if (h < x && x <= x2) {
set_canvas_cursor (right_side_trim_cursor);
Trimmable::CanTrim ct = rv->region()->can_trim ();
if (x <= h) {
if (ct & Trimmable::FrontTrimEarlier) {
set_canvas_cursor (left_side_trim_cursor);
} else {
set_canvas_cursor (left_side_trim_right_only_cursor);
}
} else {
if (ct & Trimmable::EndTrimLater) {
set_canvas_cursor (right_side_trim_cursor);
} else {
set_canvas_cursor (right_side_trim_left_only_cursor);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

View File

@@ -9,14 +9,14 @@ class Trimmable {
virtual ~Trimmable() {}
enum CanTrim {
FrontTrimEarlier,
FrontTrimLater,
EndTrimEarlier,
EndTrimLater,
TopTrimUp,
TopTrimDown,
BottomTrimUp,
BottomTrimDown
FrontTrimEarlier = 0x1,
FrontTrimLater = 0x2,
EndTrimEarlier = 0x4,
EndTrimLater = 0x8,
TopTrimUp = 0x10,
TopTrimDown = 0x20,
BottomTrimUp = 0x40,
BottomTrimDown = 0x80
} ;
virtual CanTrim can_trim() const {

View File

@@ -1607,7 +1607,7 @@ Region::can_trim () const
}
if (!_sources.empty()) {
if (last_frame() < _sources.front()->length (0)) {
if ((start() + length()) < _sources.front()->length (0)) {
ct = CanTrim (ct | EndTrimLater);
}
}