From b1e8bf98d23da1e7af7e971024d7964099216d05 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 26 Nov 2020 02:05:05 +0200 Subject: [PATCH] Made TransparentChecker shader material unique for the main two viewports Fixes #377. The issue was that the shader material was being shared with the background of the cel buttons, and when the cel button transparent background was resized, the canvas transparent background was also affected. --- CHANGELOG.md | 1 + src/UI/Dialogs/ImageEffects/ResizeCanvas.gd | 3 +-- src/UI/Timeline/CelButton.tscn | 15 +++++++++++- src/UI/TransparentChecker.gd | 4 +-- src/UI/TransparentChecker.tscn | 5 ++++ src/UI/UI.tscn | 27 ++++++++++++++++++++- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de50b520..6eab82f48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ PinyaColada, RĂ©mi Verschelde (akien-mga), dasimonde, gschwind, AbhinavKDev - Fixed "Export" option in the File menu not working properly and not remembering the directory path and file name when switching between projects (tabs). - When opening a .pxo project which has guides, they will no longer be added to the project at the first tab too. - Symmetry guides now adjust their position when the image is being resized. ([#379](https://github.com/Orama-Interactive/Pixelorama/issues/379)) +- Fixed various issues with the transparent background checker size. ([#377](https://github.com/Orama-Interactive/Pixelorama/issues/377)) - Fixed Chinese and Korean characters not displaying properly in the Splash dialog and the About dialog. - Fixed crash when importing an incorrectly formatted GIMP Color Palette file. ([#363](https://github.com/Orama-Interactive/Pixelorama/issues/363)) - Using the lighten/darken on pixels with an alpha value of 0 no longer has an effect on them. diff --git a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd index 3b53063ec..2b7355a9f 100644 --- a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd +++ b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd @@ -38,8 +38,7 @@ func _on_ResizeCanvas_about_to_show() -> void: if first_time: width_spinbox.value = Global.current_project.size.x height_spinbox.value = Global.current_project.size.y - else: - update_preview() + update_preview() func _on_ResizeCanvas_confirmed() -> void: diff --git a/src/UI/Timeline/CelButton.tscn b/src/UI/Timeline/CelButton.tscn index e8fd237c7..3ec82579b 100644 --- a/src/UI/Timeline/CelButton.tscn +++ b/src/UI/Timeline/CelButton.tscn @@ -1,7 +1,19 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://src/UI/Timeline/CelButton.gd" type="Script" id=1] [ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Shaders/TransparentChecker.shader" type="Shader" id=3] + +[sub_resource type="ShaderMaterial" id=1] +shader = ExtResource( 3 ) +shader_param/size = 10.0 +shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) +shader_param/color2 = Color( 1, 1, 1, 1 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/scale = Vector2( 0, 0 ) +shader_param/rect_size = Vector2( 0, 0 ) +shader_param/follow_movement = false +shader_param/follow_scale = false [node name="CelButton" type="Button"] margin_top = 18.0 @@ -34,6 +46,7 @@ __meta__ = { [node name="TransparentChecker" parent="CelTexture" instance=ExtResource( 2 )] show_behind_parent = true +material = SubResource( 1 ) anchor_right = 1.0 anchor_bottom = 1.0 margin_right = 0.0 diff --git a/src/UI/TransparentChecker.gd b/src/UI/TransparentChecker.gd index 1e74149fd..b1d243394 100644 --- a/src/UI/TransparentChecker.gd +++ b/src/UI/TransparentChecker.gd @@ -19,11 +19,11 @@ func update_offset(offset : Vector2, scale : Vector2) -> void: material.set_shader_param("scale", scale) -func _on_TransparentChecker_resized(): +func _on_TransparentChecker_resized() -> void: material.set_shader_param("rect_size", rect_size) -func _init_position(id : int): +func _init_position(id : int) -> void: match id: 0: Global.current_project.tile_mode = Global.Tile_Mode.NONE diff --git a/src/UI/TransparentChecker.tscn b/src/UI/TransparentChecker.tscn index 7fa0d5116..6324ebcff 100644 --- a/src/UI/TransparentChecker.tscn +++ b/src/UI/TransparentChecker.tscn @@ -8,6 +8,11 @@ shader = ExtResource( 1 ) shader_param/size = 10.0 shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) shader_param/color2 = Color( 1, 1, 1, 1 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/scale = Vector2( 0, 0 ) +shader_param/rect_size = Vector2( 0, 0 ) +shader_param/follow_movement = false +shader_param/follow_scale = false [node name="TransparentChecker" type="ColorRect"] material = SubResource( 1 ) diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index c972171f6..4b1102748 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=26 format=2] [ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1] [ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=2] @@ -8,6 +8,7 @@ [ext_resource path="res://src/UI/Canvas/Rulers/HorizontalRuler.gd" type="Script" id=6] [ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=7] [ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8] +[ext_resource path="res://src/Shaders/TransparentChecker.shader" type="Shader" id=9] [ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10] [ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11] [ext_resource path="res://assets/graphics/dark_themes/tools/rectselect.png" type="Texture" id=12] @@ -22,6 +23,28 @@ [ext_resource path="res://assets/graphics/dark_themes/tools/zoom.png" type="Texture" id=21] [ext_resource path="res://src/UI/ViewportContainer.gd" type="Script" id=23] +[sub_resource type="ShaderMaterial" id=2] +shader = ExtResource( 9 ) +shader_param/size = 10.0 +shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) +shader_param/color2 = Color( 1, 1, 1, 1 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/scale = Vector2( 0, 0 ) +shader_param/rect_size = Vector2( 0, 0 ) +shader_param/follow_movement = false +shader_param/follow_scale = false + +[sub_resource type="ShaderMaterial" id=3] +shader = ExtResource( 9 ) +shader_param/size = 10.0 +shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) +shader_param/color2 = Color( 1, 1, 1, 1 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/scale = Vector2( 0, 0 ) +shader_param/rect_size = Vector2( 0, 0 ) +shader_param/follow_movement = false +shader_param/follow_scale = false + [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.0627451, 0.0627451, 0.0627451, 1 ) expand_margin_top = 6.0 @@ -276,6 +299,7 @@ usage = 0 render_target_update_mode = 3 [node name="TransparentChecker" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer/Viewport" instance=ExtResource( 5 )] +material = SubResource( 2 ) [node name="Canvas" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer/Viewport" instance=ExtResource( 19 )] @@ -307,6 +331,7 @@ handle_input_locally = false render_target_update_mode = 3 [node name="TransparentChecker" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportContainer2/Viewport" instance=ExtResource( 5 )] +material = SubResource( 3 ) [node name="CanvasPreview" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportContainer2/Viewport" instance=ExtResource( 2 )]