1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2020 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSequencer is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __AGS_SCALE_H__
21 #define __AGS_SCALE_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <gtk/gtk.h>
27 
28 G_BEGIN_DECLS
29 
30 #define AGS_TYPE_SCALE                (ags_scale_get_type())
31 #define AGS_SCALE(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_SCALE, AgsScale))
32 #define AGS_SCALE_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_SCALE, AgsScaleClass))
33 #define AGS_IS_SCALE(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_SCALE))
34 #define AGS_IS_SCALE_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_SCALE))
35 #define AGS_SCALE_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS (obj, AGS_TYPE_SCALE, AgsScaleClass))
36 
37 #define AGS_SCALE_DEFAULT_SCALE_WIDTH (60)
38 #define AGS_SCALE_DEFAULT_SCALE_HEIGHT (128)
39 
40 #define AGS_SCALE_DEFAULT_LOWER (0.0)
41 #define AGS_SCALE_DEFAULT_UPPER (1.0)
42 #define AGS_SCALE_DEFAULT_VALUE (0.0)
43 
44 #define AGS_SCALE_DEFAULT_STEP_COUNT (16.0)
45 #define AGS_SCALE_DEFAULT_PAGE_SIZE (8.0)
46 
47 typedef struct _AgsScale AgsScale;
48 typedef struct _AgsScaleClass AgsScaleClass;
49 
50 typedef enum{
51   AGS_SCALE_LOGARITHMIC       = 1,
52 }AgsScaleFlags;
53 
54 typedef enum{
55   AGS_SCALE_BUTTON_1_PRESSED     = 1,
56 }AgsScaleButtonState;
57 
58 typedef enum{
59   AGS_SCALE_KEY_L_CONTROL       = 1,
60   AGS_SCALE_KEY_R_CONTROL       = 1 <<  1,
61   AGS_SCALE_KEY_L_SHIFT         = 1 <<  2,
62   AGS_SCALE_KEY_R_SHIFT         = 1 <<  3,
63 }AgsScaleKeyMask;
64 
65 typedef enum{
66   AGS_SCALE_LAYOUT_VERTICAL,
67   AGS_SCALE_LAYOUT_HORIZONTAL,
68 }AgsScaleLayout;
69 
70 typedef enum{
71   AGS_SCALE_STEP_UP,
72   AGS_SCALE_STEP_DOWN,
73   AGS_SCALE_PAGE_UP,
74   AGS_SCALE_PAGE_DOWN,
75 }AgsScaleAction;
76 
77 struct _AgsScale
78 {
79   GtkWidget widget;
80 
81   guint flags;
82 
83   guint key_mask;
84   guint button_state;
85   guint layout;
86 
87   guint font_size;
88 
89   guint scale_width;
90   guint scale_height;
91 
92   gchar *control_name;
93 
94   gdouble lower;
95   gdouble upper;
96 
97   gdouble default_value;
98 
99   guint step_count;
100   gdouble page_size;
101 
102   gint scale_step_count;
103   gchar **scale_point;
104   gdouble *scale_value;
105 };
106 
107 struct _AgsScaleClass
108 {
109   GtkWidgetClass widget;
110 
111   void (*value_changed)(AgsScale *scale,
112 			gdouble default_value);
113 };
114 
115 GType ags_scale_get_type(void);
116 
117 /* properties get/set */
118 void ags_scale_set_scale_width(AgsScale *scale,
119 			       guint scale_width);
120 guint ags_scale_get_scale_width(AgsScale *scale);
121 
122 void ags_scale_set_scale_height(AgsScale *scale,
123 				guint scale_height);
124 guint ags_scale_get_scale_height(AgsScale *scale);
125 
126 void ags_scale_set_control_name(AgsScale *scale,
127 				gchar *control_name);
128 gchar* ags_scale_get_control_name(AgsScale *scale);
129 
130 void ags_scale_set_upper(AgsScale *scale,
131 			 gdouble upper);
132 gdouble ags_scale_get_upper(AgsScale *scale);
133 
134 void ags_scale_set_lower(AgsScale *scale,
135 			 gdouble lower);
136 gdouble ags_scale_get_lower(AgsScale *scale);
137 
138 void ags_scale_set_default_value(AgsScale *scale,
139 				 gdouble default_value);
140 gdouble ags_scale_get_default_value(AgsScale *scale);
141 
142 /* signal */
143 void ags_scale_value_changed(AgsScale *scale,
144 			     gdouble default_value);
145 
146 /* instantiate */
147 AgsScale* ags_scale_new();
148 
149 G_END_DECLS
150 
151 #endif /*__AGS_SCALE_H__*/
152