1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-01 07:59:48 +00:00
Pixelorama/src/UI/Nodes/CollapsibleContainer.gd

78 lines
2.2 KiB
GDScript3
Raw Normal View History

Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
tool
class_name CollapsibleContainer
extends VBoxContainer
export var text := "" setget _set_text
export var visible_content := false setget _set_visible_content
var _button := Button.new()
var _texture_rect := TextureRect.new()
var _label := Label.new()
func _init() -> void:
theme_type_variation = "CollapsibleContainer"
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
func _ready() -> void:
_button.toggle_mode = true
_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
_button.connect("toggled", self, "_on_Button_toggled")
add_child(_button)
move_child(_button, 0)
_texture_rect.anchor_top = 0.5
_texture_rect.anchor_bottom = 0.5
_texture_rect.margin_left = 2
_texture_rect.margin_top = -6
_texture_rect.margin_right = 14
_texture_rect.margin_bottom = 6
_texture_rect.rect_rotation = -90
_texture_rect.rect_pivot_offset = Vector2(6, 6)
_texture_rect.add_to_group("UIButtons")
_button.add_child(_texture_rect)
_label.valign = Label.VALIGN_CENTER
_label.rect_position = Vector2(14, 0)
_label.size_flags_vertical = Control.SIZE_SHRINK_CENTER
_button.add_child(_label)
_button.pressed = visible_content
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
for child in get_children():
if not child is CanvasItem or child == _button:
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
continue
child.connect("visibility_changed", self, "_child_visibility_changed", [child])
func _notification(what: int) -> void:
if what == NOTIFICATION_THEME_CHANGED:
_texture_rect.texture = get_icon("arrow_normal", "CollapsibleContainer")
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
func _set_text(value: String) -> void:
text = value
_label.text = value
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
func _set_visible_content(value: bool) -> void:
visible_content = value
_button.pressed = value
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
func _on_Button_toggled(button_pressed: bool) -> void:
_set_visible(button_pressed)
func _set_visible(pressed: bool) -> void:
var angle := 0.0 if pressed else -90.0
var tween := create_tween()
tween.tween_property(_texture_rect, "rect_rotation", angle, 0.05)
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
for child in get_children():
if not child is CanvasItem or child == _button:
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
continue
child.visible = pressed
# Checks if a child becomes visible from another sure and ensures
# it remains invisible if the button is not pressed
func _child_visibility_changed(child: CanvasItem) -> void:
if not _button.pressed:
Export dialog UX overhaul (#781) * Remove animation tab from the export dialog, unify it with the first tab * Tidy up the UI using GridContainers * Make ExportDialog a ConfirmationDialog and clean some code * Make project a parameter in export methods This will be useful in the future for exporting multiple projects at once via terminal arguments * Add a layers option in the export dialog Currently only visible layers and selected layers, need to add specific layer selection and handle group blending properly. * Align everything to the left * Change "directory" into "folder" * Make animation direction affect spritesheets and multiple png exporting Besides just gifs and apngs * Minor code re-organization * Keep spritesheet options when changing tab * Use the Unicode multiplication sign in the dimension label * Specific layer exporting with group blending support * Change file format cursor mode to pointing hand instead of forbidden * Add a new custom CollapsibleContainer node and use it for advanced settings in the export dialog * Change Popups node into Control so its children will automatically inherit the theme * Add the TextureRect of the CollapsibleContainer in the UIButtons group * Update ExportDialog.gd * Disable "Create new folder for each frame tag" when gif/apng is selected, and hide it completely on the spritesheet tab * Fix "Create new folder for each frame tag" being visible even if the CollapsibleContainer's button is not pressed * Show layer path for each layer in the export dialog's "Layers" option * Update translations * Update strings
2022-11-28 19:22:29 +00:00
child.visible = false