repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / InfoView / LiveNodeInfoView.cpp
blob354eadd1b93374f1d7f43de4e563b32adf1dde62
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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"
35 // InfoView
36 #include "InfoWindowManager.h"
37 // NodeManager
38 #include "NodeGroup.h"
39 #include "NodeRef.h"
40 // Support
41 #include "MediaIcon.h"
42 #include "MediaString.h"
44 // Media Kit
45 #include <MediaNode.h>
47 // Interface Kit
48 #include <Window.h>
50 __USE_CORTEX_NAMESPACE
52 #include <Debug.h>
53 #define D_METHOD(x) //PRINT (x)
54 #define D_MESSAGE(x) //PRINT (x)
56 // -------------------------------------------------------- //
57 // *** ctor/dtor (public)
58 // -------------------------------------------------------- //
60 LiveNodeInfoView::LiveNodeInfoView(
61 const NodeRef *ref)
62 : InfoView(ref->name(), "Live Media Node",
63 new MediaIcon(ref->nodeInfo(), B_LARGE_ICON)),
64 m_nodeID(ref->id())
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
72 BString s;
73 s << ref->id();
74 addField("Node ID", s);
76 // add "Port" field
77 s = "";
78 s << ref->node().port;
79 port_info portInfo;
80 if (get_port_info(ref->node().port, &portInfo) == B_OK)
82 s << " (" << portInfo.name << ")";
84 addField("Port", s);
86 // add separator field
87 addField("", "");
89 // add "Kinds" 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());
94 if (runMode < 1)
96 NodeGroup *group = ref->group();
97 if (group)
99 runMode = group->runMode();
102 addField("Run Mode", MediaString::getStringFor(runMode));
104 // add "Latency" field
105 bigtime_t latency;
106 if (ref->totalLatency(&latency) == B_OK)
108 s = "";
109 if (latency > 0)
111 s << static_cast<float>(latency) / 1000.0f << " ms";
113 else
115 s = "?";
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();
134 if (manager) {
135 BMessage message(InfoWindowManager::M_LIVE_NODE_WINDOW_CLOSED);
136 message.AddInt32("nodeID", m_nodeID);
137 manager->PostMessage(&message);
141 // END -- LiveNodeInfoView.cpp --