CommonCtrl.AutoHide

It gives auto hide capability to any container one specifies.

Title It gives auto hide capability to any container one specifies.
Author(s) LiXizhi
Date 2008/6/7
File script/ide/AutoHide.lua

Description

It gives auto hide capability to any container one specifies. The idea is simple, a container autohides whenever a timer checks that the mouse is no longer on the container and there is no toplevel controls. A autohidden window will leave an invisible control at its original place to receive mouse enter messages. When it receives mouse enter message, it will show up the control again and start the timer to check mouse position every interval seconds.

Overview

There is only one function to call to enable autohiding for that container.
   CommonCtrl.AutoHide.EnableAutoHide(uiobj, {leave_interval=2, height=5})
The first parameter is a base UI container ParaUIObject which is usually attached to root. The second parameter is a table with the following fields. All fields are optional
name type description
leave_interval float how many seconds to wait before autohiding the base ui object when mouse is no longer on it. If nil, it is immediate.
enter_interval float (not implemented yet) how many seconds to wait before showing up the base ui object when mouse stays in the detector region. If nil, it is immediate.
ontoggle function it is an function(bShow, uiobj) end, it is called whenever the autohidden or showed up. One can usually play an animation at these times.
x int screen position x of the detector region. if nil, it is read from the current base ui object
y int screen position y of the detector region. if nil, it is read from the current base ui object
rx int relative to base ui object screen position x of the detector region. if nil, it is read from the current base ui object
ry int relative to base ui object screen position y of the detector region. if nil, it is read from the current base ui object
width int screen position width of the detector region. if nil, it is read from the current base ui object
height int screen position height of the detector region. if nil, it is read from the current base ui object
detector_zorder int z-order of the detector window, if nil, it will be set the same as the base ui object

To disable just call. It will remove all intermediate objects for autohidding.

   CommonCtrl.AutoHide.DisableAutoHide(uiobj)

TIP Sample Code

NPL.load("(gl)script/ide/AutoHide.lua");
CommonCtrl.AutoHide.EnableAutoHide(uiobj, {leave_interval=2, height=5})
CommonCtrl.AutoHide.DisableAutoHide(uiobj)
-- advanced version
CommonCtrl.AutoHide.EnableAutoHide(uiobj, {leave_interval=2, enter_interval=0, ontoggle=function(bShow, uiobj) end, x, y, width, height, rx, ry})

Member Functions

AutoHide.EnableAutoHide

 define a new control in the common control libary
local AutoHide = {
   pools = {}, 
   error = "",
   print_error = commonlib.error,  
}
AutoHide = AutoHide;

enable autohide to a level 1 control.

  • param uiobject : a container which is attached to root.
  • param params : a clean new table of {leave_interval=2, enter_interval=0, ontoggle=nil, onhide=nil, x, y, width, height, rx, ry}

syntax

function AutoHide.EnableAutoHide(uiobj, params)

parameters

uiobj  
params  

AutoHide.DisableAutoHide

disable autohiding for a previously autohide enabled control.

  • param uiobject : a container which is attached to root.

syntax

function AutoHide.DisableAutoHide(uiobj)

parameters

uiobj  

AutoHide.AdjustDetectorState

private: adjust detector state according to the visibility of the base ui object call this function whenever the visible property of the base uiobject changes.

  • param bVisible : if nil, the visible state of the base uiobject is used. otherwise this value is used.

syntax

function AutoHide.AdjustDetectorState(params, bVisible)

parameters

params  
bVisible if nil, the visible state of the base uiobject is used. otherwise this value is used.

AutoHide.OnDetectorMouseEnter

private: mouse enter function for all detectors. adjust the state

syntax

function AutoHide.OnDetectorMouseEnter(id)

parameters

id  

AutoHide.OnDetectorFrameMove

private: frame move function for all detectors. check if mouse is not on the uiobject. if so, autohide the base ui object and adjust detector state.

syntax

function AutoHide.OnDetectorFrameMove(id)

parameters

id  

AutoHide.ToggleVisibility

private: toggle visiblity. It will call the onshow call back. and set the visiblity of the base ui object.

syntax

function AutoHide.ToggleVisibility(bShow, params)

parameters

bShow  
params  
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback