static void midi_section_init(MidiSection* self) { MidiSectionPrivate* p = MIDI_SECTION_GET_PRIVATE(self); GtkBox* box = GTK_BOX(self); GtkWidget* pad; GtkWidget* view; GtkWidget* scroll; GnomeCanvas* canvas; GnomeCanvasPoints* points; int x1, x2, y1, y2; p->patch = -1; p->ignore = FALSE; x1 = 0; y1 = 0; x2 = (PHIN_KEYBOARD_KEY_WIDTH * MIDI_NOTES); y2 = HEIGHT; /* adjustment */ p->adj = (GtkAdjustment*) gtk_adjustment_new(0, 0, 0, 0, 0, 0); /* viewport */ view = gtk_viewport_new(p->adj, NULL); gtk_box_pack_start(box, view, FALSE, FALSE, 0); gtk_viewport_set_shadow_type(GTK_VIEWPORT(view), GTK_SHADOW_NONE); gtk_widget_set_size_request(view, 0, y2); gtk_widget_show(view); /* canvas */ canvas = (GnomeCanvas*) gnome_canvas_new(); gtk_widget_set_size_request(GTK_WIDGET(canvas), x2, y2); gnome_canvas_set_scroll_region(canvas, 0, 0, x2 - 1, y2 -1); gtk_container_add(GTK_CONTAINER(view), GTK_WIDGET(canvas)); g_signal_connect(G_OBJECT(canvas), "event", G_CALLBACK(range_cb), (gpointer)p); gtk_widget_show(GTK_WIDGET(canvas)); /* range display backdrop */ gnome_canvas_item_new(gnome_canvas_root(canvas), gnome_canvas_rect_get_type(), "x1", (gdouble)0, "y1", (gdouble)0, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", BG_COLOR, NULL); /* range */ p->range = gnome_canvas_item_new(gnome_canvas_root(canvas), gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)PHIN_KEYBOARD_KEY_WIDTH, "y2", (gdouble)y2, "fill-color-rgba", RANGE_COLOR, "outline-color", "black", NULL); gnome_canvas_item_hide(p->range); /* range root note */ p->note = gnome_canvas_item_new(gnome_canvas_root(canvas), gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)PHIN_KEYBOARD_KEY_WIDTH, "y2", (gdouble)y2, "fill-color-rgba", NOTE_COLOR, "outline-color", "black", NULL); gnome_canvas_item_hide(p->note); p->canvas = canvas; /* range display border */ points = gnome_canvas_points_new(4); points->coords[0] = x1; points->coords[1] = y2; points->coords[2] = x1; points->coords[3] = y1; points->coords[4] = x2-1; points->coords[5] = y1; points->coords[6] = x2-1; points->coords[7] = y2; gnome_canvas_item_new(gnome_canvas_root(canvas), gnome_canvas_line_get_type(), "points", points, "width-units", (gdouble)1, "fill-color-rgba", 0, NULL); gnome_canvas_points_unref(points); /* keyboard */ p->keyboard = phin_hkeyboard_new(p->adj, MIDI_NOTES, TRUE); gtk_box_pack_start(box, p->keyboard, FALSE, FALSE, 0); gtk_widget_show(p->keyboard); /* vpad */ pad = gui_vpad_new(GUI_SCROLLSPACE); gtk_box_pack_start(box, pad, FALSE, FALSE, 0); gtk_widget_show(pad); /* scrollbar */ scroll = gtk_hscrollbar_new(p->adj); gtk_box_pack_start(box, scroll, FALSE, FALSE, 0); gtk_widget_show(scroll); /* done */ connect(p); }
void float_section_set_float( FloatSection* self, PatchFloatType float_type) { FloatSectionPrivate* p = FLOAT_SECTION_GET_PRIVATE(self); GtkBox* box; GtkWidget* table; GtkTable* t; int y = 0; int a1 = 0, a2 = 1; int b1 = 1, b2 = 2; int c1 = 2, c2 = 3; float floatmin, floatmax, floatstep; const char* float_names[] = { "Portamento Time" }; box = GTK_BOX(self); p->float_type = float_type; switch(float_type) { case PATCH_FLOAT_PORTAMENTO_TIME: floatmin = 0.0; floatmax = 1.0; floatstep = 0.01; break; default: debug("Bad News! unknown float type!\n"); return; } gtk_container_set_border_width(GTK_CONTAINER(self), GUI_BORDERSPACE); table = gtk_table_new(3, 3, FALSE); t = (GtkTable*)table; gui_pack(box, table); gui_attach(t, gui_title_new(float_names[float_type]), a1, c2, y, y + 1); ++y; /* title padding */ gui_attach(t, gui_vpad_new(GUI_TITLESPACE), a1, c2, y, y + 1); ++y; /* label column spacing (of some description!?) */ gui_attach(t, gui_hpad_new(GUI_TEXTSPACE), c1, c2, y, y + 1); ++y; p->floatval = phin_hslider_new_with_range(0.0, floatmin, floatmax, floatstep); gui_attach(t, p->floatval, b1, b2, y, y + 1); ++y; gui_label_attach("Mod:", t, a1, a2, y, y + 1); p->mod_combo = mod_src_new_combo_with_cell(); mod_src_combo_set_model(GTK_COMBO_BOX(p->mod_combo), MOD_SRC_GLOBALS); gui_attach(t, p->mod_combo, b1, b2, y, y + 1); p->mod_amt = phin_hslider_new_with_range(0.0, -1.0, 1.0, 0.1); gui_attach(t, p->mod_amt, c1, c2, y, y + 1); ++y; g_signal_connect(G_OBJECT(p->floatval), "value-changed", G_CALLBACK(float_cb), (gpointer)p); g_signal_connect(G_OBJECT(p->mod_amt), "value-changed", G_CALLBACK(mod_amt_cb), (gpointer)p); g_signal_connect(G_OBJECT(p->mod_combo), "changed", G_CALLBACK(mod_combo_cb), (gpointer)p); }