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

More UI changes

- Left tool options is now on top of the right tool options.
- Brushes have been removed from the right panel, and have instead become a popup that appears when you press one of the brush type buttons, to choose a brush. The indicators will be removed.
This commit is contained in:
OverloadedOrama 2019-11-30 00:41:34 +02:00
parent 3fd2df11e8
commit 4721a01f2e
10 changed files with 377 additions and 216 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/pixel.png-02d24c392cbedb7afeccdbe493729855.stex"
path="res://.import/Brush_button.png-4783b6e96c01a99d0b15c8e80d794dbf.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Graphics/pixel.png"
dest_files=[ "res://.import/pixel.png-02d24c392cbedb7afeccdbe493729855.stex" ]
source_file="res://Assets/Graphics/Brush_button.png"
dest_files=[ "res://.import/Brush_button.png-4783b6e96c01a99d0b15c8e80d794dbf.stex" ]
[params]
@ -20,7 +20,7 @@ compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2

View file

Before

Width:  |  Height:  |  Size: 101 B

After

Width:  |  Height:  |  Size: 101 B

View file

@ -0,0 +1,13 @@
[remap]
importer="image"
type="Image"
path="res://.import/pixel_image.png-44462e1df93ae83fafb33e7d5d2c9060.image"
[deps]
source_file="res://Assets/Graphics/pixel_image.png"
dest_files=[ "res://.import/pixel_image.png-44462e1df93ae83fafb33e7d5d2c9060.image" ]
[params]

450
Main.tscn

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,24 +1,38 @@
extends Button
extends BaseButton
var brush_type = Global.BRUSH_TYPES.PIXEL
var custom_brush_index := -1
func _on_BrushButton_pressed() -> void:
if Input.is_action_just_released("left_mouse"):
if Global.brushes_popup.rect_global_position == Global.left_brush_type_button.rect_global_position:
Global.current_left_brush_type = brush_type
Global.left_brush_indicator.get_parent().remove_child(Global.left_brush_indicator)
add_child(Global.left_brush_indicator)
if custom_brush_index > -1:
if custom_brush_index > -1: #Custom brush
Global.custom_left_brush_index = custom_brush_index
Global.update_left_custom_brush()
if hint_tooltip == "":
Global.left_brush_type_label.text = "Custom brush"
else:
Global.left_brush_type_label.text = "Brush: %s" % hint_tooltip
else: #Pixel brush
Global.left_brush_type_label.text = "Brush: Pixel"
elif Input.is_action_just_released("right_mouse"):
Global.update_left_custom_brush()
else:
Global.current_right_brush_type = brush_type
Global.right_brush_indicator.get_parent().remove_child(Global.right_brush_indicator)
add_child(Global.right_brush_indicator)
if custom_brush_index > -1:
Global.custom_right_brush_index = custom_brush_index
Global.update_right_custom_brush()
if hint_tooltip == "":
Global.right_brush_type_label.text = "Custom brush"
else:
Global.right_brush_type_label.text = "Brush: %s" % hint_tooltip
else: #Pixel brush
Global.right_brush_type_label.text = "Brush: Pixel"
Global.update_right_custom_brush()
func _on_DeleteButton_pressed() -> void:
if brush_type == Global.BRUSH_TYPES.CUSTOM:

View file

@ -26,7 +26,7 @@ func _ready() -> void:
Global.can_draw = false
#Background
trans_background = ImageTexture.new()
trans_background.create_from_image(load("res://Assets/Graphics/Transparent Background.png"), 0)
trans_background.create_from_image(preload("res://Assets/Graphics/Transparent Background.png"), 0)
#The sprite itself
if layers.empty():

View file

