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
354811a1
Commit
354811a1
authored
Nov 21, 2009
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skins2: Replace some theme macros by templated code.
parent
a7b6b23d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
77 deletions
+56
-77
modules/gui/skins2/src/theme.cpp
modules/gui/skins2/src/theme.cpp
+29
-65
modules/gui/skins2/src/theme.hpp
modules/gui/skins2/src/theme.hpp
+27
-12
No files found.
modules/gui/skins2/src/theme.cpp
View file @
354811a1
...
@@ -17,9 +17,9 @@
...
@@ -17,9 +17,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
along
*
along with this program; if not, write to the Free Software
*
with this program; if not, write to the Free Software Foundation, Inc.,
*
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*****************************************************************************/
#include "theme.hpp"
#include "theme.hpp"
...
@@ -159,77 +159,41 @@ void Theme::saveConfig()
...
@@ -159,77 +159,41 @@ void Theme::saveConfig()
}
}
// Useful macro
// Takes an ID of the form "id1;id2;id3", and returns the object
#define FIND_OBJECT( mapData, mapName ) \
map<string, mapData>::const_iterator it; \
it = mapName.find( id ); \
if( it == mapName.end() ) \
{ \
return NULL; \
} \
return (*it).second.get();
// This macro takes an ID of the form "id1;id2;id3", and returns the object
// corresponding to the first valid ID. If no ID is valid, it returns NULL.
// corresponding to the first valid ID. If no ID is valid, it returns NULL.
// XXX: should we use a template method instead?
// XXX The string handling here probably could be improved.
#define FIND_FIRST_OBJECT( mapDataPtr, mapName ) \
template
<
class
T
>
typename
T
::
pointer
string rightPart = id; \
Theme
::
IDmap
<
T
>::
find_first_object
(
const
string
&
id
)
const
string::size_type pos; \
do \
{ \
pos = rightPart.find( ";" ); \
string leftPart = rightPart.substr( 0, pos ); \
map<string, mapDataPtr>::const_iterator it = mapName.find( leftPart ); \
if( it != mapName.end() ) \
{ \
return (*it).second.get(); \
break; \
} \
\
if( pos != string::npos ) \
{ \
rightPart = rightPart.substr( pos, rightPart.size() ); \
rightPart = \
rightPart.substr( rightPart.find_first_not_of( " \t;" ), \
rightPart.size() ); \
} \
} \
while( pos != string::npos ); \
return NULL;
GenericBitmap
*
Theme
::
getBitmapById
(
const
string
&
id
)
const
{
FIND_FIRST_OBJECT
(
GenericBitmapPtr
,
m_bitmaps
);
}
GenericFont
*
Theme
::
getFontById
(
const
string
&
id
)
const
{
FIND_FIRST_OBJECT
(
GenericFontPtr
,
m_fonts
);
}
Popup
*
Theme
::
getPopupById
(
const
string
&
id
)
const
{
{
FIND_OBJECT
(
PopupPtr
,
m_popups
);
string
rightPart
=
id
;
}
string
::
size_type
pos
;
do
{
pos
=
rightPart
.
find
(
";"
);
string
leftPart
=
rightPart
.
substr
(
0
,
pos
);
TopWindow
*
Theme
::
getWindowById
(
const
string
&
id
)
const
typename
T
::
pointer
p
=
find_object
(
leftPart
);
{
if
(
p
)
return
p
;
FIND_OBJECT
(
TopWindowPtr
,
m_windows
);
}
GenericLayout
*
Theme
::
getLayoutById
(
const
string
&
id
)
const
if
(
pos
!=
string
::
npos
)
{
{
FIND_OBJECT
(
GenericLayoutPtr
,
m_layouts
);
rightPart
=
rightPart
.
substr
(
pos
,
rightPart
.
size
()
);
rightPart
=
rightPart
.
substr
(
rightPart
.
find_first_not_of
(
"
\t
;"
),
rightPart
.
size
()
);
}
}
while
(
pos
!=
string
::
npos
);
return
NULL
;
}
}
CtrlGeneric
*
Theme
::
getControl
ById
(
const
string
&
id
)
const
GenericBitmap
*
Theme
::
getBitmap
ById
(
const
string
&
id
)
const
{
{
FIND_OBJECT
(
CtrlGenericPtr
,
m_controls
);
m_bitmaps
.
find_first_object
(
id
);
}
}
Position
*
Theme
::
getPosition
ById
(
const
string
&
id
)
const
GenericFont
*
Theme
::
getFont
ById
(
const
string
&
id
)
const
{
{
FIND_OBJECT
(
PositionPtr
,
m_positions
);
m_fonts
.
find_first_object
(
id
);
}
}
modules/gui/skins2/src/theme.hpp
View file @
354811a1
...
@@ -58,29 +58,44 @@ public:
...
@@ -58,29 +58,44 @@ public:
GenericBitmap
*
getBitmapById
(
const
string
&
id
)
const
;
GenericBitmap
*
getBitmapById
(
const
string
&
id
)
const
;
GenericFont
*
getFontById
(
const
string
&
id
)
const
;
GenericFont
*
getFontById
(
const
string
&
id
)
const
;
Popup
*
getPopupById
(
const
string
&
id
)
const
;
TopWindow
*
getWindowById
(
const
string
&
id
)
const
;
# define ObjByID( var ) ( const string &id ) const \
GenericLayout
*
getLayoutById
(
const
string
&
id
)
const
;
{ return var.find_object( id ); }
CtrlGeneric
*
getControlById
(
const
string
&
id
)
const
;
Popup
*
getPopupById
ObjByID
(
m_popups
)
Position
*
getPositionById
(
const
string
&
id
)
const
;
TopWindow
*
getWindowById
ObjByID
(
m_windows
)
GenericLayout
*
getLayoutById
ObjByID
(
m_layouts
)
CtrlGeneric
*
getControlById
ObjByID
(
m_controls
)
Position
*
getPositionById
ObjByID
(
m_positions
)
# undef ObjById
WindowManager
&
getWindowManager
()
{
return
m_windowManager
;
}
WindowManager
&
getWindowManager
()
{
return
m_windowManager
;
}
private:
private:
template
<
class
T
>
class
IDmap
:
public
std
::
map
<
string
,
T
>
{
private:
typedef
typename
std
::
map
<
string
,
T
>
parent
;
public:
typename
T
::
pointer
find_object
(
const
string
&
id
)
const
{
typename
parent
::
const_iterator
it
=
parent
::
find
(
id
);
return
it
!=
parent
::
end
()
?
it
->
second
.
get
()
:
NULL
;
}
typename
T
::
pointer
find_first_object
(
const
string
&
id
)
const
;
};
/// Store the bitmaps by ID
/// Store the bitmaps by ID
map
<
string
,
GenericBitmapPtr
>
m_bitmaps
;
IDmap
<
GenericBitmapPtr
>
m_bitmaps
;
/// Store the fonts by ID
/// Store the fonts by ID
map
<
string
,
GenericFontPtr
>
m_fonts
;
IDmap
<
GenericFontPtr
>
m_fonts
;
/// Store the popups by ID
/// Store the popups by ID
map
<
string
,
PopupPtr
>
m_popups
;
IDmap
<
PopupPtr
>
m_popups
;
/// Store the windows by ID
/// Store the windows by ID
map
<
string
,
TopWindowPtr
>
m_windows
;
IDmap
<
TopWindowPtr
>
m_windows
;
/// Store the layouts by ID
/// Store the layouts by ID
map
<
string
,
GenericLayoutPtr
>
m_layouts
;
IDmap
<
GenericLayoutPtr
>
m_layouts
;
/// Store the controls by ID
/// Store the controls by ID
map
<
string
,
CtrlGenericPtr
>
m_controls
;
IDmap
<
CtrlGenericPtr
>
m_controls
;
/// Store the panel positions by ID
/// Store the panel positions by ID
map
<
string
,
PositionPtr
>
m_positions
;
IDmap
<
PositionPtr
>
m_positions
;
/// Store the commands
/// Store the commands
list
<
CmdGenericPtr
>
m_commands
;
list
<
CmdGenericPtr
>
m_commands
;
/// Store the Bezier curves
/// Store the Bezier curves
...
...
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