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.
32 // LiveNodeInfoView.cpp
34 #include "LiveNodeInfoView.h"
36 #include "InfoWindowManager.h"
38 #include "NodeGroup.h"
41 #include "MediaIcon.h"
42 #include "MediaString.h"
45 #include <MediaNode.h>
50 __USE_CORTEX_NAMESPACE
53 #define D_METHOD(x) //PRINT (x)
54 #define D_MESSAGE(x) //PRINT (x)
56 // -------------------------------------------------------- //
57 // *** ctor/dtor (public)
58 // -------------------------------------------------------- //
60 LiveNodeInfoView::LiveNodeInfoView(
62 : InfoView(ref
->name(), "Live Media Node",
63 new MediaIcon(ref
->nodeInfo(), B_LARGE_ICON
)),
66 D_METHOD(("LiveNodeInfoView::LiveNodeInfoView()\n"));
68 // adjust view properties
69 setSideBarWidth(be_plain_font
->StringWidth(" Run Mode ") + 2 * InfoView::M_H_MARGIN
);
71 // add "Node ID" field
74 addField("Node ID", s
);
78 s
<< ref
->node().port
;
80 if (get_port_info(ref
->node().port
, &portInfo
) == B_OK
)
82 s
<< " (" << portInfo
.name
<< ")";
86 // add separator field
90 addField("Kinds", MediaString::getStringFor(static_cast<node_kind
>(ref
->kind())));
92 // add "Run Mode" field
93 BMediaNode::run_mode runMode
= static_cast<BMediaNode::run_mode
>(ref
->runMode());
96 NodeGroup
*group
= ref
->group();
99 runMode
= group
->runMode();
102 addField("Run Mode", MediaString::getStringFor(runMode
));
104 // add "Latency" field
106 if (ref
->totalLatency(&latency
) == B_OK
)
111 s
<< static_cast<float>(latency
) / 1000.0f
<< " ms";
117 addField("Latency", s
);
121 LiveNodeInfoView::~LiveNodeInfoView() {
122 D_METHOD(("LiveNodeInfoView::~LiveNodeInfoView()\n"));
126 // -------------------------------------------------------- //
127 // *** BView implementation (public)
128 // -------------------------------------------------------- //
130 void LiveNodeInfoView::DetachedFromWindow() {
131 D_METHOD(("LiveNodeInfoView::DetachedFromWindow()\n"));
133 InfoWindowManager
*manager
= InfoWindowManager::Instance();
135 BMessage
message(InfoWindowManager::M_LIVE_NODE_WINDOW_CLOSED
);
136 message
.AddInt32("nodeID", m_nodeID
);
137 manager
->PostMessage(&message
);
141 // END -- LiveNodeInfoView.cpp --