change ::get_icon_path() and ::get_icon() to accept an "icon set" name to provide ability to use different sets of icons; use when creating MouseCursors
This commit is contained in:
parent
eca6c9f998
commit
d59d26b89a
|
@ -500,6 +500,7 @@ Editor::Editor ()
|
|||
controls_layout.signal_scroll_event().connect (sigc::mem_fun(*this, &Editor::control_layout_scroll), false);
|
||||
|
||||
_cursors = new MouseCursors;
|
||||
_cursors->set_cursor_set (ARDOUR_UI::config()->get_icon_set());
|
||||
|
||||
ArdourCanvas::GtkCanvas* time_pad = manage (new ArdourCanvas::GtkCanvas ());
|
||||
|
||||
|
|
|
@ -23,17 +23,102 @@
|
|||
#include "editor_xpms"
|
||||
|
||||
MouseCursors::MouseCursors ()
|
||||
: cross_hair (0)
|
||||
, trimmer (0)
|
||||
, right_side_trim (0)
|
||||
, left_side_trim (0)
|
||||
, right_side_trim_left_only (0)
|
||||
, left_side_trim_right_only (0)
|
||||
, fade_in (0)
|
||||
, fade_out (0)
|
||||
, selector (0)
|
||||
, grabber (0)
|
||||
, grabber_note (0)
|
||||
, grabber_edit_point (0)
|
||||
, zoom_in (0)
|
||||
, zoom_out (0)
|
||||
, time_fx (0)
|
||||
, fader (0)
|
||||
, speaker (0)
|
||||
, midi_pencil (0)
|
||||
, midi_select (0)
|
||||
, midi_resize (0)
|
||||
, midi_erase (0)
|
||||
, up_down (0)
|
||||
, wait (0)
|
||||
, timebar (0)
|
||||
, transparent (0)
|
||||
, resize_left (0)
|
||||
, resize_top_left (0)
|
||||
, resize_top (0)
|
||||
, resize_top_right (0)
|
||||
, resize_right (0)
|
||||
, resize_bottom_right (0)
|
||||
, resize_bottom (0)
|
||||
, resize_bottom_left (0)
|
||||
, move (0)
|
||||
, expand_left_right (0)
|
||||
, expand_up_down (0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MouseCursors::drop_all ()
|
||||
{
|
||||
delete cross_hair; cross_hair = 0;
|
||||
delete trimmer; trimmer = 0;
|
||||
delete right_side_trim; right_side_trim = 0;
|
||||
delete left_side_trim; left_side_trim = 0;
|
||||
delete right_side_trim_left_only; right_side_trim_left_only = 0;
|
||||
delete left_side_trim_right_only; left_side_trim_right_only = 0;
|
||||
delete fade_in; fade_in = 0;
|
||||
delete fade_out; fade_out = 0;
|
||||
delete selector; selector = 0;
|
||||
delete grabber; grabber = 0;
|
||||
delete grabber_note; grabber_note = 0;
|
||||
delete grabber_edit_point; grabber_edit_point = 0;
|
||||
delete zoom_in; zoom_in = 0;
|
||||
delete zoom_out; zoom_out = 0;
|
||||
delete time_fx; time_fx = 0;
|
||||
delete fader; fader = 0;
|
||||
delete speaker; speaker = 0;
|
||||
delete midi_pencil; midi_pencil = 0;
|
||||
delete midi_select; midi_select = 0;
|
||||
delete midi_resize; midi_resize = 0;
|
||||
delete midi_erase; midi_erase = 0;
|
||||
delete up_down; up_down = 0;
|
||||
delete wait; wait = 0;
|
||||
delete timebar; timebar = 0;
|
||||
delete transparent; transparent = 0;
|
||||
delete resize_left; resize_left = 0;
|
||||
delete resize_top_left; resize_top_left = 0;
|
||||
delete resize_top; resize_top = 0;
|
||||
delete resize_top_right; resize_top_right = 0;
|
||||
delete resize_right; resize_right = 0;
|
||||
delete resize_bottom_right; resize_bottom_right = 0;
|
||||
delete resize_bottom; resize_bottom = 0;
|
||||
delete resize_bottom_left; resize_bottom_left = 0;
|
||||
delete move; move = 0;
|
||||
delete expand_left_right; expand_left_right = 0;
|
||||
delete expand_up_down; expand_up_down = 0;
|
||||
}
|
||||
|
||||
void
|
||||
MouseCursors::set_cursor_set (const std::string& name)
|
||||
{
|
||||
using namespace Glib;
|
||||
using namespace Gdk;
|
||||
|
||||
drop_all ();
|
||||
_cursor_set = name;
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("zoom_in_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("zoom_in_cursor", _cursor_set));
|
||||
zoom_in = new Cursor (Display::get_default(), p, 10, 5);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("zoom_out_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("zoom_out_cursor", _cursor_set));
|
||||
zoom_out = new Cursor (Display::get_default(), p, 5, 5);
|
||||
}
|
||||
|
||||
|
@ -67,17 +152,17 @@ MouseCursors::MouseCursors ()
|
|||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber", _cursor_set));
|
||||
grabber = new Cursor (Display::get_default(), p, 5, 0);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber_note"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber_note", _cursor_set));
|
||||
grabber_note = new Cursor (Display::get_default(), p, 5, 10);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber_edit_point"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("grabber_edit_point", _cursor_set));
|
||||
grabber_edit_point = new Cursor (Display::get_default(), p, 5, 17);
|
||||
}
|
||||
|
||||
|
@ -85,92 +170,92 @@ MouseCursors::MouseCursors ()
|
|||
trimmer = new Cursor (SB_H_DOUBLE_ARROW);
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor", _cursor_set));
|
||||
left_side_trim = new Cursor (Display::get_default(), p, 5, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor", _cursor_set));
|
||||
right_side_trim = new Cursor (Display::get_default(), p, 23, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor_right_only"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor_right_only", _cursor_set));
|
||||
left_side_trim_right_only = new Cursor (Display::get_default(), p, 5, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor_left_only"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor_left_only", _cursor_set));
|
||||
right_side_trim_left_only = new Cursor (Display::get_default(), p, 23, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("fade_in_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("fade_in_cursor", _cursor_set));
|
||||
fade_in = new Cursor (Display::get_default(), p, 0, 0);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("fade_out_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("fade_out_cursor", _cursor_set));
|
||||
fade_out = new Cursor (Display::get_default(), p, 29, 0);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_left_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_left_cursor", _cursor_set));
|
||||
resize_left = new Cursor (Display::get_default(), p, 3, 10);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_left_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_left_cursor", _cursor_set));
|
||||
resize_top_left = new Cursor (Display::get_default(), p, 3, 3);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_cursor", _cursor_set));
|
||||
resize_top = new Cursor (Display::get_default(), p, 10, 3);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_right_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_top_right_cursor", _cursor_set));
|
||||
resize_top_right = new Cursor (Display::get_default(), p, 18, 3);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_right_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_right_cursor", _cursor_set));
|
||||
resize_right = new Cursor (Display::get_default(), p, 24, 10);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_right_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_right_cursor", _cursor_set));
|
||||
resize_bottom_right = new Cursor (Display::get_default(), p, 18, 18);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_cursor", _cursor_set));
|
||||
resize_bottom = new Cursor (Display::get_default(), p, 10, 24);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_left_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("resize_bottom_left_cursor", _cursor_set));
|
||||
resize_bottom_left = new Cursor (Display::get_default(), p, 3, 18);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("move_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("move_cursor", _cursor_set));
|
||||
move = new Cursor (Display::get_default(), p, 11, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("expand_left_right_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("expand_left_right_cursor", _cursor_set));
|
||||
expand_left_right = new Cursor (Display::get_default(), p, 11, 4);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("expand_up_down_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("expand_up_down_cursor", _cursor_set));
|
||||
expand_up_down = new Cursor (Display::get_default(), p, 4, 11);
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<Pixbuf> p (::get_icon ("i_beam_cursor"));
|
||||
RefPtr<Pixbuf> p (::get_icon ("i_beam_cursor", _cursor_set));
|
||||
selector = new Cursor (Display::get_default(), p, 4, 11);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ class MouseCursors
|
|||
public:
|
||||
MouseCursors ();
|
||||
|
||||
void set_cursor_set (const std::string& name);
|
||||
std::string cursor_set() const { return _cursor_set; }
|
||||
|
||||
Gdk::Cursor* cross_hair;
|
||||
Gdk::Cursor* trimmer;
|
||||
Gdk::Cursor* right_side_trim;
|
||||
|
@ -66,6 +69,11 @@ public:
|
|||
Gdk::Cursor* move;
|
||||
Gdk::Cursor* expand_left_right;
|
||||
Gdk::Cursor* expand_up_down;
|
||||
|
||||
private:
|
||||
std::string _cursor_set;
|
||||
void drop_all ();
|
||||
|
||||
};
|
||||
|
||||
#endif /* __gtk2_ardour_mouse_cursors__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
*/
|
||||
|
||||
UI_CONFIG_VARIABLE(std::string, icon_set, "icon-set", "default")
|
||||
UI_CONFIG_VARIABLE(std::string, ui_rc_file, "ui-rc-file", "ardour3_ui_dark.rc")
|
||||
UI_CONFIG_VARIABLE(bool, flat_buttons, "flat-buttons", false)
|
||||
UI_CONFIG_VARIABLE(float, waveform_gradient_depth, "waveform-gradient-depth", 0.6)
|
||||
|
|
|
@ -655,24 +655,54 @@ get_xpm (std::string name)
|
|||
}
|
||||
|
||||
std::string
|
||||
get_icon_path (const char* cname)
|
||||
get_icon_path (const char* cname, string icon_set)
|
||||
{
|
||||
std::string data_file_path;
|
||||
string name = cname;
|
||||
name += X_(".png");
|
||||
|
||||
Searchpath spath(ARDOUR::ardour_data_search_path());
|
||||
|
||||
spath.add_subdirectory_to_paths("icons");
|
||||
|
||||
std::string data_file_path;
|
||||
|
||||
if (!find_file_in_search_path (spath, name, data_file_path)) {
|
||||
fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
|
||||
|
||||
if (!icon_set.empty() && icon_set != "default") {
|
||||
string subdir = Glib::build_filename ("icons", icon_set);
|
||||
spath.add_subdirectory_to_paths (subdir);
|
||||
|
||||
find_file_in_search_path (spath, name, data_file_path);
|
||||
}
|
||||
|
||||
if (data_file_path.empty()) {
|
||||
|
||||
if (!icon_set.empty() && icon_set != "default") {
|
||||
warning << string_compose (_("icon \"%1\" not found for icon set \"%2\", fallback to default"), cname, icon_set) << endmsg;
|
||||
}
|
||||
|
||||
Searchpath def (ARDOUR::ardour_data_search_path());
|
||||
def.add_subdirectory_to_paths ("icons");
|
||||
|
||||
if (!find_file_in_search_path (def, name, data_file_path)) {
|
||||
fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
|
||||
return data_file_path;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
get_icon (const char* cname, string icon_set)
|
||||
{
|
||||
Glib::RefPtr<Gdk::Pixbuf> img;
|
||||
try {
|
||||
img = Gdk::Pixbuf::create_from_file (get_icon_path (cname, icon_set));
|
||||
} catch (const Gdk::PixbufError &e) {
|
||||
cerr << "Caught PixbufError: " << e.what() << endl;
|
||||
} catch (...) {
|
||||
error << string_compose (_("Caught exception while loading icon named %1"), cname) << endmsg;
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf>
|
||||
get_icon (const char* cname)
|
||||
{
|
||||
|
|
|
@ -76,8 +76,8 @@ bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev);
|
|||
bool emulate_key_event (Gtk::Widget*, unsigned int);
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> get_xpm (std::string);
|
||||
std::string get_icon_path (const char*);
|
||||
Glib::RefPtr<Gdk::Pixbuf> get_icon (const char*);
|
||||
std::string get_icon_path (const char*, std::string icon_set = std::string());
|
||||
Glib::RefPtr<Gdk::Pixbuf> get_icon (const char*, std::string icon_set = std::string());
|
||||
static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map;
|
||||
const char* const *get_xpm_data (std::string path);
|
||||
std::string longest (std::vector<std::string>&);
|
||||
|
|
Loading…
Reference in New Issue
Block a user