make GUI more compact
This commit is contained in:
37
effects.c
37
effects.c
@@ -686,51 +686,52 @@ static EffectGroup effects_lib_group[] = {
|
||||
};
|
||||
|
||||
static Effect wah_effect[] = {
|
||||
{"Wah", WAH_ON_OFF, WAH_POSITION, wah_group, G_N_ELEMENTS(wah_group)},
|
||||
{NULL, WAH_ON_OFF, WAH_POSITION, wah_group, G_N_ELEMENTS(wah_group)},
|
||||
};
|
||||
|
||||
static Effect comp_effect[] = {
|
||||
{"Compressor", COMP_ON_OFF, COMP_POSITION, comp_group, G_N_ELEMENTS(comp_group)},
|
||||
{NULL, COMP_ON_OFF, COMP_POSITION, comp_group, G_N_ELEMENTS(comp_group)},
|
||||
};
|
||||
|
||||
static Effect dist_effect[] = {
|
||||
{"Distortion", DIST_ON_OFF, DIST_POSITION, dist_group, G_N_ELEMENTS(dist_group)},
|
||||
{NULL, DIST_ON_OFF, DIST_POSITION, dist_group, G_N_ELEMENTS(dist_group)},
|
||||
};
|
||||
|
||||
static Effect noisegate_effect[] = {
|
||||
{"Noisegate", NOISEGATE_ON_OFF, NOISEGATE_POSITION, noisegate_group, G_N_ELEMENTS(noisegate_group)},
|
||||
{NULL, NOISEGATE_ON_OFF, NOISEGATE_POSITION, noisegate_group, G_N_ELEMENTS(noisegate_group)},
|
||||
};
|
||||
|
||||
static Effect chorusfx_effect[] = {
|
||||
{"Chorus/FX", CHORUSFX_ON_OFF, CHORUSFX_POSITION, chorusfx_group, G_N_ELEMENTS(chorusfx_group)},
|
||||
{NULL, CHORUSFX_ON_OFF, CHORUSFX_POSITION, chorusfx_group, G_N_ELEMENTS(chorusfx_group)},
|
||||
};
|
||||
|
||||
static Effect delay_effect[] = {
|
||||
{"Delay", DELAY_ON_OFF, DELAY_POSITION, delay_group, G_N_ELEMENTS(delay_group)},
|
||||
{NULL, DELAY_ON_OFF, DELAY_POSITION, delay_group, G_N_ELEMENTS(delay_group)},
|
||||
};
|
||||
|
||||
static Effect reverb_effect[] = {
|
||||
{"Reverb", REVERB_ON_OFF, REVERB_POSITION, reverb_group, G_N_ELEMENTS(reverb_group)},
|
||||
{NULL, REVERB_ON_OFF, REVERB_POSITION, reverb_group, G_N_ELEMENTS(reverb_group)},
|
||||
};
|
||||
|
||||
static Effect amp_effect[] = {
|
||||
{"Amp", AMP_ON_OFF, AMP_POSITION, amp_group, G_N_ELEMENTS(amp_group)},
|
||||
{NULL, AMP_ON_OFF, AMP_POSITION, amp_group, G_N_ELEMENTS(amp_group)},
|
||||
{"Cabinet", -1, -1, amp_cab_group, G_N_ELEMENTS(amp_cab_group)},
|
||||
};
|
||||
|
||||
static Effect eq_effect[] = {
|
||||
{"EQ", EQ_ON_OFF, EQ_POSITION, eq_group, G_N_ELEMENTS(eq_group)},
|
||||
{NULL, EQ_ON_OFF, EQ_POSITION, eq_group, G_N_ELEMENTS(eq_group)},
|
||||
};
|
||||
|
||||
EffectList effects[] = {
|
||||
{wah_effect, G_N_ELEMENTS(wah_effect)},
|
||||
{amp_effect, G_N_ELEMENTS(amp_effect)},
|
||||
{eq_effect, G_N_ELEMENTS(eq_effect)},
|
||||
{comp_effect, G_N_ELEMENTS(comp_effect)},
|
||||
{dist_effect, G_N_ELEMENTS(dist_effect)},
|
||||
{noisegate_effect, G_N_ELEMENTS(noisegate_effect)},
|
||||
{chorusfx_effect, G_N_ELEMENTS(chorusfx_effect)},
|
||||
{delay_effect, G_N_ELEMENTS(delay_effect)},
|
||||
{reverb_effect, G_N_ELEMENTS(reverb_effect)},
|
||||
{"Wah", wah_effect, G_N_ELEMENTS(wah_effect)},
|
||||
{"Amplifier", amp_effect, G_N_ELEMENTS(amp_effect)},
|
||||
{"Equalizer", eq_effect, G_N_ELEMENTS(eq_effect)},
|
||||
{"Compressor", comp_effect, G_N_ELEMENTS(comp_effect)},
|
||||
{"Distortion", dist_effect, G_N_ELEMENTS(dist_effect)},
|
||||
{"Noisegate", noisegate_effect, G_N_ELEMENTS(noisegate_effect)},
|
||||
{"Chorus/FX", chorusfx_effect, G_N_ELEMENTS(chorusfx_effect)},
|
||||
{"Delay", delay_effect, G_N_ELEMENTS(delay_effect)},
|
||||
{"Reverb", reverb_effect, G_N_ELEMENTS(reverb_effect)},
|
||||
};
|
||||
|
||||
int n_effects = G_N_ELEMENTS(effects);
|
||||
|
||||
@@ -42,14 +42,15 @@ typedef struct {
|
||||
} EffectGroup;
|
||||
|
||||
typedef struct {
|
||||
gchar *label; /**< Base effect name */
|
||||
guint id; /**< ID (to set effect on/off) */
|
||||
gchar *label; /**< Group label */
|
||||
guint id; /**< ID to set effect on/off, or if it isn't on/off group then -1 */
|
||||
guint position; /**< position */
|
||||
EffectGroup *group; /**< possible effect types */
|
||||
gint group_amt; /**< possible effect types length */
|
||||
} Effect;
|
||||
|
||||
typedef struct {
|
||||
gchar *label; /**< base effect name */
|
||||
Effect *effect; /**< list of supported effects */
|
||||
gint amt; /**< list of supported effects length */
|
||||
} EffectList;
|
||||
|
||||
68
gui.c
68
gui.c
@@ -245,7 +245,7 @@ GtkWidget *create_table(EffectSettings *settings, gint amt)
|
||||
**/
|
||||
GtkWidget *create_on_off_button(Effect *effect)
|
||||
{
|
||||
GtkWidget *button = gtk_toggle_button_new_with_label(effect->label);
|
||||
GtkWidget *button = gtk_check_button_new();
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
|
||||
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggled_cb), effect);
|
||||
widget_list_add(GTK_OBJECT(button), effect->id, effect->position, -1, -1);
|
||||
@@ -266,11 +266,14 @@ typedef struct {
|
||||
**/
|
||||
void effect_settings_group_free(EffectSettingsGroup *group)
|
||||
{
|
||||
/* destroy widget without parent */
|
||||
if (gtk_widget_get_parent(group->child) == NULL)
|
||||
gtk_widget_destroy(group->child);
|
||||
if (group->child != NULL) {
|
||||
/* destroy widget without parent */
|
||||
if (gtk_widget_get_parent(group->child) == NULL)
|
||||
gtk_widget_destroy(group->child);
|
||||
|
||||
g_object_unref(group->child);
|
||||
}
|
||||
|
||||
g_object_unref(group->child);
|
||||
g_slice_free(EffectSettingsGroup, group);
|
||||
}
|
||||
|
||||
@@ -303,8 +306,11 @@ void combo_box_changed_cb(GtkComboBox *widget, gpointer data)
|
||||
if (child != NULL) {
|
||||
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(gtk_widget_get_parent(vbox))), child);
|
||||
}
|
||||
gtk_container_add(GTK_CONTAINER(gtk_widget_get_parent(gtk_widget_get_parent(vbox))), settings->child);
|
||||
gtk_widget_show_all(gtk_widget_get_parent(gtk_widget_get_parent(vbox)));
|
||||
|
||||
if (settings->child != NULL) {
|
||||
gtk_container_add(GTK_CONTAINER(gtk_widget_get_parent(gtk_widget_get_parent(vbox))), settings->child);
|
||||
gtk_widget_show_all(gtk_widget_get_parent(gtk_widget_get_parent(vbox)));
|
||||
}
|
||||
g_object_set_data(G_OBJECT(widget), "active_child", settings->child);
|
||||
}
|
||||
}
|
||||
@@ -340,14 +346,18 @@ GtkWidget *create_widget_container(EffectGroup *group, gint amt)
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), group[x].label);
|
||||
cmbox_no++;
|
||||
|
||||
widget = create_table(group[x].settings, group[x].settings_amt);
|
||||
g_object_ref_sink(widget);
|
||||
if ((group[x].settings != NULL) && (group[x].settings > 0)) {
|
||||
widget = create_table(group[x].settings, group[x].settings_amt);
|
||||
g_object_ref_sink(widget);
|
||||
} else
|
||||
widget = NULL;
|
||||
|
||||
settings = g_slice_new(EffectSettingsGroup);
|
||||
settings->id = group[x].id;
|
||||
settings->type = group[x].type;
|
||||
settings->position = group[x].position;
|
||||
settings->child = widget;
|
||||
|
||||
widget_list_add(GTK_OBJECT(combo_box), group[x].id, group[x].position, group[x].type, x);
|
||||
|
||||
name = g_strdup_printf("SettingsGroup%d", cmbox_no);
|
||||
@@ -365,34 +375,44 @@ GtkWidget *create_widget_container(EffectGroup *group, gint amt)
|
||||
/**
|
||||
* \param widgets Effect descriptions
|
||||
* \param amt amount of effect descriptions
|
||||
* \param label frame label (can be NULL)
|
||||
*
|
||||
* Creates vbox containing widgets allowing user to set effect options.
|
||||
* Creates frame (with optional label) containing widgets allowing user to set effect options.
|
||||
*
|
||||
* \return widget that allow user to set effect options.
|
||||
**/
|
||||
GtkWidget *create_vbox(Effect *widgets, gint amt)
|
||||
GtkWidget *create_vbox(Effect *widgets, gint amt, gchar *label)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *table;
|
||||
GtkWidget *container;
|
||||
GtkWidget *frame;
|
||||
int x;
|
||||
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
frame = gtk_frame_new(label);
|
||||
|
||||
gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE);
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
table = gtk_table_new(2, amt, FALSE);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(table), 2);
|
||||
|
||||
for (x = 0; x<amt; x++) {
|
||||
widget = create_on_off_button(&widgets[x]);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 2);
|
||||
if ((widgets[x].id != -1) && (widgets[x].position != -1)) {
|
||||
widget = create_on_off_button(&widgets[x]);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 1, x, x+1);
|
||||
} else if (widgets[x].label) {
|
||||
widget = gtk_label_new(widgets[x].label);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 1, x, x+1);
|
||||
}
|
||||
|
||||
table = create_widget_container(widgets[x].group, widgets[x].group_amt);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 2);
|
||||
container = create_widget_container(widgets[x].group, widgets[x].group_amt);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), container, 1, 2, x, x+1);
|
||||
}
|
||||
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 2);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
|
||||
return vbox;
|
||||
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
||||
return frame;
|
||||
}
|
||||
|
||||
enum {
|
||||
@@ -842,11 +862,11 @@ void gui_create()
|
||||
knob_anim = gtk_knob_animation_new_from_inline(knob_pixbuf);
|
||||
|
||||
for (x = 0; x<n_effects; x++) {
|
||||
if ((x % 3) == 0) {
|
||||
hbox = gtk_hbox_new(TRUE, 0);
|
||||
if ((x % ((n_effects+1)/2)) == 0) {
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 2);
|
||||
}
|
||||
widget = create_vbox(effects[x].effect, effects[x].amt);
|
||||
widget = create_vbox(effects[x].effect, effects[x].amt, effects[x].label);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user