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_NAVIGATION_H__
21 #define __AGS_NAVIGATION_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <gtk/gtk.h>
27 
28 #include <ags/libags.h>
29 #include <ags/libags-audio.h>
30 #include <ags/libags-gui.h>
31 
32 G_BEGIN_DECLS
33 
34 #define AGS_TYPE_NAVIGATION                (ags_navigation_get_type())
35 #define AGS_NAVIGATION(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_NAVIGATION, AgsNavigation))
36 #define AGS_NAVIGATION_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_NAVIGATION, AgsNavigationClass))
37 #define AGS_IS_NAVIGATION(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_NAVIGATION))
38 #define AGS_IS_NAVIGATION_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_NAVIGATION))
39 #define AGS_NAVIGATION_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_NAVIGATION, AgsNavigationClass))
40 
41 #define AGS_NAVIGATION_DEFAULT_TACT_STEP (1.0)
42 #define AGS_NAVIGATION_SEEK_STEPS (1.0)
43 #define AGS_NAVIGATION_REWIND_STEPS (4.0)
44 
45 typedef struct _AgsNavigation AgsNavigation;
46 typedef struct _AgsNavigationClass AgsNavigationClass;
47 
48 typedef enum{
49   AGS_NAVIGATION_CONNECTED    = 1,
50   AGS_NAVIGATION_BLOCK_TACT   = 1 << 1,
51   AGS_NAVIGATION_BLOCK_PLAY   = 1 << 2,
52   AGS_NAVIGATION_BLOCK_TIC    = 1 << 3,
53 }AgsNavigationFlags;
54 
55 struct _AgsNavigation
56 {
57   GtkBox box;
58 
59   guint flags;
60 
61   GObject *soundcard;
62   gdouble start_tact;
63   gdouble note_offset;
64 
65   GtkImage *expander_image;
66   GtkToggleButton *expander;
67 
68   GtkSpinButton *bpm;
69   gdouble current_bpm;
70 
71   GtkToggleButton *rewind;
72   GtkButton *previous;
73   GtkToggleButton *play;
74   GtkButton *stop;
75   GtkButton *next;
76   GtkToggleButton *forward;
77 
78   GtkCheckButton *loop;
79 
80   GtkLabel *position_time;
81   GtkSpinButton *position_tact;
82 
83   GtkLabel *duration_time;
84   GtkSpinButton *duration_tact;
85 
86   GtkSpinButton *loop_left_tact;
87   GtkSpinButton *loop_right_tact;
88 
89   GtkCheckButton *scroll;
90   GtkCheckButton *exclude_sequencer;
91 };
92 
93 struct _AgsNavigationClass
94 {
95   GtkBoxClass box;
96 
97   void (*change_position)(AgsNavigation *navigation,
98 			  gdouble tact);
99 };
100 
101 GType ags_navigation_get_type(void);
102 
103 gchar* ags_navigation_tact_to_time_string(gdouble tact,
104 					  gdouble bpm,
105 					  gdouble delay_factor);
106 
107 gchar* ags_navigation_relative_tact_to_time_string(gchar *timestr,
108 						   gdouble delay,
109 						   gdouble bpm,
110 						   gdouble delay_factor);
111 
112 gchar* ags_navigation_absolute_tact_to_time_string(gdouble tact,
113 						   gdouble bpm,
114 						   gdouble delay_factor);
115 
116 void ags_navigation_update_time_string(double tact,
117 				       gdouble bpm,
118 				       gdouble delay_factor,
119 				       gchar *time_string);
120 
121 void ags_navigation_set_seeking_sensitive(AgsNavigation *navigation,
122 					  gboolean enabled);
123 
124 void ags_navigation_change_position(AgsNavigation *navigation,
125 				    gdouble tact);
126 
127 gboolean ags_navigation_duration_time_queue_draw(GtkWidget *widget);
128 
129 AgsNavigation* ags_navigation_new();
130 
131 G_END_DECLS
132 
133 #endif /*__AGS_NAVIGATION_H__*/
134