Guitarix
gx_main_midi.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * ---------------------------------------------------------------------------
19 *
20 * This file is part of the guitarix GUI main class
21 * Note: this header file depends on gx_parameter.h
22 * and make use of the gx_engine namespace
23 *
24 * ----------------------------------------------------------------------------
25 */
26
27#pragma once
28
29#ifndef SRC_HEADERS_GX_MAIN_MIDI_H_
30#define SRC_HEADERS_GX_MAIN_MIDI_H_
31
32#ifndef SRC_HEADERS_GX_PARAMETER_H_
33#include "./gx_parameter.h"
34#endif
35
36#include <glibmm.h>
37#include <gtk/gtk.h>
38
39#include <iomanip>
40#include <cstring>
41#include <string>
42
43class ToggleAction; //FIXME
44
45namespace gx_main_midi {
46/****************************************************************
47 ** MidiControllerTable
48 */
49
50class MidiControllerTable: public sigc::trackable {
51 private:
53 static GtkWidget *window; // there can only be 1 window
54 GtkToggleButton *togglebutton;
55 GtkTreeSelection *selection;
56 GtkListStore *store;
57 Glib::RefPtr<ToggleAction> menuaction;
59 sigc::connection midi_conn;
60 static void response_cb(GtkWidget *widget, gint response_id, gpointer data);
61 static void edited_cb(GtkCellRendererText *renderer, gchar *path,
62 gchar *new_text, gpointer data);
63 static void destroy_cb(GtkWidget*, gpointer data);
64 static void toggleButtonSetSwitch(GtkWidget *w, gpointer data);
65 void set(bool v);
66 void load();
67 explicit MidiControllerTable(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
69 public:
70 static void toggle(gx_engine::GxMachineBase& machine, Glib::RefPtr<ToggleAction> item);
71};
72
73/*****************************************************************
74 ** Midi Control
75 */
76
78 private:
79 enum { RESPONSE_DELETE = 1 };
80 std::map<gx_engine::Parameter::toggle_type, const char*> toggle_behaviour_descriptions {
81 { gx_engine::Parameter::toggle_type::OnOff, "off /on states transition toggle" },
82 { gx_engine::Parameter::toggle_type::Constant, "constant state toggle" },
83 { gx_engine::Parameter::toggle_type::Toggle, "toggle state" },
84 { gx_engine::Parameter::toggle_type::Commander, "always toggle" }
85 };
86 GtkListStore* store;
90 GtkAdjustment* adj_lower;
91 GtkAdjustment* adj_upper;
92 GtkToggleButton *use_toggle;
93 //
94 GtkWidget* dialog;
95 GtkWidget* entry_new;
96 GtkWidget* label_desc;
98 static string ctr_desc(int ctr);
99 static const char *ctl_to_str(int n);
100 public:
102 static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data);
103 static void midi_destroy_cb(GtkWidget *widget, gpointer data);
104 static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data);
105 static gboolean check_midi_cb(gpointer);
106 static void changed_text_handler(GtkEditable *entry, gpointer data);
107};
108
109} // end namespace
110#endif // SRC_HEADERS_GX_MAIN_MIDI_H_
111
GtkAdjustment * adj_upper
Definition: gx_main_midi.h:91
static void toggle_behaviours_visibility(GtkWidget *widget, gpointer data)
static void midi_response_cb(GtkWidget *widget, gint response_id, gpointer data)
static void midi_destroy_cb(GtkWidget *widget, gpointer data)
gx_engine::Parameter & param
Definition: gx_main_midi.h:87
MidiConnect(GdkEventButton *event, gx_engine::Parameter &param, gx_engine::GxMachineBase &machine)
static const char * ctl_to_str(int n)
std::map< gx_engine::Parameter::toggle_type, const char * > toggle_behaviour_descriptions
Definition: gx_main_midi.h:80
gx_engine::GxMachineBase & machine
Definition: gx_main_midi.h:88
static void changed_text_handler(GtkEditable *entry, gpointer data)
static string ctr_desc(int ctr)
static gboolean check_midi_cb(gpointer)
GtkAdjustment * adj_lower
Definition: gx_main_midi.h:90
GtkWidget * toggle_behaviours
Definition: gx_main_midi.h:97
GtkToggleButton * use_toggle
Definition: gx_main_midi.h:92
MidiControllerTable(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
static void response_cb(GtkWidget *widget, gint response_id, gpointer data)
Glib::RefPtr< ToggleAction > menuaction
Definition: gx_main_midi.h:57
gx_engine::GxMachineBase & machine
Definition: gx_main_midi.h:58
static void edited_cb(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data)
static void toggle(gx_engine::GxMachineBase &machine, Glib::RefPtr< ToggleAction > item)
static void destroy_cb(GtkWidget *, gpointer data)
static void toggleButtonSetSwitch(GtkWidget *w, gpointer data)