---++!! !CommonCtrl.AutoHide %TOC{title="Contents:"}% %STARTINCLUDE% ---++ 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. <verbatim> CommonCtrl.AutoHide.EnableAutoHide(uiobj, {leave_interval=2, height=5}) </verbatim> 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. <verbatim> CommonCtrl.AutoHide.DisableAutoHide(uiobj) </verbatim> %T% __Sample Code__ <verbatim> 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}) </verbatim> ---+++ Member Functions ---++++ !AutoHide.EnableAutoHide <verbatim> define a new control in the common control libary local AutoHide = { pools = {}, error = "", print_error = commonlib.error, }</verbatim> CommonCtrl.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__ <verbatim>function AutoHide.EnableAutoHide(uiobj, params)</verbatim> __parameters__ | *uiobj* | | | *params* | | ---++++ !AutoHide.DisableAutoHide disable autohiding for a previously autohide enabled control. * _param_ __uiobject__ : a container which is attached to root. __syntax__ <verbatim>function AutoHide.DisableAutoHide(uiobj)</verbatim> __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__ <verbatim>function AutoHide.AdjustDetectorState(params, bVisible)</verbatim> __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__ <verbatim>function AutoHide.OnDetectorMouseEnter(id)</verbatim> __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__ <verbatim>function AutoHide.OnDetectorFrameMove(id)</verbatim> __parameters__ | *id* | | ---++++ !AutoHide.ToggleVisibility private: toggle visiblity. It will call the onshow call back. and set the visiblity of the base ui object. __syntax__ <verbatim>function AutoHide.ToggleVisibility(bShow, params)</verbatim> __parameters__ | *bShow* | | | *params* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback