1 /*
2  * Copyright (C) 2012 Hermann Meyer, Andreas Degert, Pete Shorthose, Steve Poskitt
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  * --------------------------------------------------------------------------
18  */
19 
20 #pragma once
21 
22 #ifndef SRC_HEADERS_WIDGET_H_
23 #define SRC_HEADERS_WIDGET_H_
24 
25 #include <gtkmm.h>
26 #include <gxwmm.h>
27 #include "gxtuner.h"
28 #include "../config.h" // for GX_STYLE_DIR
29 // LV2UI stuff
30 #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
31 
32 class Widget : public Gtk::HBox
33 {
34 private:
35   float reset;
36   bool refresh_meter_level(float new_level);
37   inline float power2db(float power);
38   inline double log_meter (double db);
39   Gtk::Widget* get_controller_by_port(uint32_t port_index);
40 
41   void on_value_changed(uint32_t port_index);
42   void set_tuning(float value);
43   void set_temperament();
44   void make_controller_box(Gtk::Box *box,
45                            Glib::ustring label,
46                            float min, float max,
47                            float digits,
48                            PortIndex port_name);
49 
50   void make_selector(Glib::ustring label,
51                      Glib::ustring tables[],
52                      size_t _size,
53                      float min, float digits,
54                      PortIndex port_name);
55 
56   void make_switch_box(Gtk::Box *box,
57                        Glib::ustring label,
58                        Glib::ustring label2,
59                        PortIndex port_name);
60   void  make_image(Gtk::Box *box,Glib::ustring label, bool start );
61   bool _draw(const Cairo::RefPtr<Cairo::Context> &cr);
62   void set_value(uint32_t port_index,
63                  uint32_t format,
64                  const void * buffer);
65 public:
66 
67   // public Lv2 communication stuff
68   LV2UI_Controller controller;
69   LV2UI_Write_Function write_function;
set_value_static(uint32_t port_index,uint32_t buffer_size,uint32_t format,const void * buffer,Widget * self)70   static void set_value_static(uint32_t port_index,
71                                uint32_t buffer_size,
72                                uint32_t format,
73                                const void * buffer, Widget *self)
74   {
75     self->set_value(port_index,format,buffer);
76   }
77 
78   Widget(Glib::ustring plugname);
79   ~Widget();
80 
81 protected:
82   Glib::ustring     plug_name;
83   Gtk::VBox         m_vbox_;
84   Gtk::VBox         m_vbox;
85   Gtk::VBox         m_vbox1;
86   Gtk::VBox         m_vbox2;
87   Gtk::VBox         m_vbox3;
88   Gtk::VBox         m_vbox4;
89   Gtk::VBox         m_vbox5;
90   Gtk::VBox         m_vbox6;
91   Gtk::VBox         m_vbox7;
92   Gtk::VBox         m_vbox8;
93   Gtk::VBox         m_vbox9;
94   Gtk::HBox         m_hbox_;
95   Gtk::HBox         m_hbox1_;
96   Gtk::HBox         m_hbox2_;
97   Gtk::HBox         m_hbox3_;
98   Gtk::HBox         m_hbox4_;
99   Gtk::HBox         m_hbox5_;
100   Gtk::HBox         m_hbox6_;
101   Gtk::HBox         m_hbox7_;
102   Gtk::Frame        m_fr1;
103   Gtk::Frame        m_fr2;
104 
105   Gxw::PaintBox     m_paintbox;
106   Gxw::PaintBox     m_paintbox1;
107   Gxw::PaintBox     m_paintbox2;
108   Gxw::HSlider      m_bigknob;
109   Gxw::HSlider      m_bigknob1;
110   Gxw::HSlider      m_bigknob2;
111   Gxw::HSlider      m_bigknob3;
112   Gxw::HSlider      m_bigknob4;
113   Gxw::RackTuner    m_tuner;
114   Gxw::Selector     tuner_tuning;
115   Gxw::Selector     tuner_temperament;
116   Gxw::Selector     select1;
117   Gxw::FastMeter    fastmeter;
118   Gxw::LevelSlider  levelslider;
119   Gxw::Switch       m_switch;
120   Gxw::Switch       m_switch1;
121   Gxw::Switch       m_switch2;
122   Gxw::Switch       m_switch3;
123 };
124 
125 #endif //SRC_HEADERS_WIDGET_H_
126