File: main_window.h

package info (click to toggle)
abgate 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,100 kB
  • sloc: cpp: 1,474; makefile: 24
file content (116 lines) | stat: -rw-r--r-- 2,928 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* abGate - LV2 Noise Gate Plugin
 *
 * Copyright 2011 Antanas Bružas
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "plugin_configuration.h"
#include <lv2.h>
#include "ui.h"
#include <gtkmm/image.h>
#include <gtkmm/fixed.h>
#include <gtkmm/box.h>
#include <gtkmm/window.h>
#include <gtkmm/widget.h>
#include <gtkmm/eventbox.h>

#include "knob.h"
#include "toggle.h"
#include "gate_const.h"
//-----
#include "preset_widget.h"
//-------
using namespace sigc;
using namespace Gtk;

class main_window: public EventBox {

public:
	main_window();
	virtual ~main_window();

	// Presets
	//-------------------------------------------------------------------------
	void set_all(float th, float at, float ho, float de, float ra);
	void get_all(float &th, float &at, float &ho, float &de, float &ra);
	//-------------------------------------------------------------------------

	// Informing GUI about changes in the control ports
	void gui_port_event(LV2UI_Handle ui, uint32_t port_index, uint32_t buffer_size, uint32_t format, const void * buffer) {

		float val;
		val = *static_cast<const float*>(buffer);

		// Checking if params are the same as specified in the LV2 documentation
		if (format != 0) {
			return;
		}
		if (buffer_size != 4) {
			return;
		}

		// Updating values for GUI changes
		switch (port_index) {
		case p_switch:
			bypass->set_toggle_value(val);
			break;
		case p_threshold:
			threshold->set_knob_value(val);
			break;
		case p_attack:
			attack->set_knob_value(val);
			break;
		case p_hold:
			hold->set_knob_value(val);
			break;
		case p_decay:
			decay->set_knob_value(val);
			break;
		case p_gaterange:
			gaterange->set_knob_value(val);
			break;
		default:
			return;
		}
	}

	LV2UI_Controller controller;
	LV2UI_Write_Function write_function;

	void write_control(uint32_t port_index, float value);

private:
	float get_bypass();
	float get_closethr();
	float get_threshold();
	float get_attack();
	float get_hold();
	float get_decay();
	float get_gaterange();

	// Setting some bg params
	void bg();

	VBox main_box;
	Fixed button_fix;
	knob *threshold, *attack, *hold, *decay, *gaterange;
	toggle *bypass;

	// Presets
	//-----------------------
	preset_widget *m_presets;
	//-----------------------
};