1 # ui-dc.tcl --
2 #
3 # Basic UI of the DC. Contains some helper functions.
4 #
5 # Copyright (c) 2000-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 import VisualFrame
32 import CDcUIThumbnailFrame
33 import CDcUIPreviewFrame
34 import CDcUIBroadcastFrame
35
36
37 Class CDcUI
38
39 CDcUI instproc init { appDc } {
40 # store away the dc application
41 $self instvar m_appDc
42 $self instvar m_frameRoot
43 $self instvar m_VisualFrame
44 $self instvar m_ColorModel
45 $self instvar m_uiThumbnailFrame
46 $self instvar m_uiPreviewFrame
47 $self instvar m_uiBroadcastFrame
48 $self instvar m_font
49
50 set m_appDc $appDc
51
52 set m_frameRoot 0
53 set m_VisualFrame 0
54 set m_ColorModel 0
55
56 set m_uiThumbnailFrame 0
57 set m_uiPreviewFrame 0
58 set m_uiBroadcastFrame 0
59
60 set m_font [[$self options] get_option smallfont]
61 }
62
63
64
65 CDcUI instproc build_ui { framePath } {
66 $self instvar m_frameRoot
67 $self instvar m_font
68 set f $m_font
69
70 set m_frameRoot $framePath
71
72 # create the orignal frame
73 pack [frame $m_frameRoot] -fill both -expand 1
74
75 # create the color model
76 $self instvar m_VisualFrame m_ColorModel
77
78 set m_VisualFrame [new VisualFrame $m_frameRoot.visual]
79 set m_ColorModel [$m_VisualFrame set colorModel_]
80
81 # need to create the major ui layout
82
83 # set the title of the window
84 wm title . "Director's Console"
85
86 # ok do the menu bar
87 menu $m_frameRoot.menu -type menubar
88 $self build_menu $m_frameRoot.menu
89 pack $m_frameRoot.menu -side top -fill x
90
91 # now the main frame
92 frame $m_frameRoot.frameMain -relief sunken -borderwidth 2
93 pack $m_frameRoot.frameMain -side top -fill both
94
95 $self build_main $m_frameRoot.frameMain
96
97 # now the title frame
98 frame $m_frameRoot.frameTitle -relief sunken -borderwidth 2
99 pack $m_frameRoot.frameTitle -side bottom -fill x
100
101 label $m_frameRoot.frameTitle.title -text "Director's Console" \
102 -relief ridge -font $f
103 pack $m_frameRoot.frameTitle.title -side left -fill both -expand 1
104
105 button $m_frameRoot.frameTitle.button -text "Quit" -command "exit" -font $f
106 pack $m_frameRoot.frameTitle.button -side left
107 }
108
109 CDcUI private build_menu { menu } {
110 $self instvar m_font
111 set f $m_font
112
113 $menu add cascade -label "File" -menu $menu.file -font $f
114 menu $menu.file
115 $menu.file add command -label "Properties..." -font $f
116
117 $menu.file add separator
118 $menu.file add command -label "Quit" -command "exit" -font $f
119
120 $menu add cascade -label "Help" -menu $menu.help -font $f
121 menu $menu.help
122 $menu.help add command -label "Help..." -font $f
123 $menu.help add command -label "About Director's Console..." -font $f
124 }
125
126 CDcUI private build_main { frameMain } {
127 $self instvar m_font
128 $self instvar m_appDc
129 $self instvar m_uiThumbnailFrame
130 $self instvar m_uiPreviewFrame
131 $self instvar m_uiBroadcastFrame
132 $self instvar m_framePV m_frameBC
133
134 set frameTN [frame $frameMain.thumbnailFrame -relief ridge -borderwidth 2]
135 pack $frameTN -side left -fill y
136 set m_uiThumbnailFrame [new CDcUIThumbnailFrame $m_appDc $self $frameTN]
137
138 set framePV [frame $frameMain.previewFrame -relief ridge -borderwidth 2]
139 set m_framePV $framePV
140 pack $framePV -side left -fill both
141 set m_uiPreviewFrame [new CDcUIPreviewFrame $m_appDc $self $framePV]
142
143 set frameBC [frame $frameMain.broadcastFrame -relief ridge -borderwidth 2]
144 set m_frameBC $frameBC
145 pack $frameBC -side left -fill y
146 set m_uiBroadcastFrame [new CDcUIBroadcastFrame $m_appDc $self $frameBC]
147 }
148
149 CDcUI public is_in_window { win x y } {
150 set top [winfo rooty $win]
151 set left [winfo rootx $win]
152 set bottom [expr $top + [winfo height $win] - 1]
153 set right [expr $left + [winfo width $win] - 1]
154
155 if { $y <= $bottom && $y >= $top && $x <= $right && $x >= $left } {
156 return 1
157 }
158
159 return 0
160 }
161
162
163 #-----------------------------------------------------------------------------
164 # Method:
165 # CDcUI reattach
166 #
167 # Arguments:
168 # src -- a Source/RTP object we want to show in the UI.
169 #
170 # Description:
171 # This goes through all the frames that display video, picks those that
172 # display the source, finds out their renderers, and tell the decoder to
173 # to send its output to the renderer.
174 #
175 # NOTE: This works only if the source is already being displayed, and
176 # we want to re-target the decoder due to some reasons, such as a format
177 # changed.
178 #
179 #-----------------------------------------------------------------------------
180 CDcUI public reattach { src } {
181 $self instvar m_ColorModel
182 $self instvar m_uiThumbnailFrame
183 $self instvar m_uiPreviewFrame
184 $self instvar m_uiBroadcastFrame
185
186 set decoder [$src set decoder_]
187 if {$decoder == ""} {
188 puts stderr "WARNING: no decoder for $src"
189 return
190 }
191
192 set thumbnail [$m_uiThumbnailFrame GetUIVideoWithSource $src]
193 if {$thumbnail != ""} {
194 set video_widget [$thumbnail GetVideoWidget]
195 $video_widget attach-decoder $src $m_ColorModel 0
196 }
197 set preview [$m_uiPreviewFrame GetUIVideoWithSource $src]
198 if {$preview != ""} {
199 set video_widget [$preview GetVideoWidget]
200 $video_widget attach-decoder $src $m_ColorModel 0
201 }
202 set broadcast [$m_uiBroadcastFrame GetUIVideoWithSource $src]
203 if {$broadcast != ""} {
204 set video_widget [$broadcast GetVideoWidget]
205 $video_widget attach-decoder $src $m_ColorModel 0
206 }
207 }
208
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.