Browse Source

show icons in highlight combo box

export_samplerate
Alexandros Theodotou 3 years ago
parent
commit
26fe746f3c
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 3
      inc/actions/actions.h
  2. 10
      resources/ui/editor_toolbar.ui
  3. 22
      src/actions/actions.c
  4. 4
      src/gui/backend/piano_roll.c
  5. 61
      src/gui/widgets/editor_toolbar.c
  6. 2
      src/gui/widgets/main_window.c
  7. 74
      src/plugins/lv2/lv2_gtk.c

3
inc/actions/actions.h

@ -489,6 +489,9 @@ DECLARE_SIMPLE (activate_remove_range); @@ -489,6 +489,9 @@ DECLARE_SIMPLE (activate_remove_range);
/* MIDI functions. */
DECLARE_SIMPLE (activate_midi_function);
DECLARE_SIMPLE (
activate_midi_editor_highlighting);
/**
* @}
*/

10
resources/ui/editor_toolbar.ui

@ -51,15 +51,9 @@ @@ -51,15 +51,9 @@
<object class="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkComboBoxText" id="chord_highlighting">
<object class="GtkComboBox"
id="chord_highlighting">
<property name="visible">1</property>
<property name="active-id">highlight_both</property>
<items>
<item translatable="yes" id="highlight_none">No Highlight</item>
<item translatable="yes" id="highlight_chord">Highlight Chord</item>
<item translatable="yes" id="highlight_scale">Highlight Scale</item>
<item translatable="yes" id="highlight_both">Highlight Both</item>
</items>
</object>
</child>
</object>

22
src/actions/actions.c

