Story Viewer: deployed new alignment set API
The set_origin method worked, but not in every circumstance. For example, if the story box were not aligned to the bottom of the screen in the initial part, it would not be correctly place. If you resized the screen while the box was not at the bottom, it would return there. This was due to set_origin being purely temporary - ie, the layout engine did not record the new position, and when invalidate_layout was called, the default (per the dialog WML) position of 'bottom' was restored. This new method fixes the above issues. It also fixes an issue the old GUI2 screen had where a top-aligned box would also obscure any available title.
This commit is contained in:
parent
d7b564e2a7
commit
5fbd4a727b
3 changed files with 32 additions and 16 deletions
|
@ -38,7 +38,7 @@
|
|||
y = 0
|
||||
w = "(width)"
|
||||
resize_mode = "stretch"
|
||||
name = "(if(panel_mode = 'middle' or panel_mode = 'bottom', 'dialogs/" + {_GUI_BASE_NAME} + "-border-top.png', ''))"
|
||||
name = "(if(panel_mode = 'center' or panel_mode = 'bottom', 'dialogs/" + {_GUI_BASE_NAME} + "-border-top.png', ''))"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
|
@ -46,7 +46,7 @@
|
|||
y = "(height - image_height)"
|
||||
w = "(width)"
|
||||
resize_mode = "stretch"
|
||||
name = "(if(panel_mode = 'middle' or panel_mode = 'top', 'dialogs/" + {_GUI_BASE_NAME} + "-border-bottom.png', ''))"
|
||||
name = "(if(panel_mode = 'center' or panel_mode = 'top', 'dialogs/" + {_GUI_BASE_NAME} + "-border-bottom.png', ''))"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
|
|
@ -4,6 +4,29 @@
|
|||
[stacked_widget]
|
||||
id = "text_and_control_stack"
|
||||
|
||||
# In order to ensure this widget is directly within the main grid holding it
|
||||
# instead of within a parent stacked_widget, we place the min sizing grid here.
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
|
||||
[spacer]
|
||||
definition = "default"
|
||||
height = "(screen_height / 4)"
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
@ -89,7 +112,7 @@
|
|||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
@ -213,9 +236,7 @@
|
|||
horizontal_grow = true
|
||||
vertical_alignment = "bottom"
|
||||
|
||||
{GUI_FORCE_WIDGET_MINIMUM_SIZE 0 ("(screen_height / 4)") (
|
||||
{_GUI_MAIN_STACK}
|
||||
)}
|
||||
{_GUI_MAIN_STACK}
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
|
|
@ -224,37 +224,32 @@ void story_viewer::display_part(window& window)
|
|||
stacked_widget& text_stack = find_widget<stacked_widget>(&window, "text_and_control_stack", false);
|
||||
|
||||
std::string new_panel_mode;
|
||||
gui2::point new_origin;
|
||||
|
||||
switch(current_part_->story_text_location()) {
|
||||
case storyscreen::part::BLOCK_TOP:
|
||||
new_panel_mode = "top";
|
||||
// Default 0,0 origin value is correct.
|
||||
break;
|
||||
case storyscreen::part::BLOCK_MIDDLE:
|
||||
new_panel_mode = "middle";
|
||||
new_origin.y = (window.get_size().y / 2) - (text_stack.get_size().y / 2);
|
||||
new_panel_mode = "center";
|
||||
break;
|
||||
case storyscreen::part::BLOCK_BOTTOM:
|
||||
new_panel_mode = "bottom";
|
||||
new_origin.y = window.get_size().y - text_stack.get_size().y;
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: sometimes the text won't appear after a move...
|
||||
text_stack.set_origin(new_origin);
|
||||
text_stack.set_vertical_alignment(new_panel_mode);
|
||||
|
||||
// Set the panel mode control variable for the panel's borders.
|
||||
// We use get_layer_grid here to ensure the widget is always found regardless of
|
||||
// whether the background is visible or not.
|
||||
find_widget<panel>(text_stack.get_layer_grid(0), "text_panel", false).get_canvas(0)
|
||||
.set_variable("panel_mode", wfl::variant(new_panel_mode));
|
||||
find_widget<panel>(text_stack.get_layer_grid(1), "text_panel", false)
|
||||
.get_canvas(0).set_variable("panel_mode", wfl::variant(new_panel_mode));
|
||||
|
||||
const std::string& part_text = current_part_->text();
|
||||
|
||||
if(part_text.empty() || !has_background) {
|
||||
// No text or no background for this part, hide the background layer.
|
||||
text_stack.select_layer(1);
|
||||
text_stack.select_layer(2);
|
||||
} else if(text_stack.current_layer() != -1) {
|
||||
// If the background layer was previously hidden, re-show it.
|
||||
text_stack.select_layer(-1);
|
||||
|
|
Loading…
Add table
Reference in a new issue