source: trunk/gui/scripts/videochooser.tcl @ 2035

Last change on this file since 2035 was 2023, checked in by dkearney, 14 years ago

updates for video widgets
two new video dials
video chooser widget for selecting movies
video preview widget is a no frills movie player.
updated c code to more correctly report the last frame of the movie.
new video speed widget which allows for fractional values between 0x and 1.0x
updated piv/pve example application
fixed "release" function in tcl bindings for RpVideo?

File size: 4.2 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: videochooser - list videos
3#
4# ======================================================================
5#  AUTHOR:  Derrick Kearney, Purdue University
6#  Copyright (c) 2005-2010  Purdue Research Foundation
7#
8# See the file "license.terms" for information on usage and redistribution of
9# this file, and for a DISCLAIMER OF ALL WARRANTIES.
10# ======================================================================
11
12package require Itk
13package require BLT
14package require Img
15package require Rappture
16package require RapptureGUI
17
18itcl::class Rappture::VideoChooser {
19    inherit itk::Widget
20
21    itk_option define -width width Width 300
22    itk_option define -height height Height 300
23    itk_option define -variable variable Variable ""
24
25    constructor { args } {
26        # defined below
27    }
28    destructor {
29        # defined below
30    }
31
32    public method load {path}
33    public method choose {path}
34    protected method _fixSize {}
35
36    private variable _vcnt 0            ;# counter of videos
37    private variable _variable ""       ;# variable to pass along to each choice
38    private variable _objs ""           ;# list of choice objects
39}
40
41
42itk::usual VideoChooser {
43}
44
45# ----------------------------------------------------------------------
46# CONSTRUCTOR
47# ----------------------------------------------------------------------
48itcl::body Rappture::VideoChooser::constructor {args} {
49
50    itk_component add scroller {
51        Rappture::Scroller $itk_interior.scroller \
52            -xscrollmode auto \
53            -yscrollmode off \
54            -xscrollside bottom
55    }
56
57
58    $itk_component(scroller) contents frame
59
60
61    pack $itk_component(scroller) -fill both -expand yes
62
63    eval itk_initialize $args
64}
65
66# ----------------------------------------------------------------------
67# DESTRUCTOR
68# ----------------------------------------------------------------------
69itcl::body Rappture::VideoChooser::destructor {} {
70}
71
72# ----------------------------------------------------------------------
73# USAGE: load
74# ----------------------------------------------------------------------
75itcl::body Rappture::VideoChooser::load {paths} {
76
77    set f [$itk_component(scroller) contents]
78
79    foreach path $paths {
80        incr _vcnt
81
82        set ci [Rappture::VideoChooserInfo $f.vi${_vcnt} \
83                    -variable ${_variable}]
84        $ci load $path ""
85        pack $ci -expand yes -fill both -side right
86
87        # add the object to the list of video info objs
88        lappend _objs $ci
89    }
90
91    _fixSize
92}
93
94
95# ----------------------------------------------------------------------
96# USAGE: _fixSize
97# ----------------------------------------------------------------------
98itcl::body Rappture::VideoChooser::_fixSize {} {
99
100    # fix the dimesions of the canvas
101}
102
103# ----------------------------------------------------------------------
104# CONFIGURE: -variable
105# ----------------------------------------------------------------------
106itcl::configbody Rappture::VideoChooser::variable {
107    set _variable $itk_option(-variable)
108
109    if {"" != $_variable} {
110        upvar #0 $_variable var
111
112        foreach o ${_objs} {
113            # tell this object's children about the variable change
114            $o configure -variable $var
115        }
116    }
117}
118
119# ----------------------------------------------------------------------
120# OPTION: -width
121# ----------------------------------------------------------------------
122itcl::configbody Rappture::VideoChooser::width {
123    # $_dispatcher event -idle !fixsize
124    if {[string is integer $itk_option(-width)] == 0} {
125        error "bad value: \"$itk_option(-width)\": width should be an integer"
126    }
127    set _width $itk_option(-width)
128    after idle [itcl::code $this _fixSize]
129}
130
131# ----------------------------------------------------------------------
132# OPTION: -height
133# ----------------------------------------------------------------------
134itcl::configbody Rappture::VideoChooser::height {
135    # $_dispatcher event -idle !fixsize
136    if {[string is integer $itk_option(-height)] == 0} {
137        error "bad value: \"$itk_option(-height)\": height should be an integer"
138    }
139    set _height $itk_option(-height)
140    after idle [itcl::code $this _fixSize]
141}
Note: See TracBrowser for help on using the repository browser.