[Summary] Implementing touch cursor for faders.

This commit is contained in:
VKamyshniy 2014-08-26 17:05:50 +03:00
parent aa44a0e796
commit 0180909a38
7 changed files with 44 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -33,6 +33,7 @@
underlaysource="slider_controller_fader_underlay.png"
handlesource="slider_controller_fader_handle.png"
activehandlesource="slider_controller_fader_handle.png"
touchcursor="fader_touch_cursor.png"
minposx="10"
minposy="196"
maxposx="10"

View file

@ -47,6 +47,7 @@
underlaysource="slider_controller_fader_underlay.png"
handlesource="slider_controller_fader_handle.png"
activehandlesource="slider_controller_fader_handle.png"
touchcursor="fader_touch_cursor.png"
minposx="10"
minposy="196"
maxposx="10"

View file

@ -33,6 +33,7 @@
underlaysource="slider_controller_fader_underlay.png"
handlesource="slider_controller_fader_handle.png"
activehandlesource="slider_controller_fader_handle.png"
touchcursor="fader_touch_cursor.png"
minposx="10"
minposy="196"
maxposx="10"

View file

@ -592,6 +592,14 @@ WavesUI::set_attributes (Gtk::Widget& widget, const XMLNode& definition, const X
event_box->set_visible_window (visible_window);
}
Gtkmm2ext::Fader* fader = dynamic_cast<Gtkmm2ext::Fader*> (&widget);
if (fader) {
property = xml_property (definition, "touchcursor", styles, "");
if (!property.empty ()) {
fader->set_touch_cursor (property);
}
}
Gtk::Label* label = dynamic_cast<Gtk::Label*> (&widget);
if (label) {
property = xml_property (definition, "justify", styles, "left");

View file

@ -140,6 +140,8 @@ Fader::Fader (Gtk::Adjustment& adj,
, _default_value (adjustment.get_value())
, _dragging (false)
, _read_only (read_only)
, _grab_window (0)
, _touch_cursor (0)
{
PBD::Searchpath spath(ARDOUR::ardour_data_search_path());
@ -262,6 +264,10 @@ Fader::on_button_press_event (GdkEventButton* ev)
return false;
}
if (_touch_cursor) {
get_window()->set_cursor (*_touch_cursor);
}
double hx;
double hy;
get_handle_position (hx, hy);
@ -313,6 +319,10 @@ Fader::on_button_release_event (GdkEventButton* ev)
return false;
}
if (_touch_cursor) {
get_window()->set_cursor ();
}
if (_dragging) { //temp
remove_modal_grab();
_dragging = false;
@ -458,6 +468,26 @@ Fader::set_default_value (float d)
update_unity_position ();
}
void
Fader::set_touch_cursor (const std::string& icon_name)
{
PBD::Searchpath spath(ARDOUR::ardour_data_search_path());
spath.add_subdirectory_to_paths ("icons");
std::string icon_file_path;
if (PBD::find_file_in_search_path (spath, icon_name, icon_file_path)) {
_touch_cursor = new Gdk::Cursor (Gdk::Display::get_default(),
Gdk::Pixbuf::create_from_file (icon_file_path),
12,
12);
} else {
throw failed_constructor();
}
}
void
Fader::update_unity_position ()
{

View file

@ -52,8 +52,8 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
virtual ~Fader ();
void set_controllable (boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable (c); }
void set_default_value (float);
void set_touch_cursor (const std::string& icon_name);
protected:
void get_handle_position (double& x, double& y);
@ -88,6 +88,8 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
bool _hovering;
GdkWindow* _grab_window;
Gdk::Cursor *_touch_cursor;
double _grab_loc_x;
double _grab_loc_y;
double _grab_start_x;