Move mouse cursor stuff out of Editor into its own class.
[ardour.git] / gtk2_ardour / editor.cc
index 8512200b076ce14dd8b07a23044494eede726dee..d19f5f6424d35edac0a1cc6dada990465bf230b8 100644 (file)
 #include "editor_snapshots.h"
 #include "editor_summary.h"
 #include "region_layering_order_editor.h"
+#include "mouse_cursors.h"
+#include "editor_cursors.h"
 
 #include "i18n.h"
 
@@ -136,8 +138,6 @@ using Gtkmm2ext::Keyboard;
 
 const double Editor::timebar_height = 15.0;
 
-#include "editor_xpms"
-
 static const gchar *_snap_type_strings[] = {
        N_("CD Frames"),
        N_("Timecode Frames"),
@@ -207,32 +207,6 @@ static const gchar *_rb_opt_strings[] = {
 };
 #endif
 
-/* Soundfile  drag-n-drop */
-
-Gdk::Cursor* Editor::cross_hair_cursor = 0;
-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::fade_in_cursor = 0;
-Gdk::Cursor* Editor::fade_out_cursor = 0;
-Gdk::Cursor* Editor::grabber_cursor = 0;
-Gdk::Cursor* Editor::grabber_note_cursor = 0;
-Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
-Gdk::Cursor* Editor::zoom_in_cursor = 0;
-Gdk::Cursor* Editor::zoom_out_cursor = 0;
-Gdk::Cursor* Editor::time_fx_cursor = 0;
-Gdk::Cursor* Editor::fader_cursor = 0;
-Gdk::Cursor* Editor::speaker_cursor = 0;
-Gdk::Cursor* Editor::midi_pencil_cursor = 0;
-Gdk::Cursor* Editor::midi_select_cursor = 0;
-Gdk::Cursor* Editor::midi_resize_cursor = 0;
-Gdk::Cursor* Editor::midi_erase_cursor = 0;
-Gdk::Cursor* Editor::wait_cursor = 0;
-Gdk::Cursor* Editor::timebar_cursor = 0;
-Gdk::Cursor* Editor::transparent_cursor = 0;
-Gdk::Cursor* Editor::up_down_cursor = 0;
-
 void
 show_me_the_size (Requisition* r, const char* what)
 {
@@ -505,7 +479,7 @@ Editor::Editor ()
        controls_layout.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::edit_controls_button_release));
        controls_layout_size_request_connection = controls_layout.signal_size_request().connect (sigc::mem_fun (*this, &Editor::controls_layout_size_request));
 
-       build_cursors ();
+       _cursors = new MouseCursors;
 
        ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
        ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
@@ -739,6 +713,7 @@ Editor::Editor ()
        _popup_region_menu_item = 0;
 
        _show_marker_lines = false;
+       _over_region_trim_target = false;
 
        constructed = true;
        instant_save ();
@@ -1222,104 +1197,6 @@ Editor::action_pre_activated (Glib::RefPtr<Action> const & a)
        }
 }
 
-void
-Editor::build_cursors ()
-{
-       using namespace Gdk;
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> zoom_in_cursor_pixbuf (::get_icon ("zoom_in_cursor"));
-               zoom_in_cursor = new Gdk::Cursor (Gdk::Display::get_default(), zoom_in_cursor_pixbuf, 5, 5);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> zoom_out_cursor_pixbuf (::get_icon ("zoom_out_cursor"));
-               zoom_out_cursor = new Gdk::Cursor (Gdk::Display::get_default(), zoom_out_cursor_pixbuf, 5, 5);
-       }
-       
-       Gdk::Color fbg ("#ffffff" );
-       Gdk::Color ffg  ("#000000" );
-
-       {
-               RefPtr<Bitmap> source, mask;
-
-               source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
-               mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
-               fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
-       }
-
-       {
-               RefPtr<Bitmap> source, mask;
-               source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
-               mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
-               speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
-       }
-
-       {
-               RefPtr<Bitmap> bits;
-               char pix[4] = { 0, 0, 0, 0 };
-               bits = Bitmap::create (pix, 2, 2);
-               Gdk::Color c;
-               transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
-       }
-
-       {
-               RefPtr<Bitmap> bits;
-               char pix[4] = { 0, 0, 0, 0 };
-               bits = Bitmap::create (pix, 2, 2);
-               Gdk::Color c;
-               transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> grabber_pixbuf (::get_icon ("grabber"));
-               grabber_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_pixbuf, 5, 0);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> grabber_note_pixbuf (::get_icon ("grabber_note"));
-               grabber_note_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_note_pixbuf, 5, 10);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
-               grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
-       }
-
-       cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
-       trimmer_cursor =  new Gdk::Cursor (SB_H_DOUBLE_ARROW);
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_left_cursor"));
-               left_side_trim_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 5, 11);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_right_cursor"));
-               right_side_trim_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);
-       }
-
-       {
-               Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("fade_out_cursor"));
-               fade_out_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 29, 0);
-       }
-
-       selector_cursor = new Gdk::Cursor (XTERM);
-       time_fx_cursor = new Gdk::Cursor (SIZING);
-       wait_cursor = new Gdk::Cursor  (WATCH);
-       timebar_cursor = new Gdk::Cursor(LEFT_PTR);
-       midi_pencil_cursor = new Gdk::Cursor (PENCIL);
-       midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
-       midi_resize_cursor = new Gdk::Cursor (SIZING);
-       midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
-       up_down_cursor = new Gdk::Cursor (Gdk::SB_V_DOUBLE_ARROW);
-}
-
 /** Pop up a context menu for when the user clicks on a fade in or fade out */
 void
 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)