Tuesday, November 03, 2020

gnocl::sticky - a minimal borderless window

 

Sometimes you just want to drop a small toolbar or widget holder on screen without all the decorations and controls. This code minimal minimal object is about as simple as it gets. 


proc gnocl::sticky { {orientation "horizontal"} } {
    if { [lsearch "vertical horizontal" $orientation] == -1 } { 
      return -code error \
      "Error! \"$orientation\" should be one of vertical or horizontal (default."  
    }   
    set box [gnocl::box -orientation $orientation \-borderWidth 0 -padding 0]
    set wid [gnocl::window -decorated 0 -child $box -height 25 -width 25]
    if { $orientation == "vertical"} { set tmp height} else {set tmp width}
    set eBox [gnocl::eventBox -borderWidth 0 -${tmp}Request 5 -background black]
    $eBox configure \
        -onButtonPress { %w configure -data "%x %y" -background red} \
        -onButtonRelease { %w configure -data "%x %y" -background black } \
        -onMotion { %t_ configure -x [expr %X - [lindex %d 0]] -y [expr %Y - [lindex %d 1]] }
    $box add $eBox -fill 1 -expand 0
    rename $wid ${wid}_
    # overload the basic window object
    proc $wid { cmd args } {      
        set wid [lindex [::info level 0] 0]   
        switch $cmd {
            remove -
            add { [${wid}_ cget -child] $cmd {*}$args }
            default { ${wid}_ $cmd {*}$args }
            }
    }
    return $wid
}

Sunday, November 01, 2020

October News


 

 

Just a few updates:


    gnocl::fixed
       o new option for move command, -align {x y} ; pair of floats (0-1.0) for positioning
    gnocl::pixBuf
       o new command getOrientation, returns either portrait or landscape
    gnocl::pointer
       o new command, get returns pointer screen x y coordinates
    gnocl::window
       o pointer command now has -screen option to return screen coordinates
    gnocl::toolBar
       o -iconSize and -style configure and cget fixed.
    gnocl::text
       o -shadow option now works properly (applied to scrolled window container).
       o search now has new option -wholeword <boolean> ; select between wholewords (1) and substring (0, default)
    gnocl::callback
        o new subcommands, prepend and append. Extend widget signal callback scripts.