Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
30b3704a
Commit
30b3704a
authored
Jan 18, 2011
by
Jean-Philippe André
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lua: add support for the new spin icon
parent
50ec0373
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
2 deletions
+85
-2
include/vlc_extensions.h
include/vlc_extensions.h
+5
-0
modules/misc/lua/libs/dialog.c
modules/misc/lua/libs/dialog.c
+80
-2
No files found.
include/vlc_extensions.h
View file @
30b3704a
...
...
@@ -255,6 +255,7 @@ typedef enum
EXTENSION_WIDGET_DROPDOWN
,
///< Drop-down box
EXTENSION_WIDGET_LIST
,
///< Vertical list box (of strings)
EXTENSION_WIDGET_CHECK_BOX
,
///< Checkable box with label
EXTENSION_WIDGET_SPIN_ICON
,
///< A "loading..." spinning icon
}
extension_widget_type_e
;
/// Widget descriptor for extensions
...
...
@@ -285,6 +286,10 @@ struct extension_widget_t
int
i_height
;
///< Height hint
bool
b_hide
;
///< Hide this widget (make it invisible)
/* Spinning icon */
int
i_spin_loops
;
///< Number of loops to play (-1 = infinite,
// 0 = stop animation)
/* Orders */
bool
b_kill
;
///< Destroy this widget
bool
b_update
;
///< Update this widget
...
...
modules/misc/lua/libs/dialog.c
View file @
30b3704a
...
...
@@ -78,6 +78,7 @@ static int vlclua_dialog_add_check_box( lua_State *L );
static
int
vlclua_dialog_add_list
(
lua_State
*
L
);
static
int
vlclua_dialog_add_dropdown
(
lua_State
*
L
);
static
int
vlclua_dialog_add_image
(
lua_State
*
L
);
static
int
vlclua_dialog_add_spin_icon
(
lua_State
*
L
);
static
int
vlclua_create_widget_inner
(
lua_State
*
L
,
int
i_args
,
extension_widget_t
*
p_widget
);
...
...
@@ -92,6 +93,8 @@ static int vlclua_widget_add_value( lua_State *L );
static
int
vlclua_widget_get_value
(
lua_State
*
L
);
static
int
vlclua_widget_clear
(
lua_State
*
L
);
static
int
vlclua_widget_get_selection
(
lua_State
*
L
);
static
int
vlclua_widget_animate
(
lua_State
*
L
);
static
int
vlclua_widget_stop
(
lua_State
*
L
);
/* Helpers */
static
void
AddWidget
(
extension_dialog_t
*
p_dialog
,
...
...
@@ -115,6 +118,7 @@ static const luaL_Reg vlclua_dialog_reg[] = {
{
"add_dropdown"
,
vlclua_dialog_add_dropdown
},
{
"add_list"
,
vlclua_dialog_add_list
},
{
"add_image"
,
vlclua_dialog_add_image
},
{
"add_spin_icon"
,
vlclua_dialog_add_spin_icon
},
{
"del_widget"
,
vlclua_dialog_delete_widget
},
{
NULL
,
NULL
}
...
...
@@ -129,6 +133,8 @@ static const luaL_Reg vlclua_widget_reg[] = {
{
"get_value"
,
vlclua_widget_get_value
},
{
"clear"
,
vlclua_widget_clear
},
{
"get_selection"
,
vlclua_widget_get_selection
},
{
"animate"
,
vlclua_widget_animate
},
{
"stop"
,
vlclua_widget_stop
},
{
NULL
,
NULL
}
};
...
...
@@ -511,7 +517,7 @@ static int vlclua_dialog_add_list( lua_State *L )
/**
* Create an image label
* Arguments: url
* Arguments:
(string)
url
* Qt: QLabel with setPixmap( QPixmap& )
**/
static
int
vlclua_dialog_add_image
(
lua_State
*
L
)
...
...
@@ -527,6 +533,23 @@ static int vlclua_dialog_add_image( lua_State *L )
return
vlclua_create_widget_inner
(
L
,
1
,
p_widget
);
}
/**
* Create a spinning icon
* Arguments: (int) loop count to play: 0 means stopped, -1 means infinite.
* Qt: SpinningIcon (custom widget)
**/
static
int
vlclua_dialog_add_spin_icon
(
lua_State
*
L
)
{
/* Verify arguments */
if
(
!
lua_isstring
(
L
,
2
)
)
return
luaL_error
(
L
,
"dialog:add_image usage: (filename)"
);
extension_widget_t
*
p_widget
=
calloc
(
1
,
sizeof
(
extension_widget_t
)
);
p_widget
->
type
=
EXTENSION_WIDGET_SPIN_ICON
;
return
vlclua_create_widget_inner
(
L
,
0
,
p_widget
);
}
/**
* Internal helper to finalize the creation of a widget
* @param L Lua State
...
...
@@ -847,7 +870,6 @@ static int vlclua_widget_get_selection( lua_State *L )
return
1
;
}
static
int
vlclua_widget_set_checked
(
lua_State
*
L
)
{
/* Get dialog */
...
...
@@ -881,6 +903,62 @@ static int vlclua_widget_set_checked( lua_State *L )
return
1
;
}
static
int
vlclua_widget_animate
(
lua_State
*
L
)
{
/* Get dialog */
extension_widget_t
**
pp_widget
=
(
extension_widget_t
**
)
luaL_checkudata
(
L
,
1
,
"widget"
);
if
(
!
pp_widget
||
!*
pp_widget
)
return
luaL_error
(
L
,
"Can't get pointer to widget"
);
extension_widget_t
*
p_widget
=
*
pp_widget
;
if
(
p_widget
->
type
!=
EXTENSION_WIDGET_SPIN_ICON
)
return
luaL_error
(
L
,
"method animate not valid for this widget"
);
/* Verify arguments */
vlc_mutex_lock
(
&
p_widget
->
p_dialog
->
lock
);
if
(
!
lua_isnumber
(
L
,
2
)
)
p_widget
->
i_spin_loops
=
-
1
;
else
p_widget
->
i_spin_loops
=
lua_tointeger
(
L
,
2
);
vlc_mutex_unlock
(
&
p_widget
->
p_dialog
->
lock
);
/* Signal interface of the change */
p_widget
->
b_update
=
true
;
lua_SetDialogUpdate
(
L
,
1
);
return
1
;
}
static
int
vlclua_widget_stop
(
lua_State
*
L
)
{
/* Get dialog */
extension_widget_t
**
pp_widget
=
(
extension_widget_t
**
)
luaL_checkudata
(
L
,
1
,
"widget"
);
if
(
!
pp_widget
||
!*
pp_widget
)
return
luaL_error
(
L
,
"Can't get pointer to widget"
);
extension_widget_t
*
p_widget
=
*
pp_widget
;
if
(
p_widget
->
type
!=
EXTENSION_WIDGET_SPIN_ICON
)
return
luaL_error
(
L
,
"method stop not valid for this widget"
);
vlc_mutex_lock
(
&
p_widget
->
p_dialog
->
lock
);
bool
b_needs_update
=
p_widget
->
i_spin_loops
!=
0
;
p_widget
->
i_spin_loops
=
0
;
vlc_mutex_unlock
(
&
p_widget
->
p_dialog
->
lock
);
if
(
b_needs_update
)
{
/* Signal interface of the change */
p_widget
->
b_update
=
true
;
lua_SetDialogUpdate
(
L
,
1
);
}
return
1
;
}
/**
* Delete a widget from a dialog
* Remove it from the list once it has been safely destroyed by the interface
...
...
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