1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Refactored CreateNewImage dialog and added portrait & landscape buttons from #402

The lock aspect ratio button has been changed from a checkbox to a texture button and the template code has been refactored to use a Template class instead of enums. Only dark icons have been added for now.
This commit is contained in:
Manolis Papadeas 2021-01-25 22:07:02 +02:00
parent 6cb525ad92
commit 93bbfabb99
15 changed files with 411 additions and 133 deletions

View file

@ -16,6 +16,7 @@ Laurenz Reinthaler (Schweini07), kleonc
- Added a new pixel grid, which is a grid of size 1px and it appears after a certain zoom level. ([#427](https://github.com/Orama-Interactive/Pixelorama/pull/427))
- Addet offset options to the grid. ([#434](https://github.com/Orama-Interactive/Pixelorama/pull/434))
- The isometric grid has been refactored to work better and to offer more changeable options, such as the width and height of the cell bounds. ([#430](https://github.com/Orama-Interactive/Pixelorama/pull/430))
- Added portrait and landscape buttons in the new image dialog.
### Changed
- Undo and redo now work when their respective keyboard shortcuts are being held. ([#405](https://github.com/Orama-Interactive/Pixelorama/pull/405))
@ -23,6 +24,7 @@ Laurenz Reinthaler (Schweini07), kleonc
- The FPS of the project animation is now stored in the pxo file. This effectively means that every project can have its own FPS.
- You can now toggle if you want the grid to be drawn over the tile mode or just the original part of the canvas. ([#434](https://github.com/Orama-Interactive/Pixelorama/pull/434))
- Frame tags can now be set for frames larger than 100. ([#408](https://github.com/Orama-Interactive/Pixelorama/pull/408))
- The "lock aspect ratio" button in the create new image dialog has been changed to a texture button.
### Fixed
- Fixed layer button textures not being updated properly when changing theme. ([#404](https://github.com/Orama-Interactive/Pixelorama/issues/404))

View file

@ -1391,7 +1391,13 @@ msgstr ""
msgid "A default background color of a new image"
msgstr ""
msgid "Lock aspect ratio:"
msgid "Lock aspect ratio"
msgstr ""
msgid "Portrait"
msgstr ""
msgid "Landscape"
msgstr ""
msgid "Templates:"

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/landscape.png-f0f137958836bc63f663287e750f2e0f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/dark_themes/misc/landscape.png"
dest_files=[ "res://.import/landscape.png-f0f137958836bc63f663287e750f2e0f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/lock_aspect.png-2920615523ea4c8984ebafa931aba21c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/dark_themes/misc/lock_aspect.png"
dest_files=[ "res://.import/lock_aspect.png-2920615523ea4c8984ebafa931aba21c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/lock_aspect_2.png-309fbe1c00b71f9c9e1f08c5968c1e4b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/dark_themes/misc/lock_aspect_2.png"
dest_files=[ "res://.import/lock_aspect_2.png-309fbe1c00b71f9c9e1f08c5968c1e4b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/lock_aspect_guides.png-98601575a2af1a4fd42ca9c1899b1bc7.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/dark_themes/misc/lock_aspect_guides.png"
dest_files=[ "res://.import/lock_aspect_guides.png-98601575a2af1a4fd42ca9c1899b1bc7.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/portrait.png-b586ce54479600a501e2a9b10ad742c1.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/dark_themes/misc/portrait.png"
dest_files=[ "res://.import/portrait.png-b586ce54479600a501e2a9b10ad742c1.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -113,7 +113,7 @@ boot_splash/bg_color=Color( 0.145098, 0.145098, 0.164706, 1 )
config/icon="res://assets/graphics/icons/icon.png"
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
config/Version="v0.8.2-stable"
config/Version="v0.8.3-dev"
[audio]

View file

@ -1,76 +1,58 @@
extends ConfirmationDialog
onready var templates_options = $VBoxContainer/OptionsContainer/TemplatesOptions
onready var ratio_box = $VBoxContainer/OptionsContainer/RatioCheckBox
onready var width_value = $VBoxContainer/OptionsContainer/WidthValue
onready var height_value = $VBoxContainer/OptionsContainer/HeightValue
onready var fill_color_node = $VBoxContainer/OptionsContainer/FillColor
onready var size_value = Vector2()
class Template:
var resolution : Vector2
var name : String
# Template Id identifier
enum Templates {
TDefault = 0,
T16 = 1,
T32 = 2,
T64 = 3,
T128 = 4,
GB = 5,
GBA = 6,
NES_NTSC = 7,
NES_PAL = 8,
SNES_NTSC = 9,
SNES_PAL = 10
}
# Template actual value, without Default because we get it from Global
var TResolutions = {
Templates.T16: Vector2(16,16),
Templates.T32: Vector2(32,32),
Templates.T64: Vector2(64,64),
Templates.T128: Vector2(128,128),
Templates.GB: Vector2(160,144),
Templates.GBA: Vector2(240,160),
Templates.NES_NTSC: Vector2(256,224),
Templates.NES_PAL: Vector2(256,240),
Templates.SNES_NTSC: Vector2(512,448),
Templates.SNES_PAL: Vector2(512,480),
}
func _init(_resolution : Vector2, _name := "") -> void:
resolution = _resolution
name = _name
var TStrings ={
Templates.T16: "",
Templates.T32: "",
Templates.T64: "",
Templates.T128: "",
Templates.GB: "GB",
Templates.GBA: "GBA",
Templates.NES_NTSC: "NES (NTSC)",
Templates.NES_PAL: "NES (PAL)",
Templates.SNES_NTSC: "SNES (NTSC)",
Templates.SNES_PAL: "SNES (PAL)"
}
var aspect_ratio := 1.0
var templates := [
Template.new(Vector2(16, 16)),
Template.new(Vector2(32, 32)),
Template.new(Vector2(64, 64)),
Template.new(Vector2(128, 128)),
Template.new(Vector2(160, 144), "GB"),
Template.new(Vector2(240, 160), "GBA"),
Template.new(Vector2(256, 224), "NES (NTSC)"),
Template.new(Vector2(256, 240), "NES (PAL)"),
Template.new(Vector2(512, 448), "SNES (NTSC)"),
Template.new(Vector2(512, 480), "SNES (PAL)"),
]
onready var templates_options = find_node("TemplatesOptions")
onready var ratio_box = find_node("AspectRatioButton")
onready var width_value = find_node("WidthValue")
onready var height_value = find_node("HeightValue")
onready var portrait_button = find_node("PortraitButton")
onready var landscape_button = find_node("LandscapeButton")
onready var fill_color_node = find_node("FillColor")
func _ready() -> void:
width_value.value = Global.default_image_width
height_value.value = Global.default_image_height
aspect_ratio = width_value.value / height_value.value
fill_color_node.color = Global.default_fill_color
fill_color_node.get_picker().presets_visible = false
ratio_box.connect("pressed", self, "_on_RatioCheckBox_toggled", [ratio_box.pressed])
templates_options.connect("item_selected", self, "_on_TemplatesOptions_item_selected")
_CreateOptionList()
_create_option_list()
func _CreateOptionList() -> void:
for i in Templates.values():
if i > 0:
if TStrings[i] != "":
templates_options.add_item("{width}x{height} - {name}".format({"width":TResolutions[i].x, "height":TResolutions[i].y, "name":TStrings[i]}), i)
else:
templates_options.add_item("{width}x{height}".format({"width":TResolutions[i].x, "height":TResolutions[i].y}), i)
func _create_option_list() -> void:
var i := 1
for template in templates:
if template.name != "":
templates_options.add_item("{width}x{height} - {name}".format({"width":template.resolution.x, "height":template.resolution.y, "name":template.name}), i)
else:
templates_options.add_item("{width}x{height}".format({"width":template.resolution.x, "height":template.resolution.y}), i)
i += 1
func _on_CreateNewImage_confirmed() -> void:
@ -87,30 +69,61 @@ func _on_CreateNewImage_confirmed() -> void:
Global.canvas.camera_zoom()
var aspect_ratio: float
func _on_RatioCheckBox_toggled(_button_pressed: bool) -> void:
func _on_AspectRatioButton_toggled(_button_pressed : bool) -> void:
aspect_ratio = width_value.value / height_value.value
for spin_box in [width_value, height_value]:
if spin_box.is_connected("value_changed", self, "_on_SizeValue_value_changed"):
spin_box.disconnect("value_changed", self, "_on_SizeValue_value_changed")
else:
spin_box.connect("value_changed", self, "_on_SizeValue_value_changed")
func _on_SizeValue_value_changed(value: float) -> void:
if width_value.value == value:
height_value.value = width_value.value / aspect_ratio
if height_value.value == value:
width_value.value = height_value.value * aspect_ratio
if ratio_box.pressed:
if width_value.value == value:
height_value.value = width_value.value / aspect_ratio
if height_value.value == value:
width_value.value = height_value.value * aspect_ratio
toggle_size_buttons()
func _on_TemplatesOptions_item_selected(id: int) -> void:
if id != Templates.TDefault:
size_value = TResolutions[id]
func toggle_size_buttons() -> void:
portrait_button.disconnect("toggled", self, "_on_PortraitButton_toggled")
landscape_button.disconnect("toggled", self, "_on_LandscapeButton_toggled")
portrait_button.pressed = width_value.value < height_value.value
landscape_button.pressed = width_value.value > height_value.value
portrait_button.connect("toggled", self, "_on_PortraitButton_toggled")
landscape_button.connect("toggled", self, "_on_LandscapeButton_toggled")
func _on_TemplatesOptions_item_selected(id : int) -> void:
if id > 0:
width_value.value = templates[id - 1].resolution.x
height_value.value = templates[id - 1].resolution.y
else:
width_value.value = Global.default_image_width
height_value.value = Global.default_image_height
width_value.value = size_value.x
height_value.value = size_value.y
func _on_PortraitButton_toggled(button_pressed : bool) -> void:
if !button_pressed or height_value.value > width_value.value:
toggle_size_buttons()
return
switch_width_height()
func _on_LandscapeButton_toggled(button_pressed : bool) -> void:
if !button_pressed or width_value.value > height_value.value:
toggle_size_buttons()
return
switch_width_height()
func switch_width_height() -> void:
width_value.disconnect("value_changed", self, "_on_SizeValue_value_changed")
height_value.disconnect("value_changed", self, "_on_SizeValue_value_changed")
var height = height_value.value
height_value.value = width_value.value
width_value.value = height
toggle_size_buttons()
width_value.connect("value_changed", self, "_on_SizeValue_value_changed")
height_value.connect("value_changed", self, "_on_SizeValue_value_changed")

View file

@ -1,6 +1,11 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://src/UI/Dialogs/CreateNewImage.gd" type="Script" id=1]
[ext_resource path="res://assets/graphics/dark_themes/misc/portrait.png" type="Texture" id=2]
[ext_resource path="res://assets/graphics/dark_themes/misc/landscape.png" type="Texture" id=3]
[ext_resource path="res://assets/graphics/dark_themes/misc/lock_aspect_2.png" type="Texture" id=4]
[ext_resource path="res://assets/graphics/dark_themes/misc/lock_aspect.png" type="Texture" id=5]
[ext_resource path="res://assets/graphics/dark_themes/misc/lock_aspect_guides.png" type="Texture" id=6]
[node name="CreateNewImage" type="ConfirmationDialog"]
margin_right = 300.0
@ -31,23 +36,20 @@ margin_top = 18.0
margin_right = 359.0
margin_bottom = 22.0
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
[node name="TemplatesContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 26.0
margin_right = 359.0
margin_bottom = 154.0
custom_constants/vseparation = 4
custom_constants/hseparation = 2
columns = 2
margin_bottom = 46.0
[node name="TemplatesLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
[node name="TemplatesLabel" type="Label" parent="VBoxContainer/TemplatesContainer"]
margin_top = 3.0
margin_right = 112.0
margin_right = 71.0
margin_bottom = 17.0
text = "Templates:"
[node name="TemplatesOptions" type="OptionButton" parent="VBoxContainer/OptionsContainer"]
margin_left = 114.0
margin_right = 189.0
[node name="TemplatesOptions" type="OptionButton" parent="VBoxContainer/TemplatesContainer"]
margin_left = 75.0
margin_right = 150.0
margin_bottom = 20.0
mouse_default_cursor_shape = 2
toggle_mode = false
@ -55,68 +57,153 @@ text = "Default"
items = [ "Default", null, false, 0, null ]
selected = 0
[node name="RatioLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 29.0
margin_right = 112.0
margin_bottom = 43.0
text = "Lock aspect ratio:"
[node name="SizeContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 50.0
margin_right = 359.0
margin_bottom = 102.0
[node name="RatioCheckBox" type="CheckBox" parent="VBoxContainer/OptionsContainer"]
margin_left = 114.0
margin_top = 24.0
margin_right = 189.0
margin_bottom = 48.0
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/SizeContainer"]
margin_right = 124.0
margin_bottom = 52.0
[node name="WidthContainer" type="HBoxContainer" parent="VBoxContainer/SizeContainer/VBoxContainer"]
margin_right = 124.0
margin_bottom = 24.0
[node name="WidthLabel" type="Label" parent="VBoxContainer/SizeContainer/VBoxContainer/WidthContainer"]
margin_top = 5.0
margin_right = 46.0
margin_bottom = 19.0
rect_min_size = Vector2( 46, 0 )
text = "Width:"
[node name="WidthValue" type="SpinBox" parent="VBoxContainer/SizeContainer/VBoxContainer/WidthContainer"]
margin_left = 50.0
margin_right = 124.0
margin_bottom = 24.0
mouse_default_cursor_shape = 2
min_value = 1.0
max_value = 16384.0
value = 64.0
suffix = "px"
[node name="HeightContainer" type="HBoxContainer" parent="VBoxContainer/SizeContainer/VBoxContainer"]
margin_top = 28.0
margin_right = 124.0
margin_bottom = 52.0
[node name="Height" type="Label" parent="VBoxContainer/SizeContainer/VBoxContainer/HeightContainer"]
margin_top = 5.0
margin_right = 46.0
margin_bottom = 19.0
text = "Height:"
[node name="HeightValue" type="SpinBox" parent="VBoxContainer/SizeContainer/VBoxContainer/HeightContainer"]
margin_left = 50.0
margin_right = 124.0
margin_bottom = 24.0
mouse_default_cursor_shape = 2
min_value = 1.0
max_value = 16384.0
value = 64.0
suffix = "px"
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/SizeContainer"]
margin_left = 128.0
margin_right = 148.0
margin_bottom = 52.0
texture = ExtResource( 6 )
[node name="AspectRatioButton" type="TextureButton" parent="VBoxContainer/SizeContainer/TextureRect"]
margin_left = 2.0
margin_top = 14.0
margin_right = 18.0
margin_bottom = 30.0
hint_tooltip = "Lock aspect ratio"
mouse_default_cursor_shape = 2
toggle_mode = true
texture_normal = ExtResource( 4 )
texture_pressed = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="WidthLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 57.0
margin_right = 112.0
margin_bottom = 71.0
text = "Width:"
[node name="SizeButtonsContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 106.0
margin_right = 359.0
margin_bottom = 126.0
[node name="WidthValue" type="SpinBox" parent="VBoxContainer/OptionsContainer"]
margin_left = 114.0
margin_top = 52.0
margin_right = 189.0
margin_bottom = 76.0
[node name="PortraitButton" type="Button" parent="VBoxContainer/SizeButtonsContainer"]
margin_right = 20.0
margin_bottom = 20.0
rect_min_size = Vector2( 20, 0 )
hint_tooltip = "Portrait"
focus_mode = 0
mouse_default_cursor_shape = 2
min_value = 1.0
max_value = 16384.0
value = 64.0
suffix = "px"
toggle_mode = true
enabled_focus_mode = 0
[node name="Height" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 85.0
margin_right = 112.0
margin_bottom = 99.0
text = "Height:"
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/SizeButtonsContainer/PortraitButton"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -8.0
margin_top = -8.0
margin_right = 8.0
margin_bottom = 8.0
texture = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HeightValue" type="SpinBox" parent="VBoxContainer/OptionsContainer"]
margin_left = 114.0
margin_top = 80.0
margin_right = 189.0
margin_bottom = 104.0
[node name="LandscapeButton" type="Button" parent="VBoxContainer/SizeButtonsContainer"]
margin_left = 24.0
margin_right = 44.0
margin_bottom = 20.0
rect_min_size = Vector2( 20, 0 )
hint_tooltip = "Landscape"
focus_mode = 0
mouse_default_cursor_shape = 2
min_value = 1.0
max_value = 16384.0
value = 64.0
suffix = "px"
toggle_mode = true
enabled_focus_mode = 0
[node name="FillColorLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 111.0
margin_right = 112.0
margin_bottom = 125.0
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/SizeButtonsContainer/LandscapeButton"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -8.0
margin_top = -8.0
margin_right = 8.0
margin_bottom = 8.0
texture = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FillColorContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 130.0
margin_right = 359.0
margin_bottom = 150.0
[node name="FillColorLabel" type="Label" parent="VBoxContainer/FillColorContainer"]
margin_top = 3.0
margin_right = 90.0
margin_bottom = 17.0
text = "Fill with color:"
[node name="FillColor" type="ColorPickerButton" parent="VBoxContainer/OptionsContainer"]
margin_left = 114.0
margin_top = 108.0
margin_right = 189.0
margin_bottom = 128.0
[node name="FillColor" type="ColorPickerButton" parent="VBoxContainer/FillColorContainer"]
margin_left = 94.0
margin_right = 158.0
margin_bottom = 20.0
rect_min_size = Vector2( 64, 20 )
mouse_default_cursor_shape = 2
color = Color( 0, 0, 0, 0 )
[connection signal="confirmed" from="." to="." method="_on_CreateNewImage_confirmed"]
[connection signal="item_selected" from="VBoxContainer/TemplatesContainer/TemplatesOptions" to="." method="_on_TemplatesOptions_item_selected"]
[connection signal="value_changed" from="VBoxContainer/SizeContainer/VBoxContainer/WidthContainer/WidthValue" to="." method="_on_SizeValue_value_changed"]
[connection signal="value_changed" from="VBoxContainer/SizeContainer/VBoxContainer/HeightContainer/HeightValue" to="." method="_on_SizeValue_value_changed"]
[connection signal="toggled" from="VBoxContainer/SizeContainer/TextureRect/AspectRatioButton" to="." method="_on_AspectRatioButton_toggled"]
[connection signal="toggled" from="VBoxContainer/SizeButtonsContainer/PortraitButton" to="." method="_on_PortraitButton_toggled"]
[connection signal="toggled" from="VBoxContainer/SizeButtonsContainer/LandscapeButton" to="." method="_on_LandscapeButton_toggled"]