WIP: make the add-on list a widget
The purpose of this change is ability to create more dialogs which present a list of add-ons, such as a GUI2 version of the "Install Dependencies" dialog. This change is still highly incomplete. First of all, I disabled inline install buttons and ability to sort the add-on list. In addition, a lot of functionality that belongs in the add-on list widget is still in the GUI2 add-on manager instead. It is also notable that the widget relies on several linked groups being defined in the window. I plan to finish the transition to the add-on list widget, and address the problems in the previous paragraph, in the future. The linked group issue is going to require a lot of work in particular: I plan to either make linked groups grid-specific instead of window-specific (like they are now) or allow widgets to inject linked groups to the containing window. Either way, I'm going to change the operation of GUI2 fairly deeply.
This commit is contained in:
parent
a6ba51fc05
commit
dc71d9d671
9 changed files with 878 additions and 546 deletions
|
@ -593,6 +593,21 @@
|
|||
name="gui"
|
||||
min="0"
|
||||
max="1"
|
||||
[tag]
|
||||
name="addon_list_definition"
|
||||
min="0"
|
||||
max="-1"
|
||||
super="generic/widget_definition"
|
||||
[tag]
|
||||
name="resolution"
|
||||
min="0"
|
||||
max="-1"
|
||||
super="generic/widget_definition/resolution"
|
||||
[link]
|
||||
name="gui/window/resolution/grid"
|
||||
[/link]
|
||||
[/tag]
|
||||
[/tag]
|
||||
[tag]
|
||||
name="button_definition"
|
||||
min="0"
|
||||
|
@ -1451,6 +1466,22 @@
|
|||
name="column"
|
||||
min="0"
|
||||
max="-1"
|
||||
[tag]
|
||||
name="addon_list"
|
||||
min="0"
|
||||
max="-1"
|
||||
super="generic/widget_instance"
|
||||
[key]
|
||||
name="install_status_visibility"
|
||||
type="string"
|
||||
default="visible"
|
||||
[/key]
|
||||
[key]
|
||||
name="install_buttons_visibility"
|
||||
type="string"
|
||||
default="invisible"
|
||||
[/key]
|
||||
[/tag]
|
||||
[tag]
|
||||
name="button"
|
||||
min="0"
|
||||
|
|
428
data/gui/widget/addon_list.cfg
Normal file
428
data/gui/widget/addon_list.cfg
Normal file
|
@ -0,0 +1,428 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of an addon list widget
|
||||
###
|
||||
|
||||
#define _GUI_ADDON_LIST
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[listbox]
|
||||
id = "addons"
|
||||
definition = "default"
|
||||
|
||||
horizontal_scrollbar_mode = "never"
|
||||
|
||||
[header]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[spacer]
|
||||
linked_group = "icon"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_0"
|
||||
definition = "listbox_header"
|
||||
linked_group = "name"
|
||||
|
||||
label = _ "Name"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "left"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
linked_group = "version"
|
||||
label = _ "Version"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_1"
|
||||
definition = "listbox_header"
|
||||
linked_group = "author"
|
||||
|
||||
label = _ "Author"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_2"
|
||||
definition = "listbox_header"
|
||||
linked_group = "size"
|
||||
|
||||
label = _ "Size"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_3"
|
||||
definition = "listbox_header"
|
||||
linked_group = "downloads"
|
||||
|
||||
label = _ "Downloads"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_4"
|
||||
definition = "listbox_header"
|
||||
linked_group = "type"
|
||||
|
||||
label = _ "Type"
|
||||
[/toggle_button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[spacer]
|
||||
linked_group = "control_buttons"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/header]
|
||||
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
vertical_grow = "true"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
## linked_group = "list_item"
|
||||
definition = "default"
|
||||
|
||||
return_value_id = "ok"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "false"
|
||||
vertical_alignment = "center"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[drawing]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
|
||||
width = 72
|
||||
height = 72
|
||||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
name = "(text)"
|
||||
w = "(min(image_original_width, 72))"
|
||||
h = "(min(image_original_height, 72))"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/drawing]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
vertical_alignment = "center"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "name"
|
||||
definition = "default"
|
||||
linked_group = "name"
|
||||
wrap = "true"
|
||||
characters_per_line = 20
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "installation_status"
|
||||
definition = "default_small"
|
||||
linked_group = "name"
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "version"
|
||||
definition = "default_small"
|
||||
linked_group = "version"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "author"
|
||||
definition = "default_small"
|
||||
linked_group = "author"
|
||||
wrap = "true"
|
||||
characters_per_line = 20
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "size"
|
||||
definition = "default_small"
|
||||
linked_group = "size"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "downloads"
|
||||
definition = "default_small"
|
||||
linked_group = "downloads"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "type"
|
||||
definition = "default_small"
|
||||
linked_group = "type"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
|
||||
[grid]
|
||||
id = "single_install_buttons"
|
||||
linked_group = "control_buttons"
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[stacked_widget]
|
||||
id = "install_update_stack"
|
||||
definition = "default"
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_install"
|
||||
definition = "install"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_update"
|
||||
definition = "update"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[/stacked_widget]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_uninstall"
|
||||
definition = "uninstall"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
#enddef
|
||||
|
||||
[addon_list_definition]
|
||||
id = "default"
|
||||
description = "List of one or more add-ons."
|
||||
|
||||
[resolution]
|
||||
{_GUI_ADDON_LIST}
|
||||
[/resolution]
|
||||
[/addon_list_definition]
|
||||
|
||||
#undef _GUI_ADDON_LIST
|
|
@ -3,418 +3,6 @@
|
|||
### Definition of the window to select an addon for installation.
|
||||
###
|
||||
|
||||
#define _GUI_ADDON_LIST_SECTION
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[listbox]
|
||||
id = "addons"
|
||||
definition = "default"
|
||||
|
||||
horizontal_scrollbar_mode = "never"
|
||||
|
||||
[header]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[spacer]
|
||||
linked_group = "icon"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_0"
|
||||
definition = "listbox_header"
|
||||
linked_group = "name"
|
||||
|
||||
label = _ "Name"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "left"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
linked_group = "version"
|
||||
label = _ "Version"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_1"
|
||||
definition = "listbox_header"
|
||||
linked_group = "author"
|
||||
|
||||
label = _ "Author"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_2"
|
||||
definition = "listbox_header"
|
||||
linked_group = "size"
|
||||
|
||||
label = _ "Size"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_3"
|
||||
definition = "listbox_header"
|
||||
linked_group = "downloads"
|
||||
|
||||
label = _ "Downloads"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_4"
|
||||
definition = "listbox_header"
|
||||
linked_group = "type"
|
||||
|
||||
label = _ "Type"
|
||||
[/toggle_button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[spacer]
|
||||
linked_group = "control_buttons"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/header]
|
||||
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
vertical_grow = "true"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
## linked_group = "list_item"
|
||||
definition = "default"
|
||||
|
||||
return_value_id = "ok"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "false"
|
||||
vertical_alignment = "center"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[drawing]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
|
||||
width = 72
|
||||
height = 72
|
||||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
name = "(text)"
|
||||
w = "(min(image_original_width, 72))"
|
||||
h = "(min(image_original_height, 72))"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/drawing]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
vertical_alignment = "center"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "name"
|
||||
definition = "default"
|
||||
linked_group = "name"
|
||||
wrap = "true"
|
||||
characters_per_line = 20
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "installation_status"
|
||||
definition = "default_small"
|
||||
linked_group = "name"
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "version"
|
||||
definition = "default_small"
|
||||
linked_group = "version"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "author"
|
||||
definition = "default_small"
|
||||
linked_group = "author"
|
||||
wrap = "true"
|
||||
characters_per_line = 20
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "size"
|
||||
definition = "default_small"
|
||||
linked_group = "size"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "downloads"
|
||||
definition = "default_small"
|
||||
linked_group = "downloads"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "type"
|
||||
definition = "default_small"
|
||||
linked_group = "type"
|
||||
wrap = "true"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
|
||||
[grid]
|
||||
linked_group = "control_buttons"
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[stacked_widget]
|
||||
id = "install_update_stack"
|
||||
definition = "default"
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_install"
|
||||
definition = "install"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_update"
|
||||
definition = "update"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[/stacked_widget]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "single_uninstall"
|
||||
definition = "uninstall"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
#enddef
|
||||
|
||||
#define _GUI_ADDON_DETAILS_SECTION
|
||||
[grid]
|
||||
|
||||
|
@ -1241,7 +829,12 @@
|
|||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
{_GUI_ADDON_LIST_SECTION}
|
||||
[addon_list]
|
||||
id = "addons"
|
||||
definition = "default"
|
||||
install_status_visibility = "visible"
|
||||
install_buttons_visibility = "visible"
|
||||
[/addon_list]
|
||||
|
||||
[/column]
|
||||
|
||||
|
@ -1319,5 +912,4 @@
|
|||
[/window]
|
||||
|
||||
#undef _GUI_ADDON_FILTER_OPTIONS
|
||||
#undef _GUI_ADDON_LIST_SECTION
|
||||
#undef _GUI_ADDON_DETAILS_SECTION
|
||||
|
|
|
@ -2308,6 +2308,13 @@
|
|||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Gui\Dialogs\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Gui\Dialogs\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\widgets\addon_list.cpp">
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='ReleaseDEBUG|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\widgets\button.cpp">
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
|
||||
|
@ -4201,6 +4208,7 @@
|
|||
<ClInclude Include="..\..\src\gui\dialogs\unit_recruit.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\wml_error.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\wml_message.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\widgets\addon_list.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\widgets\button.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\widgets\chatbox.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\widgets\clickable_item.hpp" />
|
||||
|
|
|
@ -1519,6 +1519,9 @@
|
|||
<ClCompile Include="..\..\src\font\text_surface.cpp">
|
||||
<Filter>Font</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\widgets\addon_list.cpp">
|
||||
<Filter>Gui\Widgets</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\addon\client.hpp">
|
||||
|
@ -2949,6 +2952,9 @@
|
|||
<ClInclude Include="..\..\src\font\pango\stream_ops.hpp">
|
||||
<Filter>Font\Pango</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\gui\widgets\addon_list.hpp">
|
||||
<Filter>Gui\Widgets</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\src\tests\test_sdl_utils.hpp">
|
||||
|
|
|
@ -243,6 +243,7 @@ gui/dialogs/unit_recall.cpp
|
|||
gui/dialogs/unit_recruit.cpp
|
||||
gui/dialogs/wml_error.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/addon_list.cpp
|
||||
gui/widgets/button.cpp
|
||||
gui/widgets/chatbox.cpp
|
||||
gui/widgets/container_base.cpp
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/widgets/addon_list.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/stacked_widget.hpp"
|
||||
|
@ -184,75 +185,6 @@ void addon_manager::on_filtertext_changed(text_box_base* textbox, const std::str
|
|||
addons.set_row_shown(res);
|
||||
}
|
||||
|
||||
static std::string colorify_addon_state_string(const std::string& str,
|
||||
const addon_tracking_info& state, bool verbose = false)
|
||||
{
|
||||
std::string colorname = "";
|
||||
|
||||
switch(state.state) {
|
||||
case ADDON_NONE:
|
||||
if(!verbose) {
|
||||
return str;
|
||||
}
|
||||
colorname = "#a69275";
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
case ADDON_NOT_TRACKED:
|
||||
colorname = "#00ff00"; // GOOD_COLOR
|
||||
break;
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
colorname = "#ffff00"; // YELLOW_COLOR/color_upgradable
|
||||
break;
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
colorname = "#ff7f00"; // <255,127,0>/color_outdated
|
||||
break;
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
colorname = "#ff0000"; // BAD_COLOR
|
||||
break;
|
||||
default:
|
||||
colorname = "#777777"; // GRAY_COLOR
|
||||
break;
|
||||
}
|
||||
|
||||
return "<span color='" + colorname + "'>" + str + "</span>";
|
||||
}
|
||||
|
||||
static std::string describe_status_simple(const addon_tracking_info& info)
|
||||
{
|
||||
std::string tc, tx;
|
||||
|
||||
switch(info.state) {
|
||||
case ADDON_NONE:
|
||||
tx = info.can_publish ? _("addon_state^Published, not installed") : _("addon_state^Not installed");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED:
|
||||
case ADDON_NOT_TRACKED:
|
||||
// Consider add-ons without version information as installed
|
||||
// for the main display. Their Description info should elaborate
|
||||
// on their status.
|
||||
tx = info.can_publish ? _("addon_state^Published") : _("addon_state^Installed");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
tx = info.can_publish ? _("addon_state^Published, upgradable") : _("addon_state^Installed, upgradable");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
tx = info.can_publish ? _("addon_state^Published, outdated on server") : _("addon_state^Installed, outdated on server");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
tx = info.can_publish ? _("addon_state^Published, broken") : _("addon_state^Installed, broken");
|
||||
break;
|
||||
|
||||
default:
|
||||
tx = _("addon_state^Unknown");
|
||||
}
|
||||
|
||||
return colorify_addon_state_string(tx, info, true);
|
||||
}
|
||||
|
||||
static std::string describe_status_verbose(const addon_tracking_info& state)
|
||||
{
|
||||
std::string s;
|
||||
|
@ -313,19 +245,21 @@ static std::string describe_status_verbose(const addon_tracking_info& state)
|
|||
s = _("addon_state^Unknown");
|
||||
}
|
||||
|
||||
return colorify_addon_state_string(s, state);
|
||||
return addon_list::colorify_addon_state_string(s, state.state);
|
||||
}
|
||||
|
||||
void addon_manager::pre_show(window& window)
|
||||
{
|
||||
load_addon_list(window);
|
||||
listbox& list = find_widget<listbox>(&window, "addons", false);
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
|
||||
/*
|
||||
list.register_sorting_option(0, [this](const int i) { return addon_at(ids_[i], addons_).title; });
|
||||
list.register_sorting_option(1, [this](const int i) { return addon_at(ids_[i], addons_).author; });
|
||||
list.register_sorting_option(2, [this](const int i) { return addon_at(ids_[i], addons_).size; });
|
||||
list.register_sorting_option(3, [this](const int i) { return addon_at(ids_[i], addons_).downloads; });
|
||||
list.register_sorting_option(4, [this](const int i) { return addon_at(ids_[i], addons_).type; });
|
||||
*/
|
||||
|
||||
find_widget<text_box>(&window, "filter", false).set_text_changed_callback(
|
||||
std::bind(&addon_manager::on_filtertext_changed, this, _1, _2));
|
||||
|
@ -395,69 +329,19 @@ void addon_manager::load_addon_list(window& window)
|
|||
|
||||
read_addons_list(cfg_, addons_);
|
||||
|
||||
listbox& list = find_widget<listbox>(&window, "addons", false);
|
||||
list.clear();
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
list.set_addons(addons_);
|
||||
|
||||
ids_.clear();
|
||||
|
||||
for(const auto & c : cfg_.child_range("campaign"))
|
||||
for(const auto& a : addons_)
|
||||
{
|
||||
ids_.push_back(c["name"]);
|
||||
ids_.push_back(a.first);
|
||||
const addon_info& info = addon_at(ids_.back(), addons_);
|
||||
tracking_info_[info.id] = get_addon_tracking_info(info);
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
string_map item;
|
||||
|
||||
item["use_markup"] = "true";
|
||||
|
||||
item["label"] = info.display_icon();
|
||||
data.emplace("icon", item);
|
||||
|
||||
item["label"] = info.display_title();
|
||||
data.emplace("name", item);
|
||||
|
||||
item["label"] = describe_status_simple(tracking_info_[info.id]);
|
||||
data.emplace("installation_status", item);
|
||||
|
||||
item["label"] = info.version.str();
|
||||
data.emplace("version", item);
|
||||
|
||||
item["label"] = info.author;
|
||||
data.emplace("author", item);
|
||||
|
||||
item["label"] = size_display_string(info.size);
|
||||
data.emplace("size", item);
|
||||
|
||||
item["label"] = std::to_string(info.downloads);
|
||||
data.emplace("downloads", item);
|
||||
|
||||
item["label"] = info.display_type();
|
||||
data.emplace("type", item);
|
||||
|
||||
grid* row_grid = &list.add_row(data);
|
||||
|
||||
stacked_widget& install_update_stack = find_widget<stacked_widget>(row_grid, "install_update_stack", false);
|
||||
|
||||
const bool is_updatable = tracking_info_[info.id].state == ADDON_INSTALLED_UPGRADABLE;
|
||||
const bool is_installed = tracking_info_[info.id].state == ADDON_INSTALLED;
|
||||
|
||||
install_update_stack.select_layer(is_updatable);
|
||||
|
||||
if(!is_updatable) {
|
||||
find_widget<button>(row_grid, "single_install", false).set_active(!is_installed);
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(row_grid, "single_install", false),
|
||||
[this, info, &window](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
|
||||
{
|
||||
install_addon(info, window);
|
||||
handled = true;
|
||||
halt = true;
|
||||
});
|
||||
}
|
||||
|
||||
find_widget<button>(row_grid, "single_uninstall", false).set_active(is_installed);
|
||||
}
|
||||
|
||||
// TODO: wire up the install buttons in some way
|
||||
}
|
||||
|
||||
unsigned int addon_manager::get_addon_index(listbox& addon_list, const std::string& id)
|
||||
|
@ -492,8 +376,8 @@ void addon_manager::options_button_callback(window& window)
|
|||
|
||||
void addon_manager::install_selected_addon(window& window)
|
||||
{
|
||||
listbox& addon_list = find_widget<listbox>(&window, "addons", false);
|
||||
const int index = addon_list.get_selected_row();
|
||||
addon_list& addons = find_widget<addon_list>(&window, "addons", false);
|
||||
const int index = addons.get_selected_row();
|
||||
|
||||
if(index == -1) {
|
||||
return;
|
||||
|
@ -504,7 +388,7 @@ void addon_manager::install_selected_addon(window& window)
|
|||
|
||||
void addon_manager::install_addon(addon_info addon, window& window)
|
||||
{
|
||||
listbox& addon_list = find_widget<listbox>(&window, "addons", false);
|
||||
listbox& addon_listbox = find_widget<addon_list>(&window, "addons", false).get_listbox();
|
||||
config archive;
|
||||
bool download_succeeded = client_.download_addon(archive, addon.id, addon.title);
|
||||
if(download_succeeded)
|
||||
|
@ -515,7 +399,7 @@ void addon_manager::install_addon(addon_info addon, window& window)
|
|||
load_addon_list(window);
|
||||
|
||||
// Reselect the add-on.
|
||||
addon_list.select_row(get_addon_index(addon_list, addon.id));
|
||||
addon_listbox.select_row(get_addon_index(addon_listbox, addon.id));
|
||||
on_addon_select(window);
|
||||
|
||||
return;
|
||||
|
@ -566,7 +450,7 @@ static std::string format_addon_time(time_t time)
|
|||
|
||||
void addon_manager::on_addon_select(window& window)
|
||||
{
|
||||
const int index = find_widget<listbox>(&window, "addons", false).get_selected_row();
|
||||
const int index = find_widget<addon_list>(&window, "addons", false).get_selected_row();
|
||||
|
||||
if(index == -1) {
|
||||
return;
|
||||
|
|
230
src/gui/widgets/addon_list.cpp
Normal file
230
src/gui/widgets/addon_list.cpp
Normal file
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
Copyright (C) 2017 by the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/widgets/addon_list.hpp"
|
||||
|
||||
#include <gettext.hpp>
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/register_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/stacked_widget.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
REGISTER_WIDGET(addon_list)
|
||||
|
||||
std::string addon_list::colorify_addon_state_string(const std::string& str, ADDON_STATUS state, bool verbose)
|
||||
{
|
||||
std::string colorname = "";
|
||||
|
||||
switch(state) {
|
||||
case ADDON_NONE:
|
||||
if(!verbose) {
|
||||
return str;
|
||||
}
|
||||
colorname = "#a69275";
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
case ADDON_NOT_TRACKED:
|
||||
colorname = "#00ff00"; // GOOD_COLOR
|
||||
break;
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
colorname = "#ffff00"; // YELLOW_COLOR/color_upgradable
|
||||
break;
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
colorname = "#ff7f00"; // <255,127,0>/color_outdated
|
||||
break;
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
colorname = "#ff0000"; // BAD_COLOR
|
||||
break;
|
||||
default:
|
||||
colorname = "#777777"; // GRAY_COLOR
|
||||
break;
|
||||
}
|
||||
|
||||
return "<span color='" + colorname + "'>" + str + "</span>";
|
||||
}
|
||||
|
||||
std::string addon_list::describe_status(const addon_tracking_info& info)
|
||||
{
|
||||
std::string tc, tx;
|
||||
|
||||
switch(info.state) {
|
||||
case ADDON_NONE:
|
||||
tx = info.can_publish ? _("addon_state^Published, not installed") : _("addon_state^Not installed");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED:
|
||||
case ADDON_NOT_TRACKED:
|
||||
// Consider add-ons without version information as installed
|
||||
// for the main display. Their Description info should elaborate
|
||||
// on their status.
|
||||
tx = info.can_publish ? _("addon_state^Published") : _("addon_state^Installed");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
tx = info.can_publish ? _("addon_state^Published, upgradable") : _("addon_state^Installed, upgradable");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
tx = info.can_publish ? _("addon_state^Published, outdated on server") : _("addon_state^Installed, outdated on server");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
tx = info.can_publish ? _("addon_state^Published, broken") : _("addon_state^Installed, broken");
|
||||
break;
|
||||
|
||||
default:
|
||||
tx = _("addon_state^Unknown");
|
||||
}
|
||||
|
||||
return colorify_addon_state_string(tx, info.state, true);
|
||||
}
|
||||
|
||||
void addon_list::set_addons(const addons_list& addons)
|
||||
{
|
||||
listbox& list = get_listbox();
|
||||
list.clear();
|
||||
|
||||
for(const auto& a : addons) {
|
||||
const addon_info& addon = a.second;
|
||||
addon_tracking_info tracking_info = get_addon_tracking_info(addon);
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
string_map item;
|
||||
|
||||
item["use_markup"] = "true";
|
||||
|
||||
item["label"] = addon.display_icon();
|
||||
data.emplace("icon", item);
|
||||
|
||||
item["label"] = addon.display_title();
|
||||
data.emplace("name", item);
|
||||
|
||||
item["label"] = describe_status(tracking_info);
|
||||
data.emplace("installation_status", item);
|
||||
|
||||
item["label"] = addon.version.str();
|
||||
data.emplace("version", item);
|
||||
|
||||
item["label"] = addon.author;
|
||||
data.emplace("author", item);
|
||||
|
||||
item["label"] = size_display_string(addon.size);
|
||||
data.emplace("size", item);
|
||||
|
||||
item["label"] = std::to_string(addon.downloads);
|
||||
data.emplace("downloads", item);
|
||||
|
||||
item["label"] = addon.display_type();
|
||||
data.emplace("type", item);
|
||||
|
||||
grid* row_grid = &list.add_row(data);
|
||||
|
||||
stacked_widget& install_update_stack = find_widget<stacked_widget>(row_grid, "install_update_stack", false);
|
||||
|
||||
const bool is_updatable = tracking_info.state == ADDON_INSTALLED_UPGRADABLE;
|
||||
const bool is_installed = tracking_info.state == ADDON_INSTALLED;
|
||||
|
||||
install_update_stack.select_layer(static_cast<int>(is_updatable));
|
||||
|
||||
if(!is_updatable) {
|
||||
find_widget<button>(row_grid, "single_install", false).set_active(!is_installed);
|
||||
}
|
||||
|
||||
find_widget<button>(row_grid, "single_uninstall", false).set_active(is_installed);
|
||||
|
||||
find_widget<grid>(row_grid, "single_install_buttons", false).set_visible(install_buttons_visibility_);
|
||||
find_widget<label>(row_grid, "installation_status", false).set_visible(install_status_visibility_);
|
||||
}
|
||||
}
|
||||
|
||||
addon_list_definition::addon_list_definition(const config& cfg) :
|
||||
styled_widget_definition(cfg)
|
||||
{
|
||||
DBG_GUI_P << "Parsing add-on list " << id << "\n";
|
||||
|
||||
load_resolutions<resolution>(cfg);
|
||||
}
|
||||
|
||||
addon_list_definition::resolution::resolution(const config& cfg) :
|
||||
resolution_definition(cfg), grid(nullptr)
|
||||
{
|
||||
// Add a dummy state since every widget needs a state.
|
||||
static config dummy("draw");
|
||||
state.push_back(state_definition(dummy));
|
||||
|
||||
const config& child = cfg.child("grid");
|
||||
VALIDATE(child, _("No grid defined."));
|
||||
|
||||
grid = std::make_shared<builder_grid>(child);
|
||||
}
|
||||
|
||||
namespace implementation
|
||||
{
|
||||
|
||||
static widget::visibility parse_visibility(const std::string& str)
|
||||
{
|
||||
if(str == "visible") {
|
||||
return widget::visibility::visible;
|
||||
} else if(str == "hidden") {
|
||||
return widget::visibility::hidden;
|
||||
} else if(str == "invisible") {
|
||||
return widget::visibility::invisible;
|
||||
} else {
|
||||
throw std::exception("Invalid visibility value");
|
||||
}
|
||||
}
|
||||
|
||||
builder_addon_list::builder_addon_list(const config& cfg) :
|
||||
builder_styled_widget(cfg),
|
||||
install_status_visibility_(widget::visibility::visible),
|
||||
install_buttons_visibility_(widget::visibility::invisible)
|
||||
{
|
||||
if(cfg.has_attribute("install_status_visibility")) {
|
||||
install_status_visibility_ = parse_visibility(cfg["install_status_visibility"]);
|
||||
}
|
||||
if(cfg.has_attribute("install_buttons_visibility")) {
|
||||
install_buttons_visibility_ = parse_visibility(cfg["install_buttons_visibility"]);
|
||||
}
|
||||
}
|
||||
|
||||
widget* builder_addon_list::build() const
|
||||
{
|
||||
addon_list* widget = new addon_list();
|
||||
|
||||
init_control(widget);
|
||||
|
||||
DBG_GUI_G << "Window builder: placed add-on list '" << id <<
|
||||
"' with definition '" << definition << "'.\n";
|
||||
|
||||
auto conf = std::static_pointer_cast<const addon_list_definition::resolution>(widget->config());
|
||||
assert(conf != nullptr);
|
||||
|
||||
widget->init_grid(conf->grid);
|
||||
|
||||
widget->set_install_status_visibility(install_status_visibility_);
|
||||
widget->set_install_buttons_visibility(install_buttons_visibility_);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
152
src/gui/widgets/addon_list.hpp
Normal file
152
src/gui/widgets/addon_list.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Copyright (C) 2017 by the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_WIDGETS_ADDON_LIST_HPP_INCLUDED
|
||||
#define GUI_WIDGETS_ADDON_LIST_HPP_INCLUDED
|
||||
|
||||
#include "addon/info.hpp"
|
||||
#include "addon/state.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/container_base.hpp"
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/widget.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
namespace implementation
|
||||
{
|
||||
struct builder_addon_list;
|
||||
}
|
||||
|
||||
class addon_list : public container_base
|
||||
{
|
||||
friend struct implementation::builder_addon_list;
|
||||
|
||||
public:
|
||||
addon_list()
|
||||
: container_base(1)
|
||||
, install_status_visibility_(visibility::visible)
|
||||
, install_buttons_visibility_(visibility::invisible)
|
||||
{}
|
||||
|
||||
/** Sets the add-ons to show. */
|
||||
void set_addons(const addons_list& addons);
|
||||
|
||||
/** Sets up a callback that will be called when the player selects an add-on. */
|
||||
void set_callback_value_change(const std::function<void(widget&)>& callback)
|
||||
{
|
||||
get_listbox().set_callback_value_change(callback);
|
||||
}
|
||||
|
||||
/** Returns the index of the selected row. */
|
||||
int get_selected_row() const
|
||||
{
|
||||
const listbox& list = find_widget<const listbox>(&get_grid(), "addons", false);
|
||||
return list.get_selected_row();
|
||||
}
|
||||
|
||||
/** Returns the underlying list box. */
|
||||
listbox& get_listbox()
|
||||
{
|
||||
return find_widget<listbox>(&get_grid(), "addons", false);
|
||||
}
|
||||
|
||||
/** Changes the color of an add-on state string (installed, outdated, etc.)
|
||||
according to the state itself.
|
||||
This function is here because the add-on list widget itself needs it. */
|
||||
static std::string colorify_addon_state_string(const std::string& str, ADDON_STATUS state, bool verbose = false);
|
||||
|
||||
/** Determines if install status of each widget is shown. */
|
||||
void set_install_status_visibility(visibility visibility)
|
||||
{
|
||||
install_status_visibility_ = visibility;
|
||||
}
|
||||
|
||||
/** Determines if install/uninstall buttons are shown for each widget. */
|
||||
void set_install_buttons_visibility(visibility visibility)
|
||||
{
|
||||
install_buttons_visibility_ = visibility;
|
||||
}
|
||||
|
||||
/** See @ref styled_widget::set_active. */
|
||||
virtual void set_active(const bool) override
|
||||
{
|
||||
// DO NOTHING
|
||||
}
|
||||
|
||||
/** See @ref styled_widget::get_active. */
|
||||
virtual bool get_active() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** See @ref styled_widget::get_state. */
|
||||
virtual unsigned get_state() const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
visibility install_status_visibility_;
|
||||
visibility install_buttons_visibility_;
|
||||
|
||||
static std::string describe_status(const addon_tracking_info& info);
|
||||
|
||||
/** See @ref control::get_control_type. */
|
||||
const std::string& get_control_type() const override
|
||||
{
|
||||
static const std::string control_type = "addon_list";
|
||||
return control_type;
|
||||
}
|
||||
|
||||
/** See @ref container_::set_self_active. */
|
||||
void set_self_active(const bool) override
|
||||
{
|
||||
// DO NOTHING
|
||||
}
|
||||
};
|
||||
|
||||
struct addon_list_definition : public styled_widget_definition
|
||||
{
|
||||
explicit addon_list_definition(const config& cfg);
|
||||
|
||||
struct resolution : public resolution_definition
|
||||
{
|
||||
explicit resolution(const config& cfg);
|
||||
|
||||
builder_grid_ptr grid;
|
||||
};
|
||||
};
|
||||
|
||||
namespace implementation
|
||||
{
|
||||
|
||||
struct builder_addon_list : public builder_styled_widget
|
||||
{
|
||||
public:
|
||||
explicit builder_addon_list(const config& cfg);
|
||||
|
||||
using builder_styled_widget::build;
|
||||
|
||||
widget* build() const;
|
||||
|
||||
private:
|
||||
widget::visibility install_status_visibility_;
|
||||
widget::visibility install_buttons_visibility_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue