Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
64a27c19
Commit
64a27c19
authored
Aug 06, 2005
by
Cyril Deguet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* all: use command objects in FSM instead of C-style callbacks
parent
f6fd8d49
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
324 additions
and
408 deletions
+324
-408
modules/gui/skins2/controls/ctrl_button.cpp
modules/gui/skins2/controls/ctrl_button.cpp
+42
-55
modules/gui/skins2/controls/ctrl_button.hpp
modules/gui/skins2/controls/ctrl_button.hpp
+10
-20
modules/gui/skins2/controls/ctrl_checkbox.cpp
modules/gui/skins2/controls/ctrl_checkbox.cpp
+42
-56
modules/gui/skins2/controls/ctrl_checkbox.hpp
modules/gui/skins2/controls/ctrl_checkbox.hpp
+11
-21
modules/gui/skins2/controls/ctrl_generic.hpp
modules/gui/skins2/controls/ctrl_generic.hpp
+18
-0
modules/gui/skins2/controls/ctrl_move.cpp
modules/gui/skins2/controls/ctrl_move.cpp
+19
-23
modules/gui/skins2/controls/ctrl_move.hpp
modules/gui/skins2/controls/ctrl_move.hpp
+7
-10
modules/gui/skins2/controls/ctrl_radialslider.cpp
modules/gui/skins2/controls/ctrl_radialslider.cpp
+11
-17
modules/gui/skins2/controls/ctrl_radialslider.hpp
modules/gui/skins2/controls/ctrl_radialslider.hpp
+4
-8
modules/gui/skins2/controls/ctrl_resize.cpp
modules/gui/skins2/controls/ctrl_resize.cpp
+38
-45
modules/gui/skins2/controls/ctrl_resize.hpp
modules/gui/skins2/controls/ctrl_resize.hpp
+8
-14
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/controls/ctrl_slider.cpp
+63
-72
modules/gui/skins2/controls/ctrl_slider.hpp
modules/gui/skins2/controls/ctrl_slider.hpp
+7
-14
modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/controls/ctrl_text.cpp
+32
-38
modules/gui/skins2/controls/ctrl_text.hpp
modules/gui/skins2/controls/ctrl_text.hpp
+6
-10
modules/gui/skins2/utils/fsm.cpp
modules/gui/skins2/utils/fsm.cpp
+3
-3
modules/gui/skins2/utils/fsm.hpp
modules/gui/skins2/utils/fsm.hpp
+3
-2
No files found.
modules/gui/skins2/controls/ctrl_button.cpp
View file @
64a27c19
...
...
@@ -37,15 +37,11 @@ CtrlButton::CtrlButton( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
VarBool
*
pVisible
)
:
CtrlGeneric
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_rCommand
(
rCommand
),
m_tooltip
(
rTooltip
),
m_cmdUpOverDownOver
(
this
,
&
transUpOverDownOver
),
m_cmdDownOverUpOver
(
this
,
&
transDownOverUpOver
),
m_cmdDownOverDown
(
this
,
&
transDownOverDown
),
m_cmdDownDownOver
(
this
,
&
transDownDownOver
),
m_cmdUpOverUp
(
this
,
&
transUpOverUp
),
m_cmdUpUpOver
(
this
,
&
transUpUpOver
),
m_cmdDownUp
(
this
,
&
transDownUp
),
m_cmdUpHidden
(
this
,
&
transUpHidden
),
m_cmdHiddenUp
(
this
,
&
transHiddenUp
)
m_cmdUpOverDownOver
(
pIntf
,
this
),
m_cmdDownOverUpOver
(
pIntf
,
this
),
m_cmdDownOverDown
(
pIntf
,
this
),
m_cmdDownDownOver
(
pIntf
,
this
),
m_cmdUpOverUp
(
pIntf
,
this
),
m_cmdUpUpOver
(
pIntf
,
this
),
m_cmdDownUp
(
pIntf
,
this
),
m_cmdUpHidden
(
pIntf
,
this
),
m_cmdHiddenUp
(
pIntf
,
this
)
{
// Build the images of the button
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pIntf
);
...
...
@@ -129,85 +125,76 @@ void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest )
}
void
CtrlButton
::
transUpOverDownOver
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdUpOverDownOver
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
pThis
->
captureMouse
();
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgDown
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
m_pControl
->
captureMouse
();
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgDown
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transDownOverUpOver
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdDownOverUpOver
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
pThis
->
releaseMouse
();
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
m_pControl
->
releaseMouse
();
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
// Execute the command associated to this button
pThis
->
m_rCommand
.
execute
();
m_pControl
->
m_rCommand
.
execute
();
}
void
CtrlButton
::
transDownOverDown
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdDownOverDown
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transDownDownOver
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdDownDownOver
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgDown
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgDown
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transUpUpOver
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdUpUpOver
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgOver
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgOver
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transUpOverUp
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdUpOverUp
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transDownUp
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdDownUp
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
}
void
CtrlButton
::
transUpHidden
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdUpHidden
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
NULL
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
NULL
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
void
CtrlButton
::
transHiddenUp
(
SkinObject
*
pCtrl
)
void
CtrlButton
::
CmdHiddenUp
::
execute
(
)
{
CtrlButton
*
pThis
=
(
CtrlButton
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImg
;
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImg
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImg
;
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImg
);
}
modules/gui/skins2/controls/ctrl_button.hpp
View file @
64a27c19
...
...
@@ -68,31 +68,21 @@ class CtrlButton: public CtrlGeneric
CmdGeneric
&
m_rCommand
;
/// Tooltip text
const
UString
m_tooltip
;
/// Callbacks objects
Callback
m_cmdUpOverDownOver
;
Callback
m_cmdDownOverUpOver
;
Callback
m_cmdDownOverDown
;
Callback
m_cmdDownDownOver
;
Callback
m_cmdUpOverUp
;
Callback
m_cmdUpUpOver
;
Callback
m_cmdDownUp
;
Callback
m_cmdUpHidden
;
Callback
m_cmdHiddenUp
;
/// Images of the button in the different states
OSGraphics
*
m_pImgUp
,
*
m_pImgOver
,
*
m_pImgDown
;
/// Current image
OSGraphics
*
m_pImg
;
/// Callback
function
s
static
void
transUpOverDownOver
(
SkinObject
*
pCtrl
);
static
void
transDownOverUpOver
(
SkinObject
*
pCtrl
);
static
void
transDownOverDown
(
SkinObject
*
pCtrl
);
static
void
transDownDownOver
(
SkinObject
*
pCtrl
);
static
void
transUpOverUp
(
SkinObject
*
pCtrl
);
static
void
transUpUpOver
(
SkinObject
*
pCtrl
);
static
void
transDownUp
(
SkinObject
*
pCtrl
);
static
void
transUpHidden
(
SkinObject
*
pCtrl
);
static
void
transHiddenUp
(
SkinObject
*
pCtrl
);
/// Callback
object
s
DEFINE_CALLBACK
(
CtrlButton
,
UpOverDownOver
)
DEFINE_CALLBACK
(
CtrlButton
,
DownOverUpOver
)
DEFINE_CALLBACK
(
CtrlButton
,
DownOverDown
)
DEFINE_CALLBACK
(
CtrlButton
,
DownDownOver
)
DEFINE_CALLBACK
(
CtrlButton
,
UpOverUp
)
DEFINE_CALLBACK
(
CtrlButton
,
UpUpOver
)
DEFINE_CALLBACK
(
CtrlButton
,
DownUp
)
DEFINE_CALLBACK
(
CtrlButton
,
UpHidden
)
DEFINE_CALLBACK
(
CtrlButton
,
HiddenUp
)
};
...
...
modules/gui/skins2/controls/ctrl_checkbox.cpp
View file @
64a27c19
...
...
@@ -47,15 +47,11 @@ CtrlCheckbox::CtrlCheckbox( intf_thread_t *pIntf,
m_rVariable
(
rVariable
),
m_rCommand1
(
rCommand1
),
m_rCommand2
(
rCommand2
),
m_tooltip1
(
rTooltip1
),
m_tooltip2
(
rTooltip2
),
m_cmdUpOverDownOver
(
this
,
&
transUpOverDownOver
),
m_cmdDownOverUpOver
(
this
,
&
transDownOverUpOver
),
m_cmdDownOverDown
(
this
,
&
transDownOverDown
),
m_cmdDownDownOver
(
this
,
&
transDownDownOver
),
m_cmdUpOverUp
(
this
,
&
transUpOverUp
),
m_cmdUpUpOver
(
this
,
&
transUpUpOver
),
m_cmdDownUp
(
this
,
&
transDownUp
),
m_cmdUpHidden
(
this
,
&
transUpHidden
),
m_cmdHiddenUp
(
this
,
&
transHiddenUp
)
m_cmdUpOverDownOver
(
pIntf
,
this
),
m_cmdDownOverUpOver
(
pIntf
,
this
),
m_cmdDownOverDown
(
pIntf
,
this
),
m_cmdDownDownOver
(
pIntf
,
this
),
m_cmdUpOverUp
(
pIntf
,
this
),
m_cmdUpUpOver
(
pIntf
,
this
),
m_cmdDownUp
(
pIntf
,
this
),
m_cmdUpHidden
(
pIntf
,
this
),
m_cmdHiddenUp
(
pIntf
,
this
)
{
// Build the images of the checkbox
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pIntf
);
...
...
@@ -173,89 +169,80 @@ void CtrlCheckbox::draw( OSGraphics &rImage, int xDest, int yDest )
}
void
CtrlCheckbox
::
transUpOverDownOver
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdUpOverDownOver
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
pThis
->
captureMouse
();
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgDown
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
m_pControl
->
captureMouse
();
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgDown
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transDownOverUpOver
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdDownOverUpOver
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
// Invert the state variable
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
// Execute the command
pThis
->
m_pCommand
->
execute
();
m_pControl
->
m_pCommand
->
execute
();
}
void
CtrlCheckbox
::
transDownOverDown
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdDownOverDown
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transDownDownOver
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdDownDownOver
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgDown
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgDown
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transUpUpOver
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdUpUpOver
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgOver
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgOver
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transUpOverUp
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdUpOverUp
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transDownUp
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdDownUp
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
}
void
CtrlCheckbox
::
transUpHidden
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdUpHidden
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
NULL
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
NULL
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
void
CtrlCheckbox
::
transHiddenUp
(
SkinObject
*
pCtrl
)
void
CtrlCheckbox
::
CmdHiddenUp
::
execute
(
)
{
CtrlCheckbox
*
pThis
=
(
CtrlCheckbox
*
)
pCtrl
;
const
OSGraphics
*
pOldImg
=
pThis
->
m_pImgCurrent
;
pThis
->
m_pImgCurrent
=
pThis
->
m_pImgUp
;
pThis
->
notifyLayoutMaxSize
(
pOldImg
,
pThis
->
m_pImgCurrent
);
const
OSGraphics
*
pOldImg
=
m_pControl
->
m_pImgCurrent
;
m_pControl
->
m_pImgCurrent
=
m_pControl
->
m_pImgUp
;
m_pControl
->
notifyLayoutMaxSize
(
pOldImg
,
m_pControl
->
m_pImgCurrent
);
}
...
...
@@ -292,4 +279,3 @@ void CtrlCheckbox::changeButton()
// Refresh
notifyLayout
();
}
modules/gui/skins2/controls/ctrl_checkbox.hpp
View file @
64a27c19
...
...
@@ -81,17 +81,7 @@ class CtrlCheckbox: public CtrlGeneric
const
UString
m_tooltip1
,
m_tooltip2
;
/// Current tooltip
const
UString
*
m_pTooltip
;
/// Callbacks objects
Callback
m_cmdUpOverDownOver
;
Callback
m_cmdDownOverUpOver
;
Callback
m_cmdDownOverDown
;
Callback
m_cmdDownDownOver
;
Callback
m_cmdUpOverUp
;
Callback
m_cmdUpUpOver
;
Callback
m_cmdDownUp
;
Callback
m_cmdUpHidden
;
Callback
m_cmdHiddenUp
;
/// Images of the checkbox in the different states
/// Images of the checkbox in the different states
OSGraphics
*
m_pImgUp1
,
*
m_pImgOver1
,
*
m_pImgDown1
;
OSGraphics
*
m_pImgUp2
,
*
m_pImgOver2
,
*
m_pImgDown2
;
/// Current set of images (pointing to 1 or 2)
...
...
@@ -103,16 +93,16 @@ class CtrlCheckbox: public CtrlGeneric
/// Current image
OSGraphics
*
m_pImgCurrent
;
/// Callback
function
s
static
void
transUpOverDownOver
(
SkinObject
*
pCtrl
);
static
void
transDownOverUpOver
(
SkinObject
*
pCtrl
);
static
void
transDownOverDown
(
SkinObject
*
pCtrl
);
static
void
transDownDownOver
(
SkinObject
*
pCtrl
);
static
void
transUpOverUp
(
SkinObject
*
pCtrl
);
static
void
transUpUpOver
(
SkinObject
*
pCtrl
);
static
void
transDownUp
(
SkinObject
*
pCtrl
);
static
void
transUpHidden
(
SkinObject
*
pCtrl
);
static
void
transHiddenUp
(
SkinObject
*
pCtrl
);
/// Callback
object
s
DEFINE_CALLBACK
(
CtrlCheckbox
,
UpOverDownOver
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
DownOverUpOver
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
DownOverDown
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
DownDownOver
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
UpOverUp
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
UpUpOver
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
DownUp
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
UpHidden
)
DEFINE_CALLBACK
(
CtrlCheckbox
,
HiddenUp
)
/// Method called when the observed variable is modified
virtual
void
onVarBoolUpdate
(
VarBool
&
rVariable
);
...
...
modules/gui/skins2/controls/ctrl_generic.hpp
View file @
64a27c19
...
...
@@ -30,6 +30,7 @@
#include "../utils/fsm.hpp"
#include "../utils/ustring.hpp"
#include "../utils/observer.hpp"
#include "../commands/cmd_generic.hpp"
class
EvtGeneric
;
class
OSGraphics
;
...
...
@@ -133,4 +134,21 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
typedef
CountedPtr
<
CtrlGeneric
>
CtrlGenericPtr
;
// Macro to define a control action command
#define DEFINE_CALLBACK( control, action ) \
class Cmd##action: public CmdGeneric \
{ \
public: \
Cmd##action( intf_thread_t *pIntf, control *pControl ): \
CmdGeneric( pIntf ), m_pControl( pControl) {} \
virtual ~Cmd##action() {} \
virtual void execute(); \
virtual string getType() const { return "Cmd" #control #action; } \
private: \
control *m_pControl; \
\
} m_cmd##action; \
friend class Cmd##action;
#endif
modules/gui/skins2/controls/ctrl_move.cpp
View file @
64a27c19
...
...
@@ -37,9 +37,9 @@ CtrlMove::CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
CtrlFlat
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_rWindowManager
(
rWindowManager
),
m_rCtrl
(
rCtrl
),
m_rWindow
(
rWindow
),
m_cmdMovingMoving
(
this
,
&
transMovingMoving
),
m_cmdStillMoving
(
this
,
&
transStillMoving
),
m_cmdMovingStill
(
this
,
&
transMovingStill
)
m_cmdMovingMoving
(
pIntf
,
this
),
m_cmdStillMoving
(
pIntf
,
this
),
m_cmdMovingStill
(
pIntf
,
this
)
{
m_pEvt
=
NULL
;
m_xPos
=
0
;
...
...
@@ -96,39 +96,35 @@ void CtrlMove::handleEvent( EvtGeneric &rEvent )
}
void
CtrlMove
::
transStillMoving
(
SkinObject
*
pCtrl
)
void
CtrlMove
::
CmdStillMoving
::
execute
(
)
{
CtrlMove
*
pThis
=
(
CtrlMove
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
pThis
->
m_xPos
=
pEvtMouse
->
getXPos
();
pThis
->
m_yPos
=
pEvtMouse
->
getYPos
();
m_pControl
->
m_xPos
=
pEvtMouse
->
getXPos
();
m_pControl
->
m_yPos
=
pEvtMouse
->
getYPos
();
pThis
->
captureMouse
();
m_pControl
->
captureMouse
();
pThis
->
m_rWindowManager
.
startMove
(
pThis
->
m_rWindow
);
m_pControl
->
m_rWindowManager
.
startMove
(
m_pControl
->
m_rWindow
);
}
void
CtrlMove
::
transMovingMoving
(
SkinObject
*
pCtrl
)
void
CtrlMove
::
CmdMovingMoving
::
execute
(
)
{
CtrlMove
*
pThis
=
(
CtrlMove
*
)
pCtrl
;
EvtMotion
*
pEvtMotion
=
(
EvtMotion
*
)
pThis
->
m_pEvt
;
EvtMotion
*
pEvtMotion
=
(
EvtMotion
*
)
m_pControl
->
m_pEvt
;
int
xNewLeft
=
pEvtMotion
->
getXPos
()
-
pThis
->
m_xPos
+
pThis
->
m_rWindow
.
getLeft
();
int
yNewTop
=
pEvtMotion
->
getYPos
()
-
pThis
->
m_yPos
+
pThis
->
m_rWindow
.
getTop
();
int
xNewLeft
=
pEvtMotion
->
getXPos
()
-
m_pControl
->
m_xPos
+
m_pControl
->
m_rWindow
.
getLeft
();
int
yNewTop
=
pEvtMotion
->
getYPos
()
-
m_pControl
->
m_yPos
+
m_pControl
->
m_rWindow
.
getTop
();
pThis
->
m_rWindowManager
.
move
(
pThis
->
m_rWindow
,
xNewLeft
,
yNewTop
);
m_pControl
->
m_rWindowManager
.
move
(
m_pControl
->
m_rWindow
,
xNewLeft
,
yNewTop
);
}
void
CtrlMove
::
transMovingStill
(
SkinObject
*
pCtrl
)
void
CtrlMove
::
CmdMovingStill
::
execute
(
)
{
CtrlMove
*
pThis
=
(
CtrlMove
*
)
pCtrl
;
m_pControl
->
releaseMouse
()
;
pThis
->
releaseMouse
();
pThis
->
m_rWindowManager
.
stopMove
();
m_pControl
->
m_rWindowManager
.
stopMove
();
}
modules/gui/skins2/controls/ctrl_move.hpp
View file @
64a27c19
...
...
@@ -58,11 +58,7 @@ class CtrlMove: public CtrlFlat
/// Get the position of the decorated control in the layout, if any
virtual
const
Position
*
getPosition
()
const
;
static
void
transMovingMoving
(
SkinObject
*
pCtrl
);
static
void
transStillMoving
(
SkinObject
*
pCtrl
);
static
void
transMovingStill
(
SkinObject
*
pCtrl
);
/// Get the type of control (custom RTTI)
/// Get the type of control (custom RTTI)
virtual
string
getType
()
const
{
return
m_rCtrl
.
getType
();
}
private:
...
...
@@ -77,10 +73,11 @@ class CtrlMove: public CtrlFlat
EvtGeneric
*
m_pEvt
;
/// Position of the click that started the move
int
m_xPos
,
m_yPos
;
/// Callbacks
Callback
m_cmdMovingMoving
;
Callback
m_cmdStillMoving
;
Callback
m_cmdMovingStill
;
};
/// Callback objects
DEFINE_CALLBACK
(
CtrlMove
,
MovingMoving
)
DEFINE_CALLBACK
(
CtrlMove
,
StillMoving
)
DEFINE_CALLBACK
(
CtrlMove
,
MovingStill
)
};
#endif
modules/gui/skins2/controls/ctrl_radialslider.cpp
View file @
64a27c19
...
...
@@ -40,8 +40,8 @@ CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
VarBool
*
pVisible
)
:
CtrlGeneric
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_numImg
(
numImg
),
m_rVariable
(
rVariable
),
m_minAngle
(
minAngle
),
m_maxAngle
(
maxAngle
),
m_cmdUpDown
(
this
,
&
transUpDown
),
m_cmdDownUp
(
this
,
&
transDownUp
),
m_cmdMove
(
this
,
&
transMove
),
m_position
(
0
),
m_lastPos
(
0
)
m_cmdUpDown
(
pIntf
,
this
),
m_cmdDownUp
(
pIntf
,
this
),
m_cmdMove
(
pIntf
,
this
)
{
// Build the images of the sequence
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
getIntf
()
);
...
...
@@ -105,35 +105,29 @@ void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable )
}
void
CtrlRadialSlider
::
transUpDown
(
SkinObject
*
pCtrl
)
void
CtrlRadialSlider
::
CmdUpDown
::
execute
(
)
{
CtrlRadialSlider
*
pThis
=
(
CtrlRadialSlider
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Change the position of the cursor, in non-blocking mode
pThis
->
setCursor
(
pEvtMouse
->
getXPos
(),
pEvtMouse
->
getYPos
(),
false
);
m_pControl
->
setCursor
(
pEvtMouse
->
getXPos
(),
pEvtMouse
->
getYPos
(),
false
);
pThis
->
captureMouse
();
m_pControl
->
captureMouse
();
}
void
CtrlRadialSlider
::
transDownUp
(
SkinObject
*
pCtrl
)
void
CtrlRadialSlider
::
CmdDownUp
::
execute
(
)
{
CtrlRadialSlider
*
pThis
=
(
CtrlRadialSlider
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
}
void
CtrlRadialSlider
::
transMove
(
SkinObject
*
pCtrl
)
void
CtrlRadialSlider
::
CmdMove
::
execute
(
)
{
CtrlRadialSlider
*
pThis
=
(
CtrlRadialSlider
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Change the position of the cursor, in blocking mode
pThis
->
setCursor
(
pEvtMouse
->
getXPos
(),
pEvtMouse
->
getYPos
(),
true
);
m_pControl
->
setCursor
(
pEvtMouse
->
getXPos
(),
pEvtMouse
->
getYPos
(),
true
);
}
...
...
modules/gui/skins2/controls/ctrl_radialslider.hpp
View file @
64a27c19
...
...
@@ -69,10 +69,6 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
VarPercent
&
m_rVariable
;
/// Min and max angles of the button
float
m_minAngle
,
m_maxAngle
;
/// Callbacks objects
Callback
m_cmdUpDown
;
Callback
m_cmdDownUp
;
Callback
m_cmdMove
;
/// Position of the cursor
int
m_position
;
/// Size of an image
...
...
@@ -84,10 +80,10 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
/// Last saved position
int
m_lastPos
;
/// Callback
function
s
static
void
transUpDown
(
SkinObject
*
pCtrl
);
static
void
transDownUp
(
SkinObject
*
pCtrl
);
static
void
transMove
(
SkinObject
*
pCtrl
);
/// Callback
object
s
DEFINE_CALLBACK
(
CtrlRadialSlider
,
UpDown
)
DEFINE_CALLBACK
(
CtrlRadialSlider
,
DownUp
)
DEFINE_CALLBACK
(
CtrlRadialSlider
,
Move
)
/// Method called when the observed variable is modified
virtual
void
onUpdate
(
Subject
<
VarPercent
>
&
rVariable
);
...
...
modules/gui/skins2/controls/ctrl_resize.cpp
View file @
64a27c19
...
...
@@ -37,12 +37,12 @@ CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
GenericLayout
&
rLayout
,
const
UString
&
rHelp
,
VarBool
*
pVisible
)
:
CtrlFlat
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_rCtrl
(
rCtrl
),
m_rLayout
(
rLayout
),
m_cmdOutStill
(
this
,
&
transOutStill
),
m_cmdStillOut
(
this
,
&
transStillOut
),
m_cmdStillStill
(
this
,
&
transStillStill
),
m_cmdStillResize
(
this
,
&
transStillResize
),
m_cmdResizeStill
(
this
,
&
transResizeStill
),
m_cmdResizeResize
(
this
,
&
transResizeResize
)
m_rLayout
(
rLayout
),
m_cmdOutStill
(
pIntf
,
this
),
m_cmdStillOut
(
pIntf
,
this
),
m_cmdStillStill
(
pIntf
,
this
),
m_cmdStillResize
(
pIntf
,
this
),
m_cmdResizeStill
(
pIntf
,
this
),
m_cmdResizeResize
(
pIntf
,
this
)
{
m_pEvt
=
NULL
;
m_xPos
=
0
;
...
...
@@ -103,96 +103,89 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
}
void
CtrlResize
::
transOutStill
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdOutStill
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kResizeNWSE
);
}
void
CtrlResize
::
transStillOut
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdStillOut
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kDefaultArrow
);
}
void
CtrlResize
::
transStillStill
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdStillStill
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kResizeNWSE
);
}
void
CtrlResize
::
transStillResize
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdStillResize
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Set the cursor
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kResizeNWSE
);
pThis
->
m_xPos
=
pEvtMouse
->
getXPos
();
pThis
->
m_yPos
=
pEvtMouse
->
getYPos
();
m_pControl
->
m_xPos
=
pEvtMouse
->
getXPos
();
m_pControl
->
m_yPos
=
pEvtMouse
->
getYPos
();
pThis
->
captureMouse
();
m_pControl
->
captureMouse
();
pThis
->
m_width
=
pThis
->
m_rLayout
.
getWidth
();
pThis
->
m_height
=
pThis
->
m_rLayout
.
getHeight
();
m_pControl
->
m_width
=
m_pControl
->
m_rLayout
.
getWidth
();
m_pControl
->
m_height
=
m_pControl
->
m_rLayout
.
getHeight
();
}
void
CtrlResize
::
transResizeStill
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdResizeStill
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
// Set the cursor
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kResizeNWSE
);
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
}
void
CtrlResize
::
transResizeResize
(
SkinObject
*
pCtrl
)
void
CtrlResize
::
CmdResizeResize
::
execute
(
)
{
CtrlResize
*
pThis
=
(
CtrlResize
*
)
pCtrl
;
EvtMotion
*
pEvtMotion
=
(
EvtMotion
*
)
pThis
->
m_pEvt
;
EvtMotion
*
pEvtMotion
=
(
EvtMotion
*
)
m_pControl
->
m_pEvt
;
// Set the cursor
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
pThis
->
getIntf
()
);
OSFactory
*
pOsFactory
=
OSFactory
::
instance
(
m_pControl
->
getIntf
()
);
pOsFactory
->
changeCursor
(
OSFactory
::
kResizeNWSE
);
int
newWidth
=
pEvtMotion
->
getXPos
()
-
pThis
->
m_xPos
+
pThis
->
m_width
;
int
newHeight
=
pEvtMotion
->
getYPos
()
-
pThis
->
m_yPos
+
pThis
->
m_height
;
int
newWidth
=
pEvtMotion
->
getXPos
()
-
m_pControl
->
m_xPos
+
m_pControl
->
m_width
;
int
newHeight
=
pEvtMotion
->
getYPos
()
-
m_pControl
->
m_yPos
+
m_pControl
->
m_height
;
// Check boundaries
if
(
newWidth
<
pThis
->
m_rLayout
.
getMinWidth
()
)
if
(
newWidth
<
m_pControl
->
m_rLayout
.
getMinWidth
()
)
{
newWidth
=
pThis
->
m_rLayout
.
getMinWidth
();
newWidth
=
m_pControl
->
m_rLayout
.
getMinWidth
();
}
if
(
newWidth
>
pThis
->
m_rLayout
.
getMaxWidth
()
)
if
(
newWidth
>
m_pControl
->
m_rLayout
.
getMaxWidth
()
)
{
newWidth
=
pThis
->
m_rLayout
.
getMaxWidth
();
newWidth
=
m_pControl
->
m_rLayout
.
getMaxWidth
();
}
if
(
newHeight
<
pThis
->
m_rLayout
.
getMinHeight
()
)
if
(
newHeight
<
m_pControl
->
m_rLayout
.
getMinHeight
()
)
{
newHeight
=
pThis
->
m_rLayout
.
getMinHeight
();
newHeight
=
m_pControl
->
m_rLayout
.
getMinHeight
();
}
if
(
newHeight
>
pThis
->
m_rLayout
.
getMaxHeight
()
)
if
(
newHeight
>
m_pControl
->
m_rLayout
.
getMaxHeight
()
)
{
newHeight
=
pThis
->
m_rLayout
.
getMaxHeight
();
newHeight
=
m_pControl
->
m_rLayout
.
getMaxHeight
();
}
// Create a resize command
CmdGeneric
*
pCmd
=
new
CmdResize
(
pThis
->
getIntf
(),
pThis
->
m_rLayout
,
CmdGeneric
*
pCmd
=
new
CmdResize
(
m_pControl
->
getIntf
(),
m_pControl
->
m_rLayout
,
newWidth
,
newHeight
);
// Push the command in the asynchronous command queue
AsyncQueue
*
pQueue
=
AsyncQueue
::
instance
(
pThis
->
getIntf
()
);
AsyncQueue
*
pQueue
=
AsyncQueue
::
instance
(
m_pControl
->
getIntf
()
);
pQueue
->
remove
(
"resize"
);
pQueue
->
push
(
CmdGenericPtr
(
pCmd
)
);
}
modules/gui/skins2/controls/ctrl_resize.hpp
View file @
64a27c19
...
...
@@ -57,13 +57,6 @@ class CtrlResize: public CtrlFlat
/// Get the position of the decorated control in the layout, if any
virtual
const
Position
*
getPosition
()
const
;
static
void
transOutStill
(
SkinObject
*
pCtrl
);
static
void
transStillOut
(
SkinObject
*
pCtrl
);
static
void
transStillStill
(
SkinObject
*
pCtrl
);
static
void
transStillResize
(
SkinObject
*
pCtrl
);
static
void
transResizeStill
(
SkinObject
*
pCtrl
);
static
void
transResizeResize
(
SkinObject
*
pCtrl
);
/// Get the type of control (custom RTTI)
virtual
string
getType
()
const
{
return
m_rCtrl
.
getType
();
}
...
...
@@ -77,13 +70,14 @@ class CtrlResize: public CtrlFlat
EvtGeneric
*
m_pEvt
;
/// Position of the click that started the resizing
int
m_xPos
,
m_yPos
;
/// Callbacks
Callback
m_cmdOutStill
;
Callback
m_cmdStillOut
;
Callback
m_cmdStillStill
;
Callback
m_cmdStillResize
;
Callback
m_cmdResizeStill
;
Callback
m_cmdResizeResize
;
/// Callback objects
DEFINE_CALLBACK
(
CtrlResize
,
OutStill
)
DEFINE_CALLBACK
(
CtrlResize
,
StillOut
)
DEFINE_CALLBACK
(
CtrlResize
,
StillStill
)
DEFINE_CALLBACK
(
CtrlResize
,
StillResize
)
DEFINE_CALLBACK
(
CtrlResize
,
ResizeStill
)
DEFINE_CALLBACK
(
CtrlResize
,
ResizeResize
)
// Size of the layout, before resizing
int
m_width
,
m_height
;
...
...
modules/gui/skins2/controls/ctrl_slider.cpp
View file @
64a27c19
...
...
@@ -50,10 +50,10 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
CtrlGeneric
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_rVariable
(
rVariable
),
m_tooltip
(
rTooltip
),
m_width
(
rCurve
.
getWidth
()
),
m_height
(
rCurve
.
getHeight
()
),
m_cmdOverDown
(
this
,
&
transOverDown
),
m_cmd
DownOver
(
this
,
&
transDownOver
),
m_cmdOverUp
(
this
,
&
transOverUp
),
m_cmd
UpOver
(
this
,
&
transUpOver
),
m_cmdMove
(
this
,
&
transMove
),
m_cmdScroll
(
this
,
&
transScroll
),
m_cmdOverDown
(
pIntf
,
this
),
m_cmdDownOver
(
pIntf
,
this
),
m_cmd
OverUp
(
pIntf
,
this
),
m_cmdUpOver
(
pIntf
,
this
),
m_cmd
Move
(
pIntf
,
this
),
m_cmdScroll
(
pIntf
,
this
),
m_lastPercentage
(
0
),
m_xOffset
(
0
),
m_yOffset
(
0
),
m_pEvt
(
NULL
),
m_rCurve
(
rCurve
)
{
...
...
@@ -175,139 +175,130 @@ void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
}
void
CtrlSliderCursor
::
transOverDown
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdOverDown
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Compute the resize factors
float
factorX
,
factorY
;
pThis
->
getResizeFactors
(
factorX
,
factorY
);
m_pControl
->
getResizeFactors
(
factorX
,
factorY
);
// Get the position of the control
const
Position
*
pPos
=
pThis
->
getPosition
();
const
Position
*
pPos
=
m_pControl
->
getPosition
();
// Compute the offset
int
tempX
,
tempY
;
pThis
->
m_rCurve
.
getPoint
(
pThis
->
m_rVariable
.
get
(),
tempX
,
tempY
);
pThis
->
m_xOffset
=
pEvtMouse
->
getXPos
()
-
pPos
->
getLeft
()
m_pControl
->
m_rCurve
.
getPoint
(
m_pControl
->
m_rVariable
.
get
(),
tempX
,
tempY
);
m_pControl
->
m_xOffset
=
pEvtMouse
->
getXPos
()
-
pPos
->
getLeft
()
-
(
int
)(
tempX
*
factorX
);
pThis
->
m_yOffset
=
pEvtMouse
->
getYPos
()
-
pPos
->
getTop
()
m_pControl
->
m_yOffset
=
pEvtMouse
->
getYPos
()
-
pPos
->
getTop
()
-
(
int
)(
tempY
*
factorY
);
pThis
->
captureMouse
();
pThis
->
m_pImg
=
pThis
->
m_pImgDown
;
if
(
pThis
->
m_pImg
)
m_pControl
->
captureMouse
();
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgDown
;
if
(
m_pControl
->
m_pImg
)
{
pThis
->
notifyLayout
(
pThis
->
m_rCurve
.
getWidth
()
+
pThis
->
m_pImg
->
getWidth
(),
pThis
->
m_rCurve
.
getHeight
()
+
pThis
->
m_pImg
->
getHeight
(),
-
pThis
->
m_pImg
->
getWidth
()
/
2
,
-
pThis
->
m_pImg
->
getHeight
()
/
2
);
m_pControl
->
notifyLayout
(
m_pControl
->
m_rCurve
.
getWidth
()
+
m_pControl
->
m_pImg
->
getWidth
(),
m_pControl
->
m_rCurve
.
getHeight
()
+
m_pControl
->
m_pImg
->
getHeight
(),
-
m_pControl
->
m_pImg
->
getWidth
()
/
2
,
-
m_pControl
->
m_pImg
->
getHeight
()
/
2
);
}
else
pThis
->
notifyLayout
();
m_pControl
->
notifyLayout
();
}
void
CtrlSliderCursor
::
transDownOver
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdDownOver
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
// Save the position
pThis
->
m_lastPercentage
=
pThis
->
m_rVariable
.
get
();
m_pControl
->
m_lastPercentage
=
m_pControl
->
m_rVariable
.
get
();
pThis
->
releaseMouse
();
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
if
(
pThis
->
m_pImg
)
m_pControl
->
releaseMouse
();
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
if
(
m_pControl
->
m_pImg
)
{
pThis
->
notifyLayout
(
pThis
->
m_rCurve
.
getWidth
()
+
pThis
->
m_pImg
->
getWidth
(),
pThis
->
m_rCurve
.
getHeight
()
+
pThis
->
m_pImg
->
getHeight
(),
-
pThis
->
m_pImg
->
getWidth
()
/
2
,
-
pThis
->
m_pImg
->
getHeight
()
/
2
);
m_pControl
->
notifyLayout
(
m_pControl
->
m_rCurve
.
getWidth
()
+
m_pControl
->
m_pImg
->
getWidth
(),
m_pControl
->
m_rCurve
.
getHeight
()
+
m_pControl
->
m_pImg
->
getHeight
(),
-
m_pControl
->
m_pImg
->
getWidth
()
/
2
,
-
m_pControl
->
m_pImg
->
getHeight
()
/
2
);
}
else
pThis
->
notifyLayout
();
m_pControl
->
notifyLayout
();
}
void
CtrlSliderCursor
::
transUpOver
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdUpOver
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
pThis
->
m_pImg
=
pThis
->
m_pImgOver
;
if
(
pThis
->
m_pImg
)
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgOver
;
if
(
m_pControl
->
m_pImg
)
{
pThis
->
notifyLayout
(
pThis
->
m_rCurve
.
getWidth
()
+
pThis
->
m_pImg
->
getWidth
(),
pThis
->
m_rCurve
.
getHeight
()
+
pThis
->
m_pImg
->
getHeight
(),
-
pThis
->
m_pImg
->
getWidth
()
/
2
,
-
pThis
->
m_pImg
->
getHeight
()
/
2
);
m_pControl
->
notifyLayout
(
m_pControl
->
m_rCurve
.
getWidth
()
+
m_pControl
->
m_pImg
->
getWidth
(),
m_pControl
->
m_rCurve
.
getHeight
()
+
m_pControl
->
m_pImg
->
getHeight
(),
-
m_pControl
->
m_pImg
->
getWidth
()
/
2
,
-
m_pControl
->
m_pImg
->
getHeight
()
/
2
);
}
else
pThis
->
notifyLayout
();
m_pControl
->
notifyLayout
();
}
void
CtrlSliderCursor
::
transOverUp
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdOverUp
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
pThis
->
m_pImg
=
pThis
->
m_pImgUp
;
if
(
pThis
->
m_pImg
)
m_pControl
->
m_pImg
=
m_pControl
->
m_pImgUp
;
if
(
m_pControl
->
m_pImg
)
{
pThis
->
notifyLayout
(
pThis
->
m_rCurve
.
getWidth
()
+
pThis
->
m_pImg
->
getWidth
(),
pThis
->
m_rCurve
.
getHeight
()
+
pThis
->
m_pImg
->
getHeight
(),
-
pThis
->
m_pImg
->
getWidth
()
/
2
,
-
pThis
->
m_pImg
->
getHeight
()
/
2
);
m_pControl
->
notifyLayout
(
m_pControl
->
m_rCurve
.
getWidth
()
+
m_pControl
->
m_pImg
->
getWidth
(),
m_pControl
->
m_rCurve
.
getHeight
()
+
m_pControl
->
m_pImg
->
getHeight
(),
-
m_pControl
->
m_pImg
->
getWidth
()
/
2
,
-
m_pControl
->
m_pImg
->
getHeight
()
/
2
);
}
else
pThis
->
notifyLayout
();
m_pControl
->
notifyLayout
();
}
void
CtrlSliderCursor
::
transMove
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdMove
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Get the position of the control
const
Position
*
pPos
=
pThis
->
getPosition
();
const
Position
*
pPos
=
m_pControl
->
getPosition
();
// Compute the resize factors
float
factorX
,
factorY
;
pThis
->
getResizeFactors
(
factorX
,
factorY
);
m_pControl
->
getResizeFactors
(
factorX
,
factorY
);
// Compute the relative position of the centre of the cursor
float
relX
=
pEvtMouse
->
getXPos
()
-
pPos
->
getLeft
()
-
pThis
->
m_xOffset
;
float
relY
=
pEvtMouse
->
getYPos
()
-
pPos
->
getTop
()
-
pThis
->
m_yOffset
;
float
relX
=
pEvtMouse
->
getXPos
()
-
pPos
->
getLeft
()
-
m_pControl
->
m_xOffset
;
float
relY
=
pEvtMouse
->
getYPos
()
-
pPos
->
getTop
()
-
m_pControl
->
m_yOffset
;
// Ponderate with the resize factors
int
relXPond
=
(
int
)(
relX
/
factorX
);
int
relYPond
=
(
int
)(
relY
/
factorY
);
// Update the position
if
(
pThis
->
m_rCurve
.
getMinDist
(
relXPond
,
relYPond
)
<
RANGE
)
if
(
m_pControl
->
m_rCurve
.
getMinDist
(
relXPond
,
relYPond
)
<
RANGE
)
{
float
percentage
=
pThis
->
m_rCurve
.
getNearestPercent
(
relXPond
,
float
percentage
=
m_pControl
->
m_rCurve
.
getNearestPercent
(
relXPond
,
relYPond
);
pThis
->
m_rVariable
.
set
(
percentage
);
m_pControl
->
m_rVariable
.
set
(
percentage
);
}
else
{
pThis
->
m_rVariable
.
set
(
pThis
->
m_lastPercentage
);
m_pControl
->
m_rVariable
.
set
(
m_pControl
->
m_lastPercentage
);
}
}
void
CtrlSliderCursor
::
transScroll
(
SkinObject
*
pCtrl
)
void
CtrlSliderCursor
::
CmdScroll
::
execute
(
)
{
CtrlSliderCursor
*
pThis
=
(
CtrlSliderCursor
*
)
pCtrl
;
EvtScroll
*
pEvtScroll
=
(
EvtScroll
*
)
pThis
->
m_pEvt
;
EvtScroll
*
pEvtScroll
=
(
EvtScroll
*
)
m_pControl
->
m_pEvt
;
int
direction
=
pEvtScroll
->
getDirection
();
float
percentage
=
pThis
->
m_rVariable
.
get
();
float
percentage
=
m_pControl
->
m_rVariable
.
get
();
if
(
direction
==
EvtScroll
::
kUp
)
{
percentage
+=
SCROLL_STEP
;
...
...
@@ -317,7 +308,7 @@ void CtrlSliderCursor::transScroll( SkinObject *pCtrl )
percentage
-=
SCROLL_STEP
;
}
pThis
->
m_rVariable
.
set
(
percentage
);
m_pControl
->
m_rVariable
.
set
(
percentage
);
}
...
...
modules/gui/skins2/controls/ctrl_slider.hpp
View file @
64a27c19
...
...
@@ -75,13 +75,6 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
const
UString
m_tooltip
;
/// Initial size of the control
int
m_width
,
m_height
;
/// Callback objects
Callback
m_cmdOverDown
;
Callback
m_cmdDownOver
;
Callback
m_cmdOverUp
;
Callback
m_cmdUpOver
;
Callback
m_cmdMove
;
Callback
m_cmdScroll
;
/// Position of the cursor
int
m_xPosition
,
m_yPosition
;
/// Last saved position of the cursor (stored as a percentage)
...
...
@@ -97,13 +90,13 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
/// Bezier curve of the slider
const
Bezier
&
m_rCurve
;
/// Callback
function
s
static
void
transOverDown
(
SkinObject
*
pCtrl
);
static
void
transDownOver
(
SkinObject
*
pCtrl
);
static
void
transOverUp
(
SkinObject
*
pCtrl
);
static
void
transUpOver
(
SkinObject
*
pCtrl
);
static
void
transMove
(
SkinObject
*
pCtrl
);
static
void
transScroll
(
SkinObject
*
pCtrl
);
/// Callback
object
s
DEFINE_CALLBACK
(
CtrlSliderCursor
,
OverDown
)
DEFINE_CALLBACK
(
CtrlSliderCursor
,
DownOver
)
DEFINE_CALLBACK
(
CtrlSliderCursor
,
OverUp
)
DEFINE_CALLBACK
(
CtrlSliderCursor
,
UpOver
)
DEFINE_CALLBACK
(
CtrlSliderCursor
,
Move
)
DEFINE_CALLBACK
(
CtrlSliderCursor
,
Scroll
)
/// Method called when the position variable is modified
virtual
void
onUpdate
(
Subject
<
VarPercent
>
&
rVariable
);
...
...
modules/gui/skins2/controls/ctrl_text.cpp
View file @
64a27c19
...
...
@@ -44,13 +44,11 @@ CtrlText::CtrlText( intf_thread_t *pIntf, VarText &rVariable,
const
GenericFont
&
rFont
,
const
UString
&
rHelp
,
uint32_t
color
,
VarBool
*
pVisible
)
:
CtrlGeneric
(
pIntf
,
rHelp
,
pVisible
),
m_fsm
(
pIntf
),
m_rVariable
(
rVariable
),
m_cmdToManual
(
this
,
&
transToManual
),
m_cmdManualMoving
(
this
,
&
transManualMoving
),
m_cmdManualStill
(
this
,
&
transManualStill
),
m_cmdMove
(
this
,
&
transMove
),
m_pEvt
(
NULL
),
m_rFont
(
rFont
),
m_color
(
color
),
m_pImg
(
NULL
),
m_pImgDouble
(
NULL
),
m_pCurrImg
(
NULL
),
m_xPos
(
0
),
m_xOffset
(
0
)
m_rVariable
(
rVariable
),
m_cmdToManual
(
pIntf
,
this
),
m_cmdManualMoving
(
pIntf
,
this
),
m_cmdManualStill
(
pIntf
,
this
),
m_cmdMove
(
pIntf
,
this
),
m_pEvt
(
NULL
),
m_rFont
(
rFont
),
m_color
(
color
),
m_pImg
(
NULL
),
m_pImgDouble
(
NULL
),
m_pCurrImg
(
NULL
),
m_xPos
(
0
),
m_xOffset
(
0
)
{
m_pTimer
=
OSFactory
::
instance
(
getIntf
()
)
->
createOSTimer
(
Callback
(
this
,
&
updateText
)
);
...
...
@@ -254,78 +252,74 @@ void CtrlText::onChangePosition()
}
void
CtrlText
::
transToManual
(
SkinObject
*
pCtrl
)
void
CtrlText
::
CmdToManual
::
execute
(
)
{
CtrlText
*
pThis
=
(
CtrlText
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Compute the offset
pThis
->
m_xOffset
=
pEvtMouse
->
getXPos
()
-
pThis
->
m_xPos
;
m_pControl
->
m_xOffset
=
pEvtMouse
->
getXPos
()
-
m_pControl
->
m_xPos
;
pThis
->
m_pTimer
->
stop
();
pThis
->
captureMouse
();
m_pControl
->
m_pTimer
->
stop
();
m_pControl
->
captureMouse
();
}
void
CtrlText
::
transManualMoving
(
SkinObject
*
pCtrl
)
void
CtrlText
::
CmdManualMoving
::
execute
(
)
{
CtrlText
*
pThis
=
(
CtrlText
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
// Start the automatic movement, but only if the text is wider than the
// control
if
(
pThis
->
m_pImg
&&
pThis
->
m_pImg
->
getWidth
()
>=
pThis
->
getPosition
()
->
getWidth
()
)
if
(
m_pControl
->
m_pImg
&&
m_pControl
->
m_pImg
->
getWidth
()
>=
m_pControl
->
getPosition
()
->
getWidth
()
)
{
// The current image may have been set incorrectly in displayText(), so
// set the correct value
pThis
->
m_pCurrImg
=
pThis
->
m_pImgDouble
;
m_pControl
->
m_pCurrImg
=
m_pControl
->
m_pImgDouble
;
pThis
->
m_pTimer
->
start
(
MOVING_TEXT_DELAY
,
false
);
m_pControl
->
m_pTimer
->
start
(
MOVING_TEXT_DELAY
,
false
);
}
}
void
CtrlText
::
transManualStill
(
SkinObject
*
pCtrl
)
void
CtrlText
::
CmdManualStill
::
execute
(
)
{
CtrlText
*
pThis
=
(
CtrlText
*
)
pCtrl
;
pThis
->
releaseMouse
();
m_pControl
->
releaseMouse
();
}
void
CtrlText
::
transMove
(
SkinObject
*
pCtrl
)
void
CtrlText
::
CmdMove
::
execute
(
)
{
CtrlText
*
pThis
=
(
CtrlText
*
)
pCtrl
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
pThis
->
m_pEvt
;
EvtMouse
*
pEvtMouse
=
(
EvtMouse
*
)
m_pControl
->
m_pEvt
;
// Do nothing if the text fits in the control
if
(
pThis
->
m_pImg
&&
pThis
->
m_pImg
->
getWidth
()
>=
pThis
->
getPosition
()
->
getWidth
()
)
if
(
m_pControl
->
m_pImg
&&
m_pControl
->
m_pImg
->
getWidth
()
>=
m_pControl
->
getPosition
()
->
getWidth
()
)
{
// The current image may have been set incorrectly in displayText(), so
// we set the correct value
pThis
->
m_pCurrImg
=
pThis
->
m_pImgDouble
;
m_pControl
->
m_pCurrImg
=
m_pControl
->
m_pImgDouble
;
// Compute the new position of the left side, and make sure it is
// in the correct range
pThis
->
m_xPos
=
(
pEvtMouse
->
getXPos
()
-
pThis
->
m_xOffset
);
pThis
->
adjust
(
pThis
->
m_xPos
);
m_pControl
->
m_xPos
=
(
pEvtMouse
->
getXPos
()
-
m_pControl
->
m_xOffset
);
m_pControl
->
adjust
(
m_pControl
->
m_xPos
);
pThis
->
notifyLayout
(
pThis
->
getPosition
()
->
getWidth
(),
pThis
->
getPosition
()
->
getHeight
()
);
m_pControl
->
notifyLayout
(
m_pControl
->
getPosition
()
->
getWidth
(),
m_pControl
->
getPosition
()
->
getHeight
()
);
}
}
void
CtrlText
::
updateText
(
SkinObject
*
pCtrl
)
{
CtrlText
*
pThis
=
(
CtrlText
*
)
pCtrl
;
CtrlText
*
m_pControl
=
(
CtrlText
*
)
pCtrl
;
pThis
->
m_xPos
-=
MOVING_TEXT_STEP
;
pThis
->
adjust
(
pThis
->
m_xPos
);
m_pControl
->
m_xPos
-=
MOVING_TEXT_STEP
;
m_pControl
->
adjust
(
m_pControl
->
m_xPos
);
pThis
->
notifyLayout
(
pThis
->
getPosition
()
->
getWidth
(),
pThis
->
getPosition
()
->
getHeight
()
);
m_pControl
->
notifyLayout
(
m_pControl
->
getPosition
()
->
getWidth
(),
m_pControl
->
getPosition
()
->
getHeight
()
);
}
...
...
modules/gui/skins2/controls/ctrl_text.hpp
View file @
64a27c19
...
...
@@ -68,11 +68,6 @@ class CtrlText: public CtrlGeneric, public Observer<VarText>
FSM
m_fsm
;
/// Variable associated to the control
VarText
&
m_rVariable
;
/// Callback objects
Callback
m_cmdToManual
;
Callback
m_cmdManualMoving
;
Callback
m_cmdManualStill
;
Callback
m_cmdMove
;
/// The last received event
EvtGeneric
*
m_pEvt
;
/// Font used to render the text
...
...
@@ -94,11 +89,12 @@ class CtrlText: public CtrlGeneric, public Observer<VarText>
/// Timer to move the text
OSTimer
*
m_pTimer
;
/// Callback functions
static
void
transToManual
(
SkinObject
*
pCtrl
);
static
void
transManualMoving
(
SkinObject
*
pCtrl
);
static
void
transManualStill
(
SkinObject
*
pCtrl
);
static
void
transMove
(
SkinObject
*
pCtrl
);
/// Callback objects
DEFINE_CALLBACK
(
CtrlText
,
ToManual
)
DEFINE_CALLBACK
(
CtrlText
,
ManualMoving
)
DEFINE_CALLBACK
(
CtrlText
,
ManualStill
)
DEFINE_CALLBACK
(
CtrlText
,
Move
)
/// Callback for the timer
static
void
updateText
(
SkinObject
*
pCtrl
);
...
...
modules/gui/skins2/utils/fsm.cpp
View file @
64a27c19
...
...
@@ -33,7 +33,7 @@ void FSM::addState( const string &state )
void
FSM
::
addTransition
(
const
string
&
state1
,
const
string
&
event
,
const
string
&
state2
,
C
allback
*
pCmd
)
const
string
&
state2
,
C
mdGeneric
*
pCmd
)
{
// Check that we already know the states
if
(
m_states
.
find
(
state1
)
==
m_states
.
end
()
||
...
...
@@ -100,9 +100,9 @@ void FSM::handleTransition( const string &event )
m_currentState
=
(
*
it
).
second
.
first
;
// Call the callback, if any
C
allback
*
pCmd
=
(
*
it
).
second
.
second
;
C
mdGeneric
*
pCmd
=
(
*
it
).
second
.
second
;
if
(
pCmd
!=
NULL
)
{
(
*
(
pCmd
->
getFunc
()))(
pCmd
->
getObj
()
);
pCmd
->
execute
(
);
}
}
modules/gui/skins2/utils/fsm.hpp
View file @
64a27c19
...
...
@@ -31,6 +31,7 @@
#include <set>
class
EvtGeneric
;
class
CmdGeneric
;
/// This class implements a Finite State Machine (FSM)
...
...
@@ -46,7 +47,7 @@ class FSM: public SkinObject
/// Add a transition to the machine
void
addTransition
(
const
string
&
state1
,
const
string
&
event
,
const
string
&
state2
,
C
allback
*
pCmd
=
NULL
);
C
mdGeneric
*
pCmd
=
NULL
);
/// Retrieve the current state
const
string
&
getState
()
const
{
return
m_currentState
;
}
...
...
@@ -65,7 +66,7 @@ class FSM: public SkinObject
/// A Data_t contains the final state of a transition, and a callback
/// to execute when the transition is applied
typedef
pair
<
string
,
C
allback
*>
Data_t
;
typedef
pair
<
string
,
C
mdGeneric
*>
Data_t
;
/// Current state of the machine
string
m_currentState
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment