2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 // Provide a simple interface for the BeOS/Genki media system.
37 // Displays all the currently running ('live') media nodes,
38 // and represents the connections between them visually.
42 // *** 9oct99: replaced grid-based version
45 // e.moon 6may99: first stab
46 // c.lenz 6oct99: starting change to DiagramView impl
48 #ifndef __MediaRoutingView__H__
49 #define __MediaRoutingView__H__
52 #include "DiagramView.h"
55 #include "MediaDefs.h"
61 #include "IStateArchivable.h"
63 #include "cortex_defs.h"
64 __BEGIN_CORTEX_NAMESPACE
70 class RouteAppNodeManager
;
75 class NodeSetIOContext
;
77 class MediaRoutingView
:
79 public IStateArchivable
{
80 typedef DiagramView _inherited
;
82 public: // *** constants
84 // [e.moon 26oct99] moved definitions to MediaRoutingView.cpp
85 static float M_CLEANUP_H_GAP
;
86 static float M_CLEANUP_V_GAP
;
87 static float M_CLEANUP_H_MARGIN
;
88 static float M_CLEANUP_V_MARGIN
;
90 // [e.moon 7dec99] enum now a named type
101 // "layout" int32: M_ICON_VIEW / M_MINI_ICON_VIEW
108 // release/delete node
109 // "nodeID" [u]int32: node to release
119 // describes a selected node (sent to owning window)
124 // describes a selected group (sent to owning window)
129 // requests that the currently selected node/group be broadcast
130 // back to the owning window
131 M_BROADCAST_SELECTION
,
134 // request to change the selected nodes cycling mode (on/off)
136 M_NODE_CHANGE_CYCLING
,
139 // request to change the selected nodes run mode
141 M_NODE_CHANGE_RUN_MODE
,
144 // request to start/stop the selected node(s) as a time source
147 M_NODE_START_TIME_SOURCE
,
148 M_NODE_STOP_TIME_SOURCE
,
151 // call BControllable::StartControlPanel for the node specified
152 // in the field "nodeID" (int32)
154 M_NODE_START_CONTROL_PANEL
,
157 // set the given group's GROUP_LOCKED flag
164 // open ParameterWindow for selected nodes
165 // [c.lenz 17feb2000]
166 M_NODE_TWEAK_PARAMETERS
,
169 // sent to the RouteWindow for displaying error
170 // messages in the status bar if available
172 // "error" bool (optional)
176 public: // *** members
178 RouteAppNodeManager
* const manager
;
180 public: // *** ctor/dtor
183 RouteAppNodeManager
*nodeManager
,
186 uint32 resizeMode
= B_FOLLOW_ALL_SIDES
);
188 virtual ~MediaRoutingView();
190 public: // *** DiagramView impl
192 virtual void connectionAborted(
193 DiagramEndPoint
*fromWhich
);
195 virtual void connectionEstablished(
196 DiagramEndPoint
*fromWhich
,
197 DiagramEndPoint
*toWhich
);
199 DiagramWire
*createWire(
200 DiagramEndPoint
*fromWhich
,
201 DiagramEndPoint
*woWhich
);
203 DiagramWire
*createWire(
204 DiagramEndPoint
*fromWhich
);
206 virtual void BackgroundMouseDown(
211 virtual void MessageDropped(
215 virtual void SelectionChanged();
217 public: // *** BView impl
219 virtual void AttachedToWindow();
221 virtual void AllAttached();
223 virtual void DetachedFromWindow();
225 virtual void KeyDown(
229 virtual void Pulse();
231 public: // *** BHandler impl
233 virtual void MessageReceived(
236 public: // *** accessors
238 layout_t
getLayout() const
241 public: // *** operations
243 // returns coordinates for a free area where the panel
244 // could be positioned; uses the M_CLEANUP_* settings
245 // and positions producers at the left, consumer at the
246 // right and filters in the middle
247 BPoint
findFreePositionFor(
248 const MediaNodePanel
*panel
) const;
250 public: // *** IStateArchivable
252 status_t
importState(
253 const BMessage
* archive
);
255 status_t
exportState(
256 BMessage
* archive
) const;
258 // [e.moon 8dec99] subset support
259 status_t
importStateFor(
260 const NodeSetIOContext
* context
,
261 const BMessage
* archive
);
263 status_t
exportStateFor(
264 const NodeSetIOContext
* context
,
265 BMessage
* archive
) const;
267 protected: // *** operations
269 // adjust the default object sizes to the current
270 // layout and font size and rearrange if necessary
274 // aligns the panels on a grid according to their node_kind
277 // displays a context menu at a given position
278 void showContextMenu(
281 // will currently display a BAlert; this should change sometime
283 void showErrorMessage(
287 private: // *** children management
289 // adds a panel representation of a live media node to the view
290 status_t
_addPanelFor(
294 // tries to find the panel to a given media node
295 status_t
_findPanelFor(
297 MediaNodePanel
**outPanel
) const;
299 // removes the panel of a given media node
300 status_t
_removePanelFor(
303 // adds a wire represenation of a media kit connection
304 status_t
_addWireFor(
305 Connection
&connection
);
307 // finds the ui rep of a given Connection object
308 status_t
_findWireFor(
310 MediaWire
**wire
) const;
313 status_t
_removeWireFor(
314 uint32 connectionID
);
316 private: // *** internal methods
318 // iterates through all selected MediaNodePanels and sets the
319 // 'cycling' state for each to cycle
320 void _changeCyclingForSelection(
323 // iterates through all selected MediaNodePanels and sets the
324 // RunMode for each to mode; 0 is interpreted as '(same as group)'
325 void _changeRunModeForSelection(
328 void _openInfoWindowsForSelection();
330 void _openParameterWindowsForSelection();
332 void _startControlPanelsForSelection();
334 // tries to release every node in the current selection, or to
335 // disconnect wires if those were selected
336 void _deleteSelection();
338 void _addShortcuts();
342 // populates the view with all nodes currently in the NodeManager
345 void _checkDroppedFile(
349 void _changeBackground(
352 void _changeBackground(
355 // adjust scroll bar ranges
356 void _adjustScrollBars();
358 void _broadcastSelection() const;
360 // find & remove an entry in m_inactiveNodeState
361 status_t
_fetchInactiveNodeState(
362 MediaNodePanel
* forPanel
,
363 BMessage
* outMessage
);
365 void _emptyInactiveNodeState();
369 // the current layout
372 // current new-group-name index
373 uint32 m_nextGroupNumber
;
375 // holds the id of the node instantiated last thru d&d
376 media_node_id m_lastDroppedNode
;
378 // the point at which above node was dropped
379 BPoint m_lastDropPoint
;
381 // holds a pointer to the currently dragged wire (if any)
382 MediaWire
*m_draggedWire
;
384 // stores location of the background bitmap (invalid if no
385 // background bitmap has been set.)
387 BEntry m_backgroundBitmapEntry
;
389 // state info for currently inactive nodes (cached from importState())
390 BList m_inactiveNodeState
;
393 __END_CORTEX_NAMESPACE
394 #endif /* __MediaRoutingView_H__ */