Addons List: Hide some columns on lower resolutions

This commit is contained in:
Celtic Minstrel 2017-04-15 21:33:16 -04:00
parent 9ba02c0900
commit cb333dbfdf
2 changed files with 476 additions and 375 deletions

View file

@ -3,7 +3,7 @@
### Definition of an addon list widget
###
#define _GUI_ADDON_LIST
#define _GUI_ADDON_LIST HEADER ROW_DEF
[grid]
[row]
@ -22,120 +22,15 @@
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]
{HEADER}
[/row]
[/header]
[list_definition]
[row]
[column]
vertical_grow = "true"
horizontal_grow = "true"
@ -148,279 +43,473 @@
[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))"
{GUI_CENTERED_IMAGE}
[/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 = "left,right,bottom"
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"
tooltip = _"Install add-on"
[/button]
[/column]
[/row]
[/layer]
[layer]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[button]
id = "single_update"
definition = "update"
tooltip = _"Update add-on"
[/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"
tooltip = _"Uninstall add-on"
[/button]
[/column]
[/row]
[/grid]
[/column]
{ROW_DEF}
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[/grid]
#enddef
#define _GUI_ADDON_LIST_HEADER_BASIC
[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]
#enddef
#define _GUI_ADDON_LIST_HEADER_TYPE
[column]
grow_factor = 1
horizontal_grow = "true"
[toggle_button]
id = "sort_4"
definition = "listbox_header"
linked_group = "type"
label = _ "Type"
[/toggle_button]
[/column]
#enddef
#define _GUI_ADDON_LIST_HEADER_CONTROL
[column]
grow_factor = 1
horizontal_grow = "true"
[spacer]
linked_group = "control_buttons"
[/spacer]
[/column]
#enddef
#define _GUI_ADDON_LIST_CONTENT_BASIC
[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))"
{GUI_CENTERED_IMAGE}
[/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 = "left,right,bottom"
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]
#enddef
#define _GUI_ADDON_LIST_CONTENT_TYPE
[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]
#enddef
#define _GUI_ADDON_LIST_CONTENT_CONTROL
[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"
tooltip = _"Install add-on"
[/button]
[/column]
[/row]
[/layer]
[layer]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[button]
id = "single_update"
definition = "update"
tooltip = _"Update add-on"
[/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"
tooltip = _"Uninstall add-on"
[/button]
[/column]
[/row]
[/grid]
[/column]
#enddef
[addon_list_definition]
id = "default"
description = "List of one or more add-ons."
[resolution]
window_width = 800
window_height = 600
[linked_group]
id = "icon"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "name"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "version"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "author"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "downloads"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "size"
fixed_width = "true"
[/linked_group]
{_GUI_ADDON_LIST (
{_GUI_ADDON_LIST_HEADER_BASIC}
) (
{_GUI_ADDON_LIST_CONTENT_BASIC}
)}
[/resolution]
[resolution]
window_width = 1024
window_height = 768
[linked_group]
id = "icon"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "name"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "version"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "author"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "downloads"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "size"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "control_buttons"
fixed_width = "true"
[/linked_group]
{_GUI_ADDON_LIST (
{_GUI_ADDON_LIST_HEADER_BASIC}
{_GUI_ADDON_LIST_HEADER_CONTROL}
) (
{_GUI_ADDON_LIST_CONTENT_BASIC}
{_GUI_ADDON_LIST_CONTENT_CONTROL}
)}
[/resolution]
[resolution]
[linked_group]
id = "icon"
@ -462,7 +551,15 @@
fixed_width = "true"
[/linked_group]
{_GUI_ADDON_LIST}
{_GUI_ADDON_LIST (
{_GUI_ADDON_LIST_HEADER_BASIC}
{_GUI_ADDON_LIST_HEADER_TYPE}
{_GUI_ADDON_LIST_HEADER_CONTROL}
) (
{_GUI_ADDON_LIST_CONTENT_BASIC}
{_GUI_ADDON_LIST_CONTENT_TYPE}
{_GUI_ADDON_LIST_CONTENT_CONTROL}
)}
[/resolution]
[/addon_list_definition]

View file

@ -173,6 +173,10 @@ void addon_list::set_addons(const addons_list& addons)
// Set special retval for the toggle panels
find_widget<toggle_panel>(row_grid, "list_panel", false).set_retval(INSTALL_ADDON_RETVAL);
grid* control_grid = find_widget<grid>(row_grid, "single_install_buttons", false, false);
if(!control_grid) {
continue;
}
stacked_widget& install_update_stack = find_widget<stacked_widget>(row_grid, "install_update_stack", false);
if(!tracking_info.can_publish) {
@ -183,10 +187,10 @@ void addon_list::set_addons(const addons_list& addons)
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>(control_grid, "single_install", false).set_active(!is_installed);
if(install_function_ != nullptr) {
gui2::event::connect_signal_mouse_left_click(
find_widget<button>(row_grid, "single_install", false),
find_widget<button>(control_grid, "single_install", false),
[this, addon](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
{
install_function_(addon);
@ -195,10 +199,10 @@ void addon_list::set_addons(const addons_list& addons)
});
}
} else {
find_widget<button>(row_grid, "single_update", false).set_active(true);
find_widget<button>(control_grid, "single_update", false).set_active(true);
if(update_function_ != nullptr) {
gui2::event::connect_signal_mouse_left_click(
find_widget<button>(row_grid, "single_update", false),
find_widget<button>(control_grid, "single_update", false),
[this, addon](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
{
update_function_(addon);
@ -211,7 +215,7 @@ void addon_list::set_addons(const addons_list& addons)
if(is_installed) {
if(uninstall_function_ != nullptr) {
gui2::event::connect_signal_mouse_left_click(
find_widget<button>(row_grid, "single_uninstall", false),
find_widget<button>(control_grid, "single_uninstall", false),
[this, addon](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
{
uninstall_function_(addon);
@ -221,16 +225,16 @@ void addon_list::set_addons(const addons_list& addons)
}
}
find_widget<button>(row_grid, "single_uninstall", false).set_active(is_installed);
find_widget<button>(control_grid, "single_uninstall", false).set_active(is_installed);
find_widget<grid>(row_grid, "single_install_buttons", false).set_visible(install_buttons_visibility_);
find_widget<grid>(control_grid, "single_install_buttons", false).set_visible(install_buttons_visibility_);
find_widget<label>(row_grid, "installation_status", false).set_visible(install_status_visibility_);
} else {
const bool is_updatable = tracking_info.state == ADDON_INSTALLED_OUTDATED;
button& install_button = find_widget<button>(row_grid, "single_install", false);
button& update_button = find_widget<button>(row_grid, "single_update", false);
button& uninstall_button = find_widget<button>(row_grid, "single_uninstall", false);
button& install_button = find_widget<button>(control_grid, "single_install", false);
button& update_button = find_widget<button>(control_grid, "single_update", false);
button& uninstall_button = find_widget<button>(control_grid, "single_uninstall", false);
install_button.set_active(true);
update_button.set_active(true);