Vertically center the question+choices block before an answer is submitted
Fixes the large empty gap below the answer choices reported after the answer-row redesign - the stem+choices VBox was pinned to the top of an expand-filled scroll panel with all the leftover height sitting unused below choice E. Now centers that block when unanswered and reverts to top alignment once the explanation/review content grows underneath it.
This commit is contained in:
@@ -386,12 +386,14 @@ func _ready() -> void:
|
||||
|
||||
var content_margin := MarginContainer.new()
|
||||
content_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
content_margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
content_margin.add_theme_constant_override("margin_left", 4)
|
||||
content_margin.add_theme_constant_override("margin_right", 12)
|
||||
question_scroll.add_child(content_margin)
|
||||
|
||||
question_content = VBoxContainer.new()
|
||||
question_content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
question_content.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
question_content.add_theme_constant_override("separation", 12)
|
||||
content_margin.add_child(question_content)
|
||||
|
||||
@@ -1498,6 +1500,7 @@ func _show_explanation() -> void:
|
||||
correct_answer_heading.text = "Correct Answer: %s" % _display_label_for_choice_id(correct_id)
|
||||
_update_question_elo_label(true)
|
||||
_refresh_nav_palette()
|
||||
_update_content_vertical_alignment()
|
||||
|
||||
|
||||
func _render_answer_review_sections() -> void:
|
||||
@@ -1520,6 +1523,19 @@ func _clear_answer_review() -> void:
|
||||
review_followups_section.visible = false
|
||||
if wrong_options_section != null:
|
||||
wrong_options_section.visible = false
|
||||
_update_content_vertical_alignment()
|
||||
|
||||
|
||||
func _update_content_vertical_alignment() -> void:
|
||||
if question_content == null:
|
||||
return
|
||||
# Before an answer is submitted the stem+choices block is usually shorter than the
|
||||
# available panel height; center it so it doesn't sit pinned to the top with a slab
|
||||
# of empty space below. Once the answer review content appears, go back to top
|
||||
# alignment so the growing explanation/follow-up sections read top-down and scroll
|
||||
# naturally instead of being centered mid-panel.
|
||||
var answered := correct_review_panel != null and correct_review_panel.visible
|
||||
question_content.alignment = BoxContainer.ALIGNMENT_BEGIN if answered else BoxContainer.ALIGNMENT_CENTER
|
||||
|
||||
|
||||
func _clear_container_children(container: Control) -> void:
|
||||
|
||||
Reference in New Issue
Block a user