* Copyright (c) 1999-2000, Eric Moon.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MediaRoutingView__H__
#define __MediaRoutingView__H__
#include "DiagramView.h"
#include "MediaDefs.h"
#include <Entry.h>
#include <List.h>
#include <Message.h>
#include "IStateArchivable.h"
#include "cortex_defs.h"
__BEGIN_CORTEX_NAMESPACE
class MediaNodePanel;
class MediaWire;
class RouteAppNodeManager;
class NodeGroup;
class NodeRef;
class Connection;
class NodeSetIOContext;
class MediaRoutingView :
public DiagramView,
public IStateArchivable {
typedef DiagramView _inherited;
public:
static float M_CLEANUP_H_GAP;
static float M_CLEANUP_V_GAP;
static float M_CLEANUP_H_MARGIN;
static float M_CLEANUP_V_MARGIN;
enum layout_t
{
M_ICON_VIEW = 1,
M_MINI_ICON_VIEW
};
public:
enum message_t {
M_LAYOUT_CHANGED,
M_CLEANUP_REQUESTED,
M_RELEASE_NODE,
M_SELECT_ALL,
M_DELETE_SELECTION,
M_NODE_SELECTED,
M_GROUP_SELECTED,
M_BROADCAST_SELECTION,
M_NODE_CHANGE_CYCLING,
M_NODE_CHANGE_RUN_MODE,
M_NODE_START_TIME_SOURCE,
M_NODE_STOP_TIME_SOURCE,
M_NODE_START_CONTROL_PANEL,
M_GROUP_SET_LOCKED,
M_NODE_TWEAK_PARAMETERS,
M_SHOW_ERROR_MESSAGE
};
public:
RouteAppNodeManager* const manager;
public:
MediaRoutingView(
RouteAppNodeManager *nodeManager,
BRect frame,
const char *name,
uint32 resizeMode = B_FOLLOW_ALL_SIDES);
virtual ~MediaRoutingView();
public:
virtual void connectionAborted(
DiagramEndPoint *fromWhich);
virtual void connectionEstablished(
DiagramEndPoint *fromWhich,
DiagramEndPoint *toWhich);
DiagramWire *createWire(
DiagramEndPoint *fromWhich,
DiagramEndPoint *woWhich);
DiagramWire *createWire(
DiagramEndPoint *fromWhich);
virtual void BackgroundMouseDown(
BPoint point,
uint32 buttons,
uint32 clicks);
virtual void MessageDropped(
BPoint point,
BMessage *message);
virtual void SelectionChanged();
public:
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void KeyDown(
const char *bytes,
int32 count);
virtual void Pulse();
public:
virtual void MessageReceived(
BMessage *message);
public:
layout_t getLayout() const
{ return m_layout; }
public:
BPoint findFreePositionFor(
const MediaNodePanel *panel) const;
public:
status_t importState(
const BMessage* archive);
status_t exportState(
BMessage* archive) const;
status_t importStateFor(
const NodeSetIOContext* context,
const BMessage* archive);
status_t exportStateFor(
const NodeSetIOContext* context,
BMessage* archive) const;
protected:
void layoutChanged(
layout_t layout);
void cleanUp();
void showContextMenu(
BPoint point);
void showErrorMessage(
BString message,
status_t error);
private:
status_t _addPanelFor(
media_node_id id,
BPoint point);
status_t _findPanelFor(
media_node_id id,
MediaNodePanel **outPanel) const;
status_t _removePanelFor(
media_node_id);
status_t _addWireFor(
Connection &connection);
status_t _findWireFor(
uint32 connectionID,
MediaWire **wire) const;
status_t _removeWireFor(
uint32 connectionID);
private:
void _changeCyclingForSelection(
bool cycle);
void _changeRunModeForSelection(
uint32 mode);
void _openInfoWindowsForSelection();
void _openParameterWindowsForSelection();
void _startControlPanelsForSelection();
void _deleteSelection();
void _addShortcuts();
void _initLayout();
void _initContent();
void _checkDroppedFile(
entry_ref *ref,
BPoint dropPoint);
void _changeBackground(
entry_ref *ref);
void _changeBackground(
rgb_color color);
void _adjustScrollBars();
void _broadcastSelection() const;
status_t _fetchInactiveNodeState(
MediaNodePanel* forPanel,
BMessage* outMessage);
void _emptyInactiveNodeState();
private:
layout_t m_layout;
uint32 m_nextGroupNumber;
media_node_id m_lastDroppedNode;
BPoint m_lastDropPoint;
MediaWire *m_draggedWire;
BEntry m_backgroundBitmapEntry;
BList m_inactiveNodeState;
};
__END_CORTEX_NAMESPACE
#endif