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