mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2024-11-20 10:47:22 +01:00
🛠 data tooltip
This commit is contained in:
parent
5d18535a3e
commit
f1b4d9c0a5
@ -5,65 +5,32 @@ class_name DataTooltip
|
||||
var value : String = ""
|
||||
var position : Vector2 = Vector2()
|
||||
|
||||
var OFFSET : Vector2 = Vector2(15,35)
|
||||
var GAP : Vector2 = Vector2(0,15)
|
||||
|
||||
onready var Data : Label = $PointData/Value/x
|
||||
onready var Value : Label = $PointData/Value/y
|
||||
onready var Function : Label = $PointData/Function
|
||||
onready var x_lbl : Label = $PointData/x
|
||||
onready var y_lbl : Label = $PointData/Value/y
|
||||
onready var func_lbl : Label = $PointData/Value/Function
|
||||
onready var color_rect: Panel = $PointData/Value/Color
|
||||
|
||||
func _ready():
|
||||
hide()
|
||||
update_size()
|
||||
|
||||
func _process(delta):
|
||||
if get_global_mouse_position().y > OFFSET.y + GAP.y:
|
||||
rect_position = get_global_mouse_position() - OFFSET - GAP
|
||||
else:
|
||||
rect_position = get_global_mouse_position() + GAP*5 - OFFSET
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
rect_position = get_global_mouse_position() + Vector2(15, - (get_rect().size.y / 2))
|
||||
|
||||
func update_datas(point : Control):
|
||||
update_size()
|
||||
|
||||
get("custom_styles/panel").set("bg_color",point.color)
|
||||
|
||||
var font_color : Color
|
||||
if point.color.g < 0.75:
|
||||
font_color = Color(1,1,1,1)
|
||||
else:
|
||||
font_color = Color(0,0,0,1)
|
||||
Data.set("custom_colors/font_color",font_color)
|
||||
Value.set("custom_colors/font_color",font_color)
|
||||
Function.set("custom_colors/font_color",font_color)
|
||||
get("custom_styles/panel").set("border_color",font_color)
|
||||
|
||||
Data.set_text(point.point_value[0]+":")
|
||||
Value.set_text(point.point_value[1])
|
||||
Function.set_text(point.function)
|
||||
update()
|
||||
show()
|
||||
|
||||
func update_slice_datas(slice : Slice):
|
||||
update_size()
|
||||
|
||||
get("custom_styles/panel").set("bg_color",slice.color)
|
||||
|
||||
var font_color : Color
|
||||
if slice.color.g < 0.75:
|
||||
font_color = Color(1,1,1,1)
|
||||
else:
|
||||
font_color = Color(0,0,0,1)
|
||||
Data.set("custom_colors/font_color",font_color)
|
||||
Value.set("custom_colors/font_color",font_color)
|
||||
Function.set("custom_colors/font_color",font_color)
|
||||
get("custom_styles/panel").set("border_color",font_color)
|
||||
|
||||
Data.set_text(slice.x_value+":")
|
||||
Value.set_text(slice.y_value)
|
||||
Function.set_text(slice.function)
|
||||
update()
|
||||
show()
|
||||
func update_values(x: String, y: String, function: String, color: Color):
|
||||
x_lbl.set_text(x)
|
||||
y_lbl.set_text(y)
|
||||
func_lbl.set_text(function)
|
||||
color_rect.get("custom_styles/panel").set("bg_color", color)
|
||||
|
||||
func update_size():
|
||||
OFFSET.x = get_size().x/2
|
||||
OFFSET.y = get_size().y
|
||||
GAP.y = OFFSET.y/3
|
||||
x_lbl.set_text("")
|
||||
y_lbl.set_text("")
|
||||
func_lbl.set_text("")
|
||||
rect_size = Vector2.ZERO
|
||||
|
||||
func _on_DataTooltip_visibility_changed():
|
||||
if not visible:
|
||||
update_size()
|
||||
|
@ -1,82 +1,116 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/easy_charts/utilities/containers/data_tooltip/data_tooltip.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
content_margin_left = 10.0
|
||||
content_margin_right = 10.0
|
||||
content_margin_top = 5.0
|
||||
content_margin_bottom = 5.0
|
||||
bg_color = Color( 1, 1, 1, 0 )
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
content_margin_top = 8.0
|
||||
content_margin_bottom = 8.0
|
||||
bg_color = Color( 0.101961, 0.101961, 0.101961, 0.784314 )
|
||||
border_color = Color( 1, 1, 1, 1 )
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
corner_detail = 20
|
||||
anti_aliasing_size = 0.9
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
corner_detail = 20
|
||||
anti_aliasing_size = 0.7
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=3]
|
||||
|
||||
[node name="DataTooltip" type="PanelContainer"]
|
||||
visible = false
|
||||
anchor_right = 0.0694688
|
||||
anchor_bottom = 0.067
|
||||
margin_left = -269.77
|
||||
margin_top = 276.615
|
||||
margin_right = -269.907
|
||||
margin_bottom = 277.416
|
||||
grow_horizontal = 2
|
||||
margin_right = 169.0
|
||||
margin_bottom = 49.0
|
||||
mouse_filter = 2
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="PointData" type="VBoxContainer" parent="."]
|
||||
margin_left = 10.0
|
||||
margin_top = 5.0
|
||||
margin_right = 61.0
|
||||
margin_bottom = 36.0
|
||||
margin_top = 8.0
|
||||
margin_right = 159.0
|
||||
margin_bottom = 42.0
|
||||
grow_horizontal = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_constants/separation = 3
|
||||
custom_constants/separation = 6
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Function" type="Label" parent="PointData"]
|
||||
margin_right = 51.0
|
||||
[node name="x" type="Label" parent="PointData"]
|
||||
margin_right = 55.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 3
|
||||
align = 1
|
||||
size_flags_horizontal = 0
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "{x value}"
|
||||
valign = 1
|
||||
|
||||
[node name="Value" type="HBoxContainer" parent="PointData"]
|
||||
margin_top = 17.0
|
||||
margin_right = 51.0
|
||||
margin_bottom = 31.0
|
||||
margin_top = 20.0
|
||||
margin_right = 149.0
|
||||
margin_bottom = 34.0
|
||||
grow_horizontal = 2
|
||||
size_flags_horizontal = 6
|
||||
alignment = 1
|
||||
size_flags_horizontal = 7
|
||||
custom_constants/separation = 1
|
||||
|
||||
[node name="x" type="Label" parent="PointData/Value"]
|
||||
margin_right = 39.0
|
||||
[node name="Color" type="Panel" parent="PointData/Value"]
|
||||
margin_top = 2.0
|
||||
margin_right = 10.0
|
||||
margin_bottom = 12.0
|
||||
rect_min_size = Vector2( 10, 10 )
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
custom_styles/panel = SubResource( 2 )
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="PointData/Value"]
|
||||
margin_left = 11.0
|
||||
margin_right = 15.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 3
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "Value:"
|
||||
align = 2
|
||||
custom_constants/separation = 4
|
||||
custom_styles/separator = SubResource( 3 )
|
||||
|
||||
[node name="Function" type="Label" parent="PointData/Value"]
|
||||
margin_left = 16.0
|
||||
margin_right = 78.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 5
|
||||
text = "{function}"
|
||||
valign = 1
|
||||
|
||||
[node name="sep" type="Label" parent="PointData/Value"]
|
||||
margin_left = 79.0
|
||||
margin_right = 83.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 5
|
||||
text = ":"
|
||||
valign = 1
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="PointData/Value"]
|
||||
margin_left = 84.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 14.0
|
||||
custom_constants/separation = 4
|
||||
custom_styles/separator = SubResource( 3 )
|
||||
|
||||
[node name="y" type="Label" parent="PointData/Value"]
|
||||
margin_left = 43.0
|
||||
margin_right = 51.0
|
||||
margin_left = 89.0
|
||||
margin_right = 144.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 5
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "0"
|
||||
text = "{y value}"
|
||||
valign = 1
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_DataTooltip_visibility_changed"]
|
||||
|
Loading…
Reference in New Issue
Block a user