Changeset 2067


Ignore:
Timestamp:
Jan 25, 2011, 10:39:36 PM (14 years ago)
Author:
dkearney
Message:

adding select function to mimic a button-1 press on a video from the video chooser.

Location:
trunk/gui/scripts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/videochooser.tcl

    r2023 r2067  
    3030    }
    3131
    32     public method load {path}
    33     public method choose {path}
     32    public method load {paths}
     33    public method select {id}
    3434    protected method _fixSize {}
    3535
    3636    private variable _vcnt 0            ;# counter of videos
    3737    private variable _variable ""       ;# variable to pass along to each choice
     38    private variable _paths ""          ;# list of choice paths
    3839    private variable _objs ""           ;# list of choice objects
    3940}
     
    8384                    -variable ${_variable}]
    8485        $ci load $path ""
    85         pack $ci -expand yes -fill both -side right
     86        pack $ci -expand yes -fill both -side left
    8687
    8788        # add the object to the list of video info objs
     89        lappend _paths $path
    8890        lappend _objs $ci
    8991    }
    9092
    9193    _fixSize
     94}
     95
     96# ----------------------------------------------------------------------
     97# USAGE: select
     98# ----------------------------------------------------------------------
     99itcl::body Rappture::VideoChooser::select {id} {
     100
     101    set obj ""
     102
     103    if {[string is integer $id] == 1} {
     104        # treat $id as the index
     105        if {($id < 0) && ($id >= [llength ${_objs}])} {
     106            error "invalid id \"$id\": must be in range 0 to [llength ${_objs}]"
     107        }
     108    } else {
     109        # treat $id as a file path
     110        set idx [lsearch -exact ${_paths} $id]
     111        if {$idx == -1} {
     112            error "invalid id \"$id\": not found in list of loaded objects"
     113        }
     114        set id $idx
     115    }
     116
     117    # grab the object associated with the id
     118    # and call it's select function.
     119    set obj [lindex ${_objs} $id]
     120    $obj select
    92121}
    93122
  • trunk/gui/scripts/videochooserinfo.tcl

    r2023 r2067  
    3232
    3333    public method load {path about}
     34    public method select {}
    3435    public method query {what}
    3536
     
    5960
    6061    itk_component add main {
    61         canvas $itk_interior.main \
    62             -background black
     62        canvas $itk_interior.main
    6363    } {
    6464        usual
     
    6868
    6969    blt::table $itk_interior \
    70         0,0 $itk_component(main) -fill both -padx 2
     70        0,0 $itk_component(main) -fill both -pady 2
    7171
    7272    blt::table configure $itk_interior c* -resize both
     
    9696
    9797    set movie [Rappture::Video file ${_path}]
    98     $movie seek 50
     98    $movie seek 60
    9999
    100100    set _preview [image create photo]
     
    115115
    116116    $itk_component(main) bind preview <ButtonPress-1> [itcl::code $this _bindings b1press]
     117    $itk_component(main) bind preview <Enter> [itcl::code $this _bindings enter]
     118    $itk_component(main) bind preview <Leave> [itcl::code $this _bindings leave]
    117119
    118120    _fixSize
    119121}
     122
     123# ----------------------------------------------------------------------
     124# USAGE: select
     125# ----------------------------------------------------------------------
     126itcl::body Rappture::VideoChooserInfo::select {} {
     127    if {"" == $_variable} {
     128        return
     129    }
     130    # send this object's movie to the preview window
     131
     132    upvar #0 $_variable var
     133    set var ${_path}
     134
     135    foreach {x0 y0 x1 y1} [$itk_component(main) bbox preview] break
     136    set x0 [expr 0]
     137    set y0 [expr 2]
     138    set x1 [expr [$itk_component(main) cget -width]-2]
     139    set y1 [expr [$itk_component(main) cget -height]-2]
     140
     141    # there is something wrong with the way we place the
     142    # images on the canvas, or how the canvas is shapeed.
     143    # the placement of the small image seems to be off
     144    # by a pixel or two. for now we fudge the numbers to
     145    # make the red line accesnts look decent.
     146
     147    $itk_component(main) create line $x0 $y0 $x1 $y0 \
     148        -fill red \
     149        -width 3 \
     150        -tags previewselected
     151
     152    $itk_component(main) create line $x0 $y1 $x1 $y1 \
     153        -fill red \
     154        -width 3 \
     155        -tags previewselected
     156
     157#    $itk_component(main) create rectangle \
     158        [$itk_component(main) bbox preview] \
     159        -outline red \
     160        -width 4 \
     161        -tags previewselected
     162#    $itk_component(main) configure -background red
     163}
     164
    120165
    121166# ----------------------------------------------------------------------
     
    125170    switch -- $sequence {
    126171        "b1press" {
    127             if {"" == $_variable} {
    128                 return
    129             }
    130             # send this object's movie to the preview window
    131 
    132             upvar #0 $_variable var
    133             set var ${_path}
    134             $itk_component(main) create rectangle \
    135                 [$itk_component(main) bbox preview] \
    136                 -outline red \
    137                 -width 4 \
    138                 -tags previewselected
    139 
     172            select
     173        }
     174        "enter" {
     175            $itk_component(main) itemconfigure previewselected -state hidden
     176        }
     177        "leave" {
     178            $itk_component(main) itemconfigure previewselected -state normal
    140179        }
    141180        default {}
     
    158197        # unselect this object
    159198        $itk_component(main) delete previewselected
     199        #$itk_component(main) configure -background black
    160200    }
    161201}
  • trunk/gui/scripts/videopreview.tcl

    r2035 r2067  
    333333    }
    334334
     335    if {![winfo ismapped $itk_component(hull)]} {
     336        return
     337    }
     338
    335339    set cw [winfo width $itk_component(main)]
    336340    set ch [winfo height $itk_component(main)]
  • trunk/gui/scripts/videoscreen.tcl

    r2035 r2067  
    595595
    596596    if {[string compare "" ${_movie}] == 0} {
     597        return
     598    }
     599
     600    if {![winfo ismapped $itk_component(hull)]} {
    597601        return
    598602    }
Note: See TracChangeset for help on using the changeset viewer.