Jamoma API  0.6.0.a19
PureData/source/j.ui/j.ui.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationPdExternals
4  *
5  * @brief j.ui : Provide standard user interface component for modules
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius, Antoine Villeret
10  *
11  * @copyright © 2007 by Tim Place @n
12  * Copyright © 2015, Antoine Villeret@n
13  * This code is licensed under the terms of the "New BSD License" @n
14  * http://creativecommons.org/licenses/BSD/
15  */
16 
17 
18 #ifndef __J_UI__
19 #define __J_UI__
20 
21 /*
22 #include "ext.h"
23 #include "ext_obex.h"
24 #include "ext_user.h"
25 #include "ext_common.h"
26 #include "jpatcher_api.h" // jpatcher_api.h must come before z_dsp.h (in Jamoma.h)
27 #include "jgraphics.h"
28 */
29 
30 #include "TTModular.h" // Jamoma Modular API
31 #include "JamomaForPd.h" // Jamoma for Max
32 //#include "ext_symobject.h"
33 
34 #define NO_MODEL_STRING "waiting for a model:address"
35 
36 #define panel_out 0
37 
38 // those stuffes are needed for handling patchers without using the pcontrol object
39 // #include "jpatcher_api.h"
40 /*
41 typedef struct dll {
42  t_object d_ob;
43  struct dll *d_next;
44  struct dll *d_prev;
45  void *d_x1;
46 } t_dll;
47 
48 typedef struct outlet {
49  struct tinyobject o_ob;
50  struct dll *o_dll;
51 } t_outlet;
52 
53 typedef struct inlet {
54  struct tinyobject i_ob;
55  void *i_who;
56  struct object *i_owner;
57 } t_inlet;
58 */
59 
60 // members
61 typedef struct _ui{
62  t_ebox box;
63  TTHandle outlets;
64  TTObject uiInfo;
65  TTObject uiSubscriber; ///< internal TTSubscriber object to bind on the ui node
66  TTHashPtr hash_datas; ///< hash table of TTData
67  TTHashPtr hash_viewers; ///< hash table of TTViewer
68  TTHashPtr hash_receivers; ///< hash table of TTReceiver
69  TTObject modelMessExplorer; ///< internal TTExplorer object to observe messages
70  TTObject modelParamExplorer; ///< internal TTExplorer object to observe parameters
71  TTObject modelRetExplorer; ///< internal TTExplorer object to observe returns
72 
73  TTAddress viewAddress;
74  TTAddress modelAddress;
75  t_object *patcherPtr; ///< the patcher in which the external is (ignoring subpatcher)
76  TTSymbol patcherContext; ///< the patcher context in which the external is (model, view)
77  TTSymbol patcherClass; ///< the patcher class in which the external is
78  TTSymbol patcherName;
79 
80  TTBoolean hover; // is the mouse hover the j.ui panel ?
81  TTBoolean highlight; // is the user selecting things ?
82  TTBoolean highlightAll; // to highlight or not all j.remotes
83 
84  /*
85  t_jrgba bgcolor;
86  t_jrgba bordercolor;
87  t_jrgba headercolor;
88  t_jrgba textcolor;
89  t_jrgba highlightcolor;
90  */
91 
92  TTString *text; // the text of the editor to read after edclose
93  t_object *textEditor; // the text editor window
94  TTObject textHandler; ///< internal TTTextHandler to fill the max text editor
95  TTObject state; ///< internal TTPreset to get the current state of the binded model
96 
97  long ui_freeze; // freeze all viewers of the view
98 
99  t_jpopupmenu *menu; // model menu
100  void *menu_qelem; // ...
101  long menu_selection; // ...
102  t_linklist *menu_items; // ...
103  t_atom *preset_names;
104  long preset_num;
105 
106  t_jpopupmenu *refmenu; // reference menu
107  void *refmenu_qelem; // ...
108  long refmenu_selection; // ...
109  t_linklist *refmenu_items; // ...
110 
111  long has_preset; // is the binded model have preset features ?
112  long has_model; // is the binded model have model features ?
113 
114  long has_panel; // is the binded model have a panel ?
115  t_rect rect_panel;
116  t_object *patcher_panel;
117 
118  long has_meters; // is the binded model have meters ? (set number of meters, not just a toggle)
119  long is_metersdefeated;
120  t_rect rect_meters;
121 
122  long has_mute; // is the binded model have a mute ?
123  long is_muted;
124  bool highlight_mute; // selection state of mute
125  t_rect rect_mute;
126 
127  long has_bypass; // is the binded model have a bypass ?
128  long is_bypassed;
129  bool highlight_bypass; // selection state of bypass
130  t_rect rect_bypass;
131 
132  long has_freeze; // is the binded model have a freeze ?
133  long is_frozen;
134  bool highlight_freeze; // selection state of freeze
135  t_rect rect_freeze;
136 
137  long has_active; // is the binded model have a active ?
138  long is_active;
139  bool highlight_active; // selection state of active
140  t_rect rect_active;
141 
142  long has_gain; // is the binded model have a gain ?
143  float gain;
144  bool highlight_gain; // selection state of gain
145  t_rect rect_gain;
146  bool gainDragging;
147 
148  long has_mix; // is the binded model have a mix ?
149  float mix;
150  bool highlight_mix; // selection state of mix
151  t_rect rect_mix;
152  bool mixDragging;
153 
154  t_pt anchor; // used for dragging the dials
155  float anchorValue; // ...
156 } t_ui;
157 
158 // prototypes: general
159 t_ui *ui_new(t_symbol *s, long argc, t_atom *argv);
160 void ui_free(t_ui *x);
161 t_pd_err ui_notify(t_ui *x, t_symbol *s, t_symbol *msg, void *sender, void *data);
162 void ui_subscribe(t_ui *x, t_symbol *address);
163 void ui_build(t_ui *x);
164 t_object *ui_get_model_object(t_ui *x);
165 void ui_bang(t_ui *x);
166 
167 // prototypes: drawing/ui
168 void ui_paint(t_ui *x, t_object *view);
169 void ui_mousedown(t_ui *x, t_object *patcherview, t_pt pt, long modifiers);
170 void ui_mousedragdelta(t_ui *x, t_object *patcherview, t_pt pt, long modifiers);
171 void ui_mouseup(t_ui *x, t_object *patcherview);
172 void ui_mousemove(t_ui *x, t_object *patcherview, t_pt pt, long modifiers);
173 void ui_mouseleave(t_ui *x, t_object *patcherview, t_pt pt, long modifiers);
174 void *ui_oksize(t_ui *x, t_rect *rect);
175 void ui_preset_interface(t_ui *x);
176 void ui_paint_address(t_ui *x, t_object *textfield);
177 
178 // prototypes: menus
179 void ui_menu_do(t_ui *x, t_object *patcherview, t_pt px, long modifiers);
180 void ui_menu_qfn(t_ui *x);
181 void ui_menu_build(t_ui *x);
182 void ui_refmenu_do(t_ui *x, t_object *patcherview, t_pt px, long modifiers);
183 void ui_refmenu_qfn(t_ui *x);
184 void ui_refmenu_build(t_ui *x);
185 
186 // prototypes: TTUiInfo registration
187 void ui_register_info(t_ui* obj);
188 void ui_unregister_info(t_ui* obj);
189 
190 // prototypes: internal TTViewer
191 void ui_data_interface(t_ui *x, TTSymbol name);
192 
193 void ui_receiver_create(t_ui *obj, TTObject& returnedReceiver, t_symbol *aCallbackMethod, TTSymbol name, TTAddress address, TTBoolean deferlow = NO, TTBoolean appendNameAsAttribute = NO);
194 void ui_receiver_destroy_all(t_ui *obj);
195 
196 void ui_viewer_create(t_ui *obj, TTObject& returnedViewer, t_symbol *aCallbackMethod, TTSymbol name, TTAddress address, TTBoolean subscribe, TTBoolean deferlow = NO);
197 void ui_viewer_destroy(t_ui *obj, TTSymbol name);
198 void ui_viewer_destroy_all(t_ui *obj);
199 void ui_viewer_send(t_ui *obj, TTSymbol name, TTValue v);
200 void ui_viewer_highlight(t_ui *obj, TTSymbol name, TTBoolean s);
201 void ui_viewer_freeze(t_ui *obj, TTSymbol name, TTBoolean f);
202 
203 void ui_explorer_create(t_object *x, TTObject& returnedExplorer, t_symbol *method);
204 void ui_modelMessExplorer_callback(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
205 void ui_modelParamExplorer_callback(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
206 void ui_modelRetExplorer_callback(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
207 
208 void ui_view_panel_attach(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
209 
210 void ui_return_model_address(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
211 void ui_return_model_init(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
212 void ui_return_model_content(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
213 
214 void ui_return_mute(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
215 void ui_return_bypass(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
216 void ui_return_mix(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
217 void ui_return_gain(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
218 void ui_return_freeze(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
219 void ui_return_active(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
220 
221 // prototype : text editor
222 void ui_edit_state(t_ui *x);
223 void ui_edclose(t_ui *x, char **text, long size);
224 void ui_doedit(t_ui *x);
225 
226 // prototype: ui handling for preset features
227 void ui_return_preset_names(TTPtr self, t_symbol *msg, long argc, t_atom* argv);
228 
229 #endif // __J_UI__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Definition: TTAddress.h:29
Create and use Jamoma object instances.
Definition: TTObject.h:29
Various utilities for interfacing with Pd that are not specific to JamomaModular as such...
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
The TTString class is used to represent a string.
Definition: TTString.h:34
the Modular Application Programming Interface
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34