@ -45,6 +45,10 @@ var view_menu : MenuButton
var help_menu : MenuButton
var left_color_picker : ColorPickerButton
var right_color_picker : ColorPickerButton
var left_brush_type_button : BaseButton
var right_brush_type_button : BaseButton
var left_brush_type_label : Label
var right_brush_type_label : Label
var left_brush_size_edit : SpinBox
var right_brush_size_edit : SpinBox
var left_interpolate_slider : HSlider
@ -80,8 +84,9 @@ var right_brush_size := 1
var current_left_brush_type = BRUSH_TYPES.PIXEL
# warning-ignore:unused_class_variable
var current_right_brush_type = BRUSH_TYPES.PIXEL
var file_brush_container
var project_brush_container
var brushes_popup : Popup
var file_brush_container : GridContainer
var project_brush_container : GridContainer
# warning-ignore:unused_class_variable
var left_horizontal_mirror := false
# warning-ignore:unused_class_variable
@ -130,11 +135,14 @@ func _ready() -> void:
help_menu = find_node_by_name(root, "HelpMenu")
left_color_picker = find_node_by_name(root, "LeftColorPickerButton")
right_color_picker = find_node_by_name(root, "RightColorPickerButton")
left_brush_type_button = find_node_by_name(root, "LeftBrushTypeButton")
right_brush_type_button = find_node_by_name(root, "RightBrushTypeButton")
left_brush_type_label = find_node_by_name(root, "LeftBrushTypeLabel")
right_brush_type_label = find_node_by_name(root, "RightBrushTypeLabel")
left_brush_size_edit = find_node_by_name(root, "LeftBrushSizeEdit")
right_brush_size_edit = find_node_by_name(root, "RightBrushSizeEdit")
left_interpolate_slider = find_node_by_name(root, "LeftInterpolateFactor")
right_interpolate_slider = find_node_by_name(root, "RightInterpolateFactor")
left_brush_indicator = find_node_by_name(root, "LeftBrushIndicator")
right_brush_indicator = find_node_by_name(root, "RightBrushIndicator")
@ -142,6 +150,7 @@ func _ready() -> void:
play_forward = find_node_by_name(root, "PlayForward")
play_backwards = find_node_by_name(root, "PlayBackwards")
frame_container = find_node_by_name(root, "FrameContainer")
vbox_layer_container = find_node_by_name(root, "VBoxLayerContainer")
remove_layer_button = find_node_by_name(root, "RemoveLayerButton")
move_up_layer_button = find_node_by_name(root, "MoveUpLayer")
@ -151,8 +160,10 @@ func _ready() -> void:
cursor_position_label = find_node_by_name(root, "CursorPosition")
zoom_level_label = find_node_by_name(root, "ZoomLevel")
current_frame_label = find_node_by_name(root, "CurrentFrame")
file_brush_container = find_node_by_name(root, "FileBrushContainer")
project_brush_container = find_node_by_name(root, "ProjectBrushContainer")
brushes_popup = find_node_by_name(root, "BrushesPopup")
file_brush_container = find_node_by_name(brushes_popup, "FileBrushContainer")
project_brush_container = find_node_by_name(brushes_popup, "ProjectBrushContainer")
#Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name
func find_node_by_name(root, node_name) -> Node:
@ -288,7 +299,7 @@ func remove_brush_buttons() -> void:
for child in project_brush_container.get_children():
child.queue_free()
func undo_custom_brush(_brush_button : Button = null) -> void:
func undo_custom_brush(_brush_button : BaseButton = null) -> void:
undos -= 1
var action_name := undo_redo.get_current_action_name()
if action_name == "Delete Custom Brush":
@ -297,7 +308,7 @@ func undo_custom_brush(_brush_button : Button = null) -> void:
_brush_button.get_node("DeleteButton").visible = false
notification_label("Undo: %s" % action_name)
func redo_custom_brush(_brush_button : Button = null) -> void:
func redo_custom_brush(_brush_button : BaseButton = null) -> void:
if undos < undo_redo.get_version(): #If we did undo and then redo
undos = undo_redo.get_version()
var action_name := undo_redo.get_current_action_name()
@ -307,7 +318,12 @@ func redo_custom_brush(_brush_button : Button = null) -> void:
notification_label("Redo: %s" % action_name)
func update_left_custom_brush() -> void:
if custom_left_brush_index > -1:
if current_left_brush_type == BRUSH_TYPES.PIXEL:
var pixel := Image.new()
pixel = preload("res://Assets/Graphics/pixel_image.png")
pixel = blend_image_with_color(pixel, left_color_picker.color, 1)
left_brush_type_button.get_child(0).texture.create_from_image(pixel)
else:
var custom_brush := Image.new()
custom_brush.copy_from(custom_brushes[custom_left_brush_index])
var custom_brush_size = custom_brush.get_size()
@ -315,8 +331,15 @@ func update_left_custom_brush() -> void:
custom_left_brush_image = blend_image_with_color(custom_brush, left_color_picker.color, left_interpolate_slider.value)
custom_left_brush_texture.create_from_image(custom_left_brush_image, 0)
left_brush_type_button.get_child(0).texture = custom_left_brush_texture
func update_right_custom_brush() -> void:
if custom_right_brush_index > -1:
if current_right_brush_type == BRUSH_TYPES.PIXEL:
var pixel := Image.new()
pixel = preload("res://Assets/Graphics/pixel_image.png")
pixel = blend_image_with_color(pixel, right_color_picker.color, 1)
right_brush_type_button.get_child(0).texture.create_from_image(pixel)
else:
var custom_brush := Image.new()
custom_brush.copy_from(custom_brushes[custom_right_brush_index])
var custom_brush_size = custom_brush.get_size()
@ -324,6 +347,8 @@ func update_right_custom_brush() -> void:
custom_right_brush_image = blend_image_with_color(custom_brush, right_color_picker.color, right_interpolate_slider.value)
custom_right_brush_texture.create_from_image(custom_right_brush_image, 0)
right_brush_type_button.get_child(0).texture = custom_right_brush_texture
func blend_image_with_color(image : Image, color : Color, interpolate_factor : float) -> Image:
var blended_image := Image.new()
blended_image.copy_from(image)

View file

@ -132,7 +132,7 @@ func _ready() -> void:
if err == OK:
image.convert(Image.FORMAT_RGBA8)
Global.custom_brushes.append(image)
Global.create_brush_button(image, Global.BRUSH_TYPES.FILE, file)
Global.create_brush_button(image, Global.BRUSH_TYPES.FILE, file.trim_suffix(".png"))
file = brushes_dir.get_next()
brushes_dir.list_dir_end()
Global.brushes_from_files = Global.custom_brushes.size()
@ -604,6 +604,12 @@ func _on_LeftIndicatorCheckbox_toggled(button_pressed) -> void:
func _on_RightIndicatorCheckbox_toggled(button_pressed) -> void:
Global.right_square_indicator_visible = button_pressed
func _on_LeftBrushTypeButton_pressed() -> void:
Global.brushes_popup.popup(Rect2(Global.left_brush_type_button.rect_global_position, Vector2(226, 72)))
func _on_RightBrushTypeButton_pressed() -> void:
Global.brushes_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
func _on_LeftBrushSizeEdit_value_changed(value) -> void:
var new_size = int(value)
Global.left_brush_size = new_size
@ -867,3 +873,4 @@ func _exit_tree() -> void:
config_cache.set_value("window", "position", OS.window_position)
config_cache.set_value("window", "size", OS.window_size)
config_cache.save("user://cache.ini")