Add option to cmake to use old style sliders

This commit is contained in:
Nick Lanham 2012-02-22 17:13:08 +01:00
parent 43fdd2f200
commit 2944f6762c
2 changed files with 31 additions and 15 deletions

View File

@ -6,6 +6,9 @@ project (DrMr)
set(LV2_INSTALL_DIR lib/lv2 CACHE PATH "Specifies where the LV2 libraries should be installed") set(LV2_INSTALL_DIR lib/lv2 CACHE PATH "Specifies where the LV2 libraries should be installed")
set(CMAKE_C_FLAGS "-Wall") set(CMAKE_C_FLAGS "-Wall")
# Availble options
option(USE_NKNOB "Use custom NKnob widgets for gain/pan instead of Gtk sliders" ON)
# check for our various libraries # check for our various libraries
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(LV2 REQUIRED lv2-plugin>=1.0.4) pkg_check_modules(LV2 REQUIRED lv2-plugin>=1.0.4)
@ -33,6 +36,7 @@ add_library(drmr_ui SHARED
drmr_hydrogen.h drmr_hydrogen.h
nknob.h nknob.h
) )
set_target_properties(drmr PROPERTIES PREFIX "") set_target_properties(drmr PROPERTIES PREFIX "")
set_target_properties(drmr_ui PROPERTIES PREFIX "") set_target_properties(drmr_ui PROPERTIES PREFIX "")
@ -46,6 +50,12 @@ set_target_properties (drmr_ui
DEFINE_SYMBOL "INSTALL_DIR=\"${CMAKE_INSTALL_PREFIX}/${LV2_INSTALL_DIR}\"" DEFINE_SYMBOL "INSTALL_DIR=\"${CMAKE_INSTALL_PREFIX}/${LV2_INSTALL_DIR}\""
) )
if (NOT USE_NKNOB)
set_target_properties (drmr_ui
PROPERTIES
COMPILE_FLAGS "-DNO_NKNOB"
)
endif (NOT USE_NKNOB)
# config install # config install
install(TARGETS drmr drmr_ui install(TARGETS drmr drmr_ui

View File

@ -82,53 +82,59 @@ static void fill_sample_table(DrMrUi* ui, int samples, char** names,GtkWidget**
GtkWidget* pan_slider; GtkWidget* pan_slider;
GtkWidget* gain_label; GtkWidget* gain_label;
GtkWidget* pan_label; GtkWidget* pan_label;
gboolean slide_expand;
sprintf(buf,"<b>%s</b>",names[si]); sprintf(buf,"<b>%s</b>",names[si]);
frame = gtk_frame_new(buf); frame = gtk_frame_new(buf);
gtk_label_set_use_markup(GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),true); gtk_label_set_use_markup(GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),true);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT); gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
hbox = gtk_hbox_new(false,0); hbox = gtk_hbox_new(false,0);
//gain_slider = gtk_vscale_new_with_range(GAIN_MIN,6.0,1.0); #ifdef NO_NKNOB
gain_slider = gtk_vscale_new_with_range(GAIN_MIN,6.0,1.0);
gtk_scale_set_value_pos(GTK_SCALE(gain_slider),GTK_POS_BOTTOM);
gtk_scale_set_digits(GTK_SCALE(gain_slider),1);
gtk_scale_add_mark(GTK_SCALE(gain_slider),0.0,GTK_POS_RIGHT,"0 dB");
// Hrmm, -inf label is at top in ardour for some reason
//gtk_scale_add_mark(GTK_SCALE(gain_slider),GAIN_MIN,GTK_POS_RIGHT,"-inf");
gtk_range_set_inverted(GTK_RANGE(gain_slider),true);
slide_expand = true;
#else
gain_slider = n_knob_new_with_range(0.0,GAIN_MIN,6.0,1.0); gain_slider = n_knob_new_with_range(0.0,GAIN_MIN,6.0,1.0);
gtk_widget_set_has_tooltip(gain_slider,TRUE); gtk_widget_set_has_tooltip(gain_slider,TRUE);
gtk_widget_set_size_request(gain_slider,-1,50); slide_expand = false;
#endif
g_object_set_qdata (G_OBJECT(gain_slider),ui->gain_quark,GINT_TO_POINTER(si)); g_object_set_qdata (G_OBJECT(gain_slider),ui->gain_quark,GINT_TO_POINTER(si));
if (gain_sliders) gain_sliders[si] = gain_slider; if (gain_sliders) gain_sliders[si] = gain_slider;
gtk_range_set_inverted(GTK_RANGE(gain_slider),true);
//gtk_scale_set_value_pos(GTK_SCALE(gain_slider),GTK_POS_BOTTOM);
if (si < 32) if (si < 32)
gtk_range_set_value(GTK_RANGE(gain_slider),ui->gain_vals[si]); gtk_range_set_value(GTK_RANGE(gain_slider),ui->gain_vals[si]);
else // things are gross if we have > 32 samples, what to do? else // things are gross if we have > 32 samples, what to do?
gtk_range_set_value(GTK_RANGE(gain_slider),0.0); gtk_range_set_value(GTK_RANGE(gain_slider),0.0);
g_signal_connect(G_OBJECT(gain_slider),"change-value",G_CALLBACK(gain_callback),ui); g_signal_connect(G_OBJECT(gain_slider),"change-value",G_CALLBACK(gain_callback),ui);
//gtk_scale_set_digits(GTK_SCALE(gain_slider),1);
//gtk_scale_add_mark(GTK_SCALE(gain_slider),0.0,GTK_POS_RIGHT,"0 dB");
// Hrmm, -inf label is at top in ardour for some reason
//gtk_scale_add_mark(GTK_SCALE(gain_slider),GAIN_MIN,GTK_POS_RIGHT,"-inf");
gain_label = gtk_label_new("Gain"); gain_label = gtk_label_new("Gain");
gain_vbox = gtk_vbox_new(false,0); gain_vbox = gtk_vbox_new(false,0);
//pan_slider = gtk_hscale_new_with_range(-1.0,1.0,0.1); #ifdef NO_NKNOB
pan_slider = gtk_hscale_new_with_range(-1.0,1.0,0.1);
gtk_scale_add_mark(GTK_SCALE(pan_slider),0.0,GTK_POS_TOP,NULL);
#else
pan_slider = n_knob_new_with_range(0.0,-1.0,1.0,0.1); pan_slider = n_knob_new_with_range(0.0,-1.0,1.0,0.1);
gtk_widget_set_has_tooltip(pan_slider,TRUE); gtk_widget_set_has_tooltip(pan_slider,TRUE);
gtk_widget_set_size_request(pan_slider,50,-1); #endif
if (pan_sliders) pan_sliders[si] = pan_slider; if (pan_sliders) pan_sliders[si] = pan_slider;
if (si < 32) if (si < 32)
gtk_range_set_value(GTK_RANGE(pan_slider),ui->pan_vals[si]); gtk_range_set_value(GTK_RANGE(pan_slider),ui->pan_vals[si]);
else else
gtk_range_set_value(GTK_RANGE(pan_slider),0); gtk_range_set_value(GTK_RANGE(pan_slider),0);
g_object_set_qdata (G_OBJECT(pan_slider),ui->pan_quark,GINT_TO_POINTER(si)); g_object_set_qdata (G_OBJECT(pan_slider),ui->pan_quark,GINT_TO_POINTER(si));
//gtk_scale_add_mark(GTK_SCALE(pan_slider),0.0,GTK_POS_TOP,NULL);
g_signal_connect(G_OBJECT(pan_slider),"change-value",G_CALLBACK(pan_callback),ui); g_signal_connect(G_OBJECT(pan_slider),"change-value",G_CALLBACK(pan_callback),ui);
pan_label = gtk_label_new("Pan"); pan_label = gtk_label_new("Pan");
pan_vbox = gtk_vbox_new(false,0); pan_vbox = gtk_vbox_new(false,0);
gtk_box_pack_start(GTK_BOX(gain_vbox),gain_slider,false,false,0); gtk_box_pack_start(GTK_BOX(gain_vbox),gain_slider,slide_expand,slide_expand,0);
gtk_box_pack_start(GTK_BOX(gain_vbox),gain_label,false,false,0); gtk_box_pack_start(GTK_BOX(gain_vbox),gain_label,false,false,0);
gtk_box_pack_start(GTK_BOX(pan_vbox),pan_slider,false,false,0); gtk_box_pack_start(GTK_BOX(pan_vbox),pan_slider,slide_expand,slide_expand,0);
gtk_box_pack_start(GTK_BOX(pan_vbox),pan_label,false,false,0); gtk_box_pack_start(GTK_BOX(pan_vbox),pan_label,false,false,0);
gtk_box_pack_start(GTK_BOX(hbox),gain_vbox,true,true,0); gtk_box_pack_start(GTK_BOX(hbox),gain_vbox,true,true,0);