-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #733 from Jowan-Spooner/better-preview-panels-new
Better Preview 2D Panel UI/UX
- Loading branch information
Showing
46 changed files
with
5,726 additions
and
4,685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
material_maker/panels/common/menu_bar_button_with_panel.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
extends Button | ||
|
||
@onready var panel := get_child(0) | ||
@export var icon_name := "" | ||
|
||
var pinned := false | ||
var theme_arrow_icon: Texture2D | ||
|
||
|
||
func _ready() -> void: | ||
custom_minimum_size = Vector2(35, 25) | ||
toggle_mode = true | ||
button_mask = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | ||
toggled.connect(_on_toggled) | ||
owner.resized.connect(position_panel) | ||
|
||
panel.hide() | ||
|
||
theme_arrow_icon = get_theme_icon("arrow", "OptionButton") | ||
icon = get_theme_icon(icon_name, "MM_Icons") | ||
|
||
|
||
func _draw() -> void: | ||
if pinned: | ||
draw_circle(Vector2(size.x-2, 2), 4, get_theme_color("icon_pressed_color")) | ||
draw_texture(theme_arrow_icon, Vector2(18, 5), get_theme_color("icon_normal_color")) | ||
|
||
|
||
func _on_toggled(pressed:bool) -> void: | ||
panel.visible = pressed | ||
|
||
if panel.visible: | ||
position_panel() | ||
if panel.has_method("_open"): | ||
panel._open() | ||
else: | ||
pinned = false | ||
|
||
|
||
func position_panel() -> void: | ||
var at_position := global_position | ||
at_position.x += size.x/2 - panel.size.x/2 | ||
at_position.x = max(at_position.x, get_parent().get_child(0).global_position.x) | ||
at_position.y += size.y + 6 | ||
panel.global_position = at_position | ||
|
||
|
||
func _input(event:InputEvent) -> void: | ||
if event.is_pressed(): | ||
mm_globals.propagate_shortcuts(self, event) | ||
|
||
if not panel.visible: | ||
return | ||
|
||
if event is InputEventMouseButton: | ||
var node := get_viewport().gui_get_hovered_control() | ||
if node != self and not is_ancestor_of(node) and (not pinned or (node and node.script == self.script)): | ||
button_pressed = false | ||
|
||
|
||
func _gui_input(event: InputEvent) -> void: | ||
if event is InputEventMouseButton and not event.pressed: | ||
if event.button_index == MOUSE_BUTTON_RIGHT: | ||
if not pinned and button_pressed: | ||
get_viewport().set_input_as_handled() | ||
pinned = true | ||
grab_focus() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://c37lcka7r53wk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.