@ -2092,3 +2092,25 @@ DEFINE_SIMPLE (activate_midi_function) @@ -2092,3 +2092,25 @@ DEFINE_SIMPLE (activate_midi_function)
g_return_if_reached ();
}
}
DEFINE_SIMPLE (
activate_midi_editor_highlighting)
{
size_t size;
const char * str =
g_variant_get_string (variant, &size);
#define SET_HIGHLIGHT(txt,hl_type) \
if (string_is_equal (str, txt)) \
{ \
piano_roll_set_highlighting ( \
PIANO_ROLL, PR_HIGHLIGHT_##hl_type); \
}
SET_HIGHLIGHT ("none", NONE);
SET_HIGHLIGHT ("chord", CHORD);
SET_HIGHLIGHT ("scale", SCALE);
SET_HIGHLIGHT ("both", BOTH);
#undef SET_HIGHLIGHT
}

4
src/gui/backend/piano_roll.c

@ -276,8 +276,8 @@ piano_roll_set_highlighting ( @@ -276,8 +276,8 @@ piano_roll_set_highlighting (
S_UI, "piano-roll-highlight",
highlighting);
EVENTS_PUSH (ET_PIANO_ROLL_HIGHLIGHTING_CHANGED,
NULL);
EVENTS_PUSH (
ET_PIANO_ROLL_HIGHLIGHTING_CHANGED, NULL);
}
/**

61
src/gui/widgets/editor_toolbar.c

@ -75,6 +75,13 @@ editor_toolbar_widget_refresh ( @@ -75,6 +75,13 @@ editor_toolbar_widget_refresh (
g_free (tooltip_str);
}
typedef enum HighlightColumns
{
ICON_NAME_COL,
LABEL_COL,
ACTION_COL,
} HighlightColumns;
void
editor_toolbar_widget_setup (
EditorToolbarWidget * self)
@ -88,10 +95,60 @@ editor_toolbar_widget_setup ( @@ -88,10 +95,60 @@ editor_toolbar_widget_setup (
QUANTIZE_OPTIONS_EDITOR);
/* setup highlighting */
GtkTreeIter iter;
GtkListStore * list_store =
gtk_list_store_new (
3, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (
list_store, &iter,
0, "draw-highlight",
1, _("No Highlight"),
2, "highlight",
-1);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (
list_store, &iter,
0, "draw-highlight",
1, _("Highlight Chord"),
2, "chord",
-1);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (
list_store, &iter,
0, "draw-highlight",
1, _("Highlight Scale"),
2, "scale",
-1);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (
list_store, &iter,
0, "draw-highlight",
1, _("Highlight Both"),
2, "both",
-1);
GtkComboBox * combo =
GTK_COMBO_BOX (self->chord_highlighting);
gtk_combo_box_set_model (
combo,
GTK_TREE_MODEL (list_store));
gtk_combo_box_set_active (
GTK_COMBO_BOX (
self->chord_highlighting),
combo,
PIANO_ROLL->highlighting);
GtkCellRenderer * cell =
gtk_cell_renderer_pixbuf_new ();
gtk_cell_layout_pack_start (
GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (
GTK_CELL_LAYOUT (combo), cell,
"icon-name", ICON_NAME_COL, NULL);
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (
GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (
GTK_CELL_LAYOUT (combo), cell,
"text", LABEL_COL, NULL);
/* setup signals */
g_signal_connect (

2
src/gui/widgets/main_window.c

@ -494,6 +494,8 @@ main_window_widget_init (MainWindowWidget * self) @@ -494,6 +494,8 @@ main_window_widget_init (MainWindowWidget * self)
S_UI, "listen-notes") ?
"true" : "false",
change_state_listen_notes },
{ "midi-editor.highlighting",
activate_midi_editor_highlighting, "s" },
/* control room */
{ "toggle-dim-output", NULL, NULL,

74
src/plugins/lv2/lv2_gtk.c

@ -889,45 +889,61 @@ new_controller(GtkSpinButton* spin, GtkWidget* control) @@ -889,45 +889,61 @@ new_controller(GtkSpinButton* spin, GtkWidget* control)
}
static PluginGtkController*
make_combo(Lv2Control* record, float value)
make_combo (
Lv2Control * record,
float value)
{
GtkListStore* list_store = gtk_list_store_new(
2, G_TYPE_FLOAT, G_TYPE_STRING);
GtkListStore* list_store =
gtk_list_store_new (
2, G_TYPE_FLOAT, G_TYPE_STRING);
int active = -1;
for (size_t i = 0; i < record->n_points; ++i) {
const Lv2ScalePoint* point = &record->points[i];
GtkTreeIter iter;
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter,
0, point->value,
1, point->label,
-1);
if (fabs(value - point->value) < FLT_EPSILON) {
active = i;
for (size_t i = 0; i < record->n_points; ++i)
{
const Lv2ScalePoint * point =
&record->points[i];
GtkTreeIter iter;
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter,
0, point->value,
1, point->label,
-1);
if (fabs(value - point->value) < FLT_EPSILON)
{
active = i;
}
}
}
GtkWidget* combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list_store));
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), active);
g_object_unref(list_store);
GtkWidget* combo =
gtk_combo_box_new_with_model (
GTK_TREE_MODEL (list_store));
gtk_combo_box_set_active (
GTK_COMBO_BOX (combo), active);
g_object_unref (list_store);
gtk_widget_set_sensitive(combo, record->is_writable);
gtk_widget_set_sensitive (
combo, record->is_writable);
GtkCellRenderer* cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell, "text", 1, NULL);
GtkCellRenderer * cell =
gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (
GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (
GTK_CELL_LAYOUT (combo), cell, "text", 1, NULL);
if (record->is_writable) {
g_signal_connect (
G_OBJECT (combo), "changed",
G_CALLBACK (combo_changed), record);
}
if (record->is_writable)
{
g_signal_connect (
G_OBJECT (combo), "changed",
G_CALLBACK (combo_changed), record);
}
return new_controller(NULL, combo);
return new_controller (NULL, combo);
}
static PluginGtkController*
make_log_slider(Lv2Control* record, float value)
static PluginGtkController *
make_log_slider (
Lv2Control * record,
float value)
{
const float min =
lilv_get_float_from_node_with_fallback (

Loading…
Cancel
Save