online multiplayer chess game (note server currently down)
Merge pull request #5 from bend-n/bettercolorpicker
better colorpicker
bendn 2022-05-18
parent 5fe8e90 · parent 77ac750 · commit 41fc949
-rw-r--r--project.godot30
-rw-r--r--ui/ColorPicker.gd61
-rw-r--r--ui/ColorPicker.tscn96
-rw-r--r--ui/Settings.tscn20
-rw-r--r--ui/colorpicker/ColorPicker.gd42
-rw-r--r--ui/colorpicker/ColorPicker.tres (renamed from ui/ColorPicker.tres)2
-rw-r--r--ui/colorpicker/ColorPicker.tscn136
-rw-r--r--ui/colorpicker/ColorPickerButton.gd (renamed from ui/ColorPickerButton.gd)8
-rw-r--r--ui/colorpicker/ColorPickerButton.tscn (renamed from ui/ColorPickerButton.tscn)14
-rw-r--r--ui/colorpicker/ColorSelect.gd41
-rw-r--r--ui/colorpicker/ColorSelect.materialbin0 -> 1099 bytes
-rw-r--r--ui/colorpicker/HexInput.gd17
-rw-r--r--ui/colorpicker/HueSlider.gd25
-rw-r--r--ui/colorpicker/OldColorView.gd9
-rw-r--r--ui/colorpicker/huepicker.materialbin0 -> 959 bytes
-rw-r--r--ui/colorpicker/smallbutton.tres (renamed from ui/smallbutton.tres)0
-rw-r--r--ui/colorpicker/smallbuttonhover.tres (renamed from ui/smallbuttonhover.tres)0
17 files changed, 315 insertions, 186 deletions
diff --git a/project.godot b/project.godot
index 430715d..c2c8a3c 100644
--- a/project.godot
+++ b/project.godot
@@ -17,12 +17,17 @@ _global_script_classes=[ {
"base": "Control",
"class": "ColorPickerBetter",
"language": "GDScript",
-"path": "res://ui/ColorPicker.gd"
+"path": "res://ui/colorpicker/ColorPicker.gd"
}, {
-"base": "Button",
+"base": "Control",
"class": "ColorPickerButtonBetter",
"language": "GDScript",
-"path": "res://ui/ColorPickerButton.gd"
+"path": "res://ui/colorpicker/ColorPickerButton.gd"
+}, {
+"base": "Control",
+"class": "ColorSelect",
+"language": "GDScript",
+"path": "res://ui/colorpicker/ColorSelect.gd"
}, {
"base": "LineEdit",
"class": "FENLabel",
@@ -34,6 +39,16 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://Grid.gd"
}, {
+"base": "LineEdit",
+"class": "HexInput",
+"language": "GDScript",
+"path": "res://ui/colorpicker/HexInput.gd"
+}, {
+"base": "Control",
+"class": "HueSlider",
+"language": "GDScript",
+"path": "res://ui/colorpicker/HueSlider.gd"
+}, {
"base": "Piece",
"class": "King",
"language": "GDScript",
@@ -49,6 +64,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://networking/Network.gd"
}, {
+"base": "ColorRect",
+"class": "OldColorView",
+"language": "GDScript",
+"path": "res://ui/colorpicker/OldColorView.gd"
+}, {
"base": "Piece",
"class": "Pawn",
"language": "GDScript",
@@ -83,11 +103,15 @@ _global_script_class_icons={
"Bishop": "res://assets/pieces/california/wB.png",
"ColorPickerBetter": "",
"ColorPickerButtonBetter": "",
+"ColorSelect": "",
"FENLabel": "",
"Grid": "",
+"HexInput": "",
+"HueSlider": "",
"King": "res://assets/pieces/california/wK.png",
"Knight": "res://assets/pieces/california/wN.png",
"Network": "",
+"OldColorView": "",
"Pawn": "res://assets/pieces/california/wP.png",
"Piece": "res://assets/pieces/california/wP.png",
"Preview": "",
diff --git a/ui/ColorPicker.gd b/ui/ColorPicker.gd
deleted file mode 100644
index d94ae62..0000000
--- a/ui/ColorPicker.gd
+++ /dev/null
@@ -1,61 +0,0 @@
-extends Control
-class_name ColorPickerBetter # when you dont like the native color picker so you make your own
-
-var color: Color
-
-var _manual_change := false
-
-signal color_changed(color)
-signal done(color)
-
-onready var hex = $Panel/hex
-onready var rgb = $Panel/H/rgb.get_children()
-onready var preview = $Panel/H/Preview
-
-
-func _ready():
- update_hex_and_preview(false)
-
-
-func update_r(value: float):
- if _manual_change:
- return
- color.r = value / 255
- update_hex_and_preview()
-
-
-func update_b(value: float):
- if _manual_change:
- return
- color.b = value / 255
- update_hex_and_preview()
-
-
-func update_g(value: float):
- if _manual_change:
- return
- color.g = value / 255
- update_hex_and_preview()
-
-
-func update_hex_and_preview(to_signal := true): # update the hex and preview
- _manual_change = true
- rgb[0].value = color.r * 255
- rgb[1].value = color.g * 255
- rgb[2].value = color.b * 255
- _manual_change = false
- var pos = hex.caret_position
- hex.text = "#" + color.to_html(false)
- hex.caret_position = pos # make it in the right place
- preview.color = color
- if to_signal:
- emit_signal("color_changed", color)
-
-
-func _on_hex_text_entered(new_text: String):
- color = Color(new_text)
- update_hex_and_preview()
-
-
-func _on_OKButton_pressed():
- emit_signal("done", color)
diff --git a/ui/ColorPicker.tscn b/ui/ColorPicker.tscn
deleted file mode 100644
index b9fab21..0000000
--- a/ui/ColorPicker.tscn
+++ /dev/null
@@ -1,96 +0,0 @@
-[gd_scene load_steps=7 format=2]
-
-[ext_resource path="res://ui/ColorPicker.gd" type="Script" id=1]
-[ext_resource path="res://ui/ColorPicker.tres" type="Theme" id=2]
-[ext_resource path="res://assets/ui/Roboto-Medium.ttf" type="DynamicFontData" id=3]
-[ext_resource path="res://ui/smallbuttonhover.tres" type="StyleBox" id=4]
-[ext_resource path="res://ui/smallbutton.tres" type="StyleBox" id=5]
-
-[sub_resource type="DynamicFont" id=1]
-size = 20
-font_data = ExtResource( 3 )
-
-[node name="ColorPicker" type="Control"]
-margin_right = 202.0
-margin_bottom = 238.0
-theme = ExtResource( 2 )
-script = ExtResource( 1 )
-
-[node name="Panel" type="Panel" parent="."]
-margin_left = -12.0
-margin_top = -12.0
-margin_right = 202.0
-margin_bottom = 240.0
-
-[node name="H" type="HBoxContainer" parent="Panel"]
-margin_left = 12.0
-margin_top = 12.0
-margin_right = 209.0
-margin_bottom = 180.0
-custom_constants/separation = 8
-
-[node name="Preview" type="ColorRect" parent="Panel/H"]
-margin_right = 100.0
-margin_bottom = 100.0
-rect_min_size = Vector2( 100, 100 )
-size_flags_horizontal = 0
-size_flags_vertical = 0
-
-[node name="rgb" type="VBoxContainer" parent="Panel/H"]
-margin_left = 108.0
-margin_right = 197.0
-margin_bottom = 168.0
-custom_constants/separation = 6
-
-[node name="r" type="SpinBox" parent="Panel/H/rgb"]
-margin_right = 89.0
-margin_bottom = 52.0
-max_value = 255.0
-rounded = true
-
-[node name="g" type="SpinBox" parent="Panel/H/rgb"]
-margin_top = 58.0
-margin_right = 89.0
-margin_bottom = 110.0
-max_value = 255.0
-rounded = true
-
-[node name="b" type="SpinBox" parent="Panel/H/rgb"]
-margin_top = 116.0
-margin_right = 89.0
-margin_bottom = 168.0
-max_value = 255.0
-rounded = true
-
-[node name="hex" type="LineEdit" parent="Panel"]
-margin_left = 6.0
-margin_top = 124.0
-margin_right = 114.0
-margin_bottom = 176.0
-max_length = 7
-placeholder_text = "#FFFFFF"
-caret_blink = true
-
-[node name="OKButton" type="Button" parent="Panel"]
-margin_left = 20.0
-margin_top = 186.0
-margin_right = 200.0
-margin_bottom = 238.0
-focus_mode = 0
-custom_colors/font_color_focus = Color( 0, 0, 0, 1 )
-custom_colors/font_color = Color( 1, 1, 1, 1 )
-custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
-custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
-custom_fonts/font = SubResource( 1 )
-custom_styles/hover = ExtResource( 4 )
-custom_styles/pressed = ExtResource( 4 )
-custom_styles/focus = ExtResource( 4 )
-custom_styles/normal = ExtResource( 5 )
-enabled_focus_mode = 0
-text = "OK"
-
-[connection signal="value_changed" from="Panel/H/rgb/r" to="." method="update_r"]
-[connection signal="value_changed" from="Panel/H/rgb/g" to="." method="update_g"]
-[connection signal="value_changed" from="Panel/H/rgb/b" to="." method="update_b"]
-[connection signal="text_entered" from="Panel/hex" to="." method="_on_hex_text_entered"]
-[connection signal="pressed" from="Panel/OKButton" to="." method="_on_OKButton_pressed"]
diff --git a/ui/Settings.tscn b/ui/Settings.tscn
index 1c08478..0d8dfac 100644
--- a/ui/Settings.tscn
+++ b/ui/Settings.tscn
@@ -1,11 +1,10 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=6 format=2]
[ext_resource path="res://ui/main.tres" type="Theme" id=1]
[ext_resource path="res://ui/Settings.gd" type="Script" id=2]
[ext_resource path="res://assets/pieces/california/wP.png" type="Texture" id=3]
[ext_resource path="res://ui/Preview.gd" type="Script" id=4]
-[ext_resource path="res://ui/ColorPickerButton.tscn" type="PackedScene" id=5]
-[ext_resource path="res://ui/ColorPickerButton.gd" type="Script" id=6]
+[ext_resource path="res://ui/colorpicker/ColorPickerButton.tscn" type="PackedScene" id=5]
[node name="Settings" type="Control" groups=["control"]]
anchor_right = 1.0
@@ -16,7 +15,7 @@ script = ExtResource( 2 )
[node name="ColorRect" type="ColorRect" parent="." groups=["control"]]
anchor_right = 1.0
anchor_bottom = 1.0
-color = Color( 0, 0, 0, 0.862745 )
+color = Color( 0, 0, 0, 1 )
[node name="HBoxContainer" type="HBoxContainer" parent="ColorRect" groups=["control"]]
anchor_right = 1.0
@@ -24,8 +23,8 @@ anchor_bottom = 1.0
alignment = 1
[node name="VBoxContainer" type="VBoxContainer" parent="ColorRect/HBoxContainer" groups=["control"]]
-margin_left = 54.0
-margin_right = 420.0
+margin_left = 165.0
+margin_right = 531.0
margin_bottom = 800.0
alignment = 1
@@ -100,8 +99,8 @@ margin_bottom = 200.0
rect_min_size = Vector2( 100, 100 )
[node name="VBoxContainer2" type="VBoxContainer" parent="ColorRect/HBoxContainer" groups=["control"]]
-margin_left = 435.0
-margin_right = 804.0
+margin_left = 546.0
+margin_right = 915.0
margin_bottom = 800.0
alignment = 1
@@ -131,8 +130,8 @@ enabled_focus_mode = 0
text = "borders"
[node name="VBoxContainer3" type="VBoxContainer" parent="ColorRect/HBoxContainer"]
-margin_left = 819.0
-margin_right = 1145.0
+margin_left = 930.0
+margin_right = 1256.0
margin_bottom = 800.0
alignment = 1
@@ -149,7 +148,6 @@ margin_top = 347.0
margin_right = 326.0
margin_bottom = 453.0
text = "boardcolor1"
-script = ExtResource( 6 )
[node name="boardcolor2" parent="ColorRect/HBoxContainer/VBoxContainer3" instance=ExtResource( 5 )]
margin_top = 468.0
diff --git a/ui/colorpicker/ColorPicker.gd b/ui/colorpicker/ColorPicker.gd
new file mode 100644
index 0000000..a9c352d
--- /dev/null
+++ b/ui/colorpicker/ColorPicker.gd
@@ -0,0 +1,42 @@
+extends Control
+class_name ColorPickerBetter # when you dont like the native color picker so you make your own
+
+var color: Color = Color.white setget set_color
+
+signal color_changed(color)
+signal done(color)
+
+onready var oldcolorview = $Panel/V/H2/OldColorView
+onready var newcolorpreview = $Panel/V/H2/NewColorPreview
+onready var hex = $Panel/V/hex
+onready var colorselect = $Panel/V/H/ColorSelect
+onready var hueslider = $Panel/V/H/HueSlider
+
+func open():
+ oldcolorview.color = color
+ update_color()
+ show()
+
+func _ready():
+ if has_node("/root/ColorPicker"):
+ open() # for testing
+
+func update_color():
+ newcolorpreview.color = color
+ hex.color = color
+ colorselect.color = color
+ hueslider.hue = color.h
+
+func set_color(newcolor):
+ color = newcolor
+ update_color()
+ emit_signal("color_changed", newcolor)
+
+
+func _on_OKButton_pressed():
+ emit_signal("done", color)
+
+
+func _color_changed(newcolor: Color):
+ if newcolor != color:
+ set_color(newcolor)
diff --git a/ui/ColorPicker.tres b/ui/colorpicker/ColorPicker.tres
index a852e11..8625250 100644
--- a/ui/ColorPicker.tres
+++ b/ui/colorpicker/ColorPicker.tres
@@ -1,7 +1,7 @@
[gd_resource type="Theme" load_steps=5 format=2]
[ext_resource path="res://assets/ui/Roboto-Medium.ttf" type="DynamicFontData" id=1]
-[ext_resource path="res://ui/smallbutton.tres" type="StyleBox" id=2]
+[ext_resource path="res://ui/colorpicker/smallbutton.tres" type="StyleBox" id=2]
[ext_resource path="res://assets/ui/whitespace.png" type="Texture" id=3]
[sub_resource type="DynamicFont" id=1]
diff --git a/ui/colorpicker/ColorPicker.tscn b/ui/colorpicker/ColorPicker.tscn
new file mode 100644
index 0000000..30bcd17
--- /dev/null
+++ b/ui/colorpicker/ColorPicker.tscn
@@ -0,0 +1,136 @@
+[gd_scene load_steps=13 format=2]
+
+[ext_resource path="res://ui/colorpicker/ColorPicker.gd" type="Script" id=1]
+[ext_resource path="res://ui/colorpicker/ColorPicker.tres" type="Theme" id=2]
+[ext_resource path="res://assets/ui/Roboto-Medium.ttf" type="DynamicFontData" id=3]
+[ext_resource path="res://ui/colorpicker/smallbutton.tres" type="StyleBox" id=4]
+[ext_resource path="res://ui/colorpicker/smallbuttonhover.tres" type="StyleBox" id=5]
+[ext_resource path="res://ui/colorpicker/HueSlider.gd" type="Script" id=6]
+[ext_resource path="res://ui/colorpicker/ColorSelect.gd" type="Script" id=7]
+[ext_resource path="res://ui/colorpicker/HexInput.gd" type="Script" id=8]
+[ext_resource path="res://ui/colorpicker/OldColorView.gd" type="Script" id=9]
+[ext_resource path="res://ui/colorpicker/huepicker.material" type="Material" id=10]
+[ext_resource path="res://ui/colorpicker/ColorSelect.material" type="Material" id=11]
+
+[sub_resource type="DynamicFont" id=1]
+size = 20
+font_data = ExtResource( 3 )
+
+[node name="ColorPicker" type="Control"]
+margin_right = 128.0
+margin_bottom = 238.0
+theme = ExtResource( 2 )
+script = ExtResource( 1 )
+
+[node name="Panel" type="Panel" parent="."]
+margin_left = -12.0
+margin_top = -12.0
+margin_right = 136.0
+margin_bottom = 248.0
+
+[node name="V" type="VBoxContainer" parent="Panel"]
+margin_left = 12.0
+margin_top = 12.0
+margin_right = 137.0
+margin_bottom = 137.0
+custom_constants/separation = 5
+
+[node name="H" type="HBoxContainer" parent="Panel/V"]
+margin_right = 125.0
+margin_bottom = 100.0
+custom_constants/separation = 5
+
+[node name="HueSlider" type="Control" parent="Panel/V/H"]
+margin_right = 20.0
+margin_bottom = 100.0
+rect_min_size = Vector2( 20, 100 )
+size_flags_vertical = 0
+script = ExtResource( 6 )
+
+[node name="ShaderHolder" type="ColorRect" parent="Panel/V/H/HueSlider"]
+show_behind_parent = true
+material = ExtResource( 10 )
+anchor_right = 1.0
+anchor_bottom = 1.0
+mouse_filter = 2
+
+[node name="ColorSelect" type="Control" parent="Panel/V/H"]
+margin_left = 25.0
+margin_right = 125.0
+margin_bottom = 100.0
+rect_min_size = Vector2( 100, 100 )
+size_flags_horizontal = 0
+size_flags_vertical = 0
+script = ExtResource( 7 )
+
+[node name="ShaderHolder" type="ColorRect" parent="Panel/V/H/ColorSelect"]
+show_behind_parent = true
+material = ExtResource( 11 )
+anchor_right = 1.0
+anchor_bottom = 1.0
+mouse_filter = 2
+
+[node name="H2" type="HBoxContainer" parent="Panel/V"]
+margin_top = 105.0
+margin_right = 125.0
+margin_bottom = 125.0
+custom_constants/separation = 0
+
+[node name="Spacer" type="Control" parent="Panel/V/H2"]
+margin_right = 25.0
+margin_bottom = 20.0
+rect_min_size = Vector2( 25, 0 )
+
+[node name="OldColorView" type="ColorRect" parent="Panel/V/H2"]
+margin_left = 25.0
+margin_right = 75.0
+margin_bottom = 20.0
+rect_min_size = Vector2( 50, 20 )
+script = ExtResource( 9 )
+
+[node name="NewColorPreview" type="ColorRect" parent="Panel/V/H2"]
+margin_left = 75.0
+margin_right = 125.0
+margin_bottom = 20.0
+rect_min_size = Vector2( 50, 20 )
+
+[node name="hex" type="LineEdit" parent="Panel/V"]
+margin_top = 130.0
+margin_right = 125.0
+margin_bottom = 182.0
+max_length = 7
+context_menu_enabled = false
+placeholder_text = "#FFFFFF"
+caret_blink = true
+script = ExtResource( 8 )
+
+[node name="OKButton" type="Button" parent="Panel/V"]
+margin_top = 187.0
+margin_right = 125.0
+margin_bottom = 239.0
+focus_mode = 0
+custom_colors/font_color_focus = Color( 0, 0, 0, 1 )
+custom_colors/font_color = Color( 1, 1, 1, 1 )
+custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
+custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
+custom_fonts/font = SubResource( 1 )
+custom_styles/hover = ExtResource( 5 )
+custom_styles/pressed = ExtResource( 5 )
+custom_styles/focus = ExtResource( 5 )
+custom_styles/normal = ExtResource( 4 )
+enabled_focus_mode = 0
+text = "OK"
+
+[node name="LineDrawer" type="Control" parent="Panel/V"]
+margin_top = 244.0
+margin_right = 125.0
+margin_bottom = 244.0
+
+[connection signal="gui_input" from="Panel/V/H/HueSlider" to="Panel/V/H/HueSlider" method="_gui_input"]
+[connection signal="hue_changed" from="Panel/V/H/HueSlider" to="Panel/V/H/ColorSelect" method="apply_hue"]
+[connection signal="color_changed" from="Panel/V/H/ColorSelect" to="." method="_color_changed"]
+[connection signal="color_changed" from="Panel/V/H2/OldColorView" to="." method="_color_changed"]
+[connection signal="gui_input" from="Panel/V/H2/OldColorView" to="Panel/V/H2/OldColorView" method="_gui_input"]
+[connection signal="color_changed" from="Panel/V/hex" to="." method="_color_changed"]
+[connection signal="text_entered" from="Panel/V/hex" to="Panel/V/hex" method="_text_entered"]
+[connection signal="pressed" from="Panel/V/OKButton" to="." method="_on_OKButton_pressed"]
diff --git a/ui/ColorPickerButton.gd b/ui/colorpicker/ColorPickerButton.gd
index 5f5ef67..7baf17e 100644
--- a/ui/ColorPickerButton.gd
+++ b/ui/colorpicker/ColorPickerButton.gd
@@ -1,4 +1,4 @@
-extends Button
+extends Control
class_name ColorPickerButtonBetter
onready var colorpicker = $"ColorPicker"
@@ -12,18 +12,12 @@ func set_color(newcolor):
color = newcolor
add_color_override("font_color", color)
colorpicker.color = color
- colorpicker.update_hex_and_preview()
func _ready():
colorpicker.set_as_toplevel(true)
colorpicker.rect_global_position = $Position.rect_global_position
$Position.queue_free()
- # VisualServer.canvas_item_set_z_index(colorpicker.get_canvas_item(), 5)
-
-
-func _on_pressed():
- colorpicker.show()
func _on_ColorPicker_done(newcolor: Color):
diff --git a/ui/ColorPickerButton.tscn b/ui/colorpicker/ColorPickerButton.tscn
index 8ecadbd..c3c07ff 100644
--- a/ui/ColorPickerButton.tscn
+++ b/ui/colorpicker/ColorPickerButton.tscn
@@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/main.tres" type="Theme" id=1]
-[ext_resource path="res://ui/ColorPickerButton.gd" type="Script" id=2]
-[ext_resource path="res://ui/ColorPicker.tscn" type="PackedScene" id=3]
+[ext_resource path="res://ui/colorpicker/ColorPickerButton.gd" type="Script" id=2]
+[ext_resource path="res://ui/colorpicker/ColorPicker.tscn" type="PackedScene" id=3]
[node name="ColorPickerButton" type="Button"]
margin_right = 232.0
@@ -15,10 +15,10 @@ script = ExtResource( 2 )
[node name="ColorPicker" parent="." instance=ExtResource( 3 )]
visible = false
-margin_left = 92.0
-margin_top = 58.0
-margin_right = 294.0
-margin_bottom = 234.0
+margin_left = 88.0
+margin_top = 56.0
+margin_right = 290.0
+margin_bottom = 294.0
[node name="Position" type="Control" parent="."]
margin_left = 80.0
@@ -26,5 +26,5 @@ margin_top = 46.0
margin_right = 120.0
margin_bottom = 86.0
-[connection signal="pressed" from="." to="." method="_on_pressed"]
+[connection signal="pressed" from="." to="ColorPicker" method="open"]
[connection signal="done" from="ColorPicker" to="." method="_on_ColorPicker_done"]
diff --git a/ui/colorpicker/ColorSelect.gd b/ui/colorpicker/ColorSelect.gd
new file mode 100644
index 0000000..1102709
--- /dev/null
+++ b/ui/colorpicker/ColorSelect.gd
@@ -0,0 +1,41 @@
+extends Control
+class_name ColorSelect
+
+var color : Color setget set_color
+
+onready var shader_holder := $ShaderHolder
+
+signal color_changed(color)
+
+func set_color(newcolor):
+ color = newcolor
+ shader_holder.material.set_shader_param("hue", color.h)
+ update()
+
+func apply_hue(newhue):
+ self.color.h = newhue
+
+
+func _gui_input(event):
+ if event is InputEventMouseButton:
+ var position = event.position
+ var saturation = position.x / rect_size.x
+ var value = 1 - (position.y / rect_size.y)
+ set_color(Color.from_hsv(color.h, saturation, value))
+ update()
+ emit_signal("color_changed", color)
+
+func _draw():
+ var vlinex = color.s * rect_size.x
+ var vliney = rect_size.y
+
+ draw_line(Vector2(vlinex - 1, 0), Vector2(vlinex - 1, vliney), Color.black)
+ draw_line(Vector2(vlinex, 0), Vector2(vlinex, vliney), Color.white)
+ draw_line(Vector2(vlinex + 1, 0), Vector2(vlinex + 1, vliney), Color.black)
+
+ var hlinex = rect_size.x
+ var hliney = rect_size.y - color.v * rect_size.y
+
+ draw_line(Vector2(0, hliney - 1), Vector2(hlinex, hliney - 1), Color.black)
+ draw_line(Vector2(0, hliney), Vector2(hlinex, hliney), Color.white)
+ draw_line(Vector2(0, hliney + 1), Vector2(hlinex, hliney + 1), Color.black)
diff --git a/ui/colorpicker/ColorSelect.material b/ui/colorpicker/ColorSelect.material
new file mode 100644
index 0000000..4226a76
--- /dev/null
+++ b/ui/colorpicker/ColorSelect.material
Binary files differ
diff --git a/ui/colorpicker/HexInput.gd b/ui/colorpicker/HexInput.gd
new file mode 100644
index 0000000..6447923
--- /dev/null
+++ b/ui/colorpicker/HexInput.gd
@@ -0,0 +1,17 @@
+extends LineEdit
+class_name HexInput
+
+var color: Color setget set_color
+
+signal color_changed(color)
+
+func set_color(newcolor):
+ color = newcolor
+ var pos = caret_position
+ text = "#" + color.to_html(false)
+ caret_position = pos # make it in the right place
+
+
+func _text_entered(new_text: String):
+ set_color(Color(new_text))
+ emit_signal("color_changed", color)
diff --git a/ui/colorpicker/HueSlider.gd b/ui/colorpicker/HueSlider.gd
new file mode 100644
index 0000000..1bf4607
--- /dev/null
+++ b/ui/colorpicker/HueSlider.gd
@@ -0,0 +1,25 @@
+extends Control
+class_name HueSlider
+
+onready var line_drawer = $"../../LineDrawer"
+
+signal hue_changed(hue)
+
+var hue :float setget set_hue
+
+func _gui_input(event):
+ if event is InputEventMouseButton:
+ var position = event.position
+ set_hue(position.y / rect_size.y)
+ emit_signal("hue_changed", hue)
+
+func set_hue(newhue):
+ hue = newhue
+ update()
+
+func _draw():
+ var x = rect_size.x
+ var y = hue * rect_size.y
+ draw_line(Vector2(0, y - 1), Vector2(x, y -1), Color.black, 1, true)
+ draw_line(Vector2(0, y), Vector2(x, y), Color.white, 1, true)
+ draw_line(Vector2(0, y + 1), Vector2(x, y + 1), Color.black, 1, true)
diff --git a/ui/colorpicker/OldColorView.gd b/ui/colorpicker/OldColorView.gd
new file mode 100644
index 0000000..c840c2c
--- /dev/null
+++ b/ui/colorpicker/OldColorView.gd
@@ -0,0 +1,9 @@
+extends ColorRect
+class_name OldColorView
+
+signal color_changed(color)
+
+
+func _gui_input(event: InputEvent):
+ if event is InputEventMouseButton:
+ emit_signal("color_changed", color)
diff --git a/ui/colorpicker/huepicker.material b/ui/colorpicker/huepicker.material
new file mode 100644
index 0000000..436f3ff
--- /dev/null
+++ b/ui/colorpicker/huepicker.material
Binary files differ
diff --git a/ui/smallbutton.tres b/ui/colorpicker/smallbutton.tres
index 8e87d11..8e87d11 100644
--- a/ui/smallbutton.tres
+++ b/ui/colorpicker/smallbutton.tres
diff --git a/ui/smallbuttonhover.tres b/ui/colorpicker/smallbuttonhover.tres
index 3189e53..3189e53 100644
--- a/ui/smallbuttonhover.tres
+++ b/ui/colorpicker/smallbuttonhover.tres