diff --git a/addons/ColorPreview/ColorPreview.gd b/addons/ColorPreview/ColorPreview.gd index 3382003..5609708 100644 --- a/addons/ColorPreview/ColorPreview.gd +++ b/addons/ColorPreview/ColorPreview.gd @@ -158,8 +158,8 @@ func gutter_draw_color_preview(line: int, gutter: int, area: Rect2) -> void: # spacing the squares so they don't merge var padding = size / 6 - icon_region.position += Vector2(padding, padding) - icon_region.size -= Vector2(padding, padding) * 2 + icon_region = icon_region.grow(-padding) + var icon_corner_region = PackedVector2Array([ icon_region.end, icon_region.end + Vector2(-icon_region.size.x / 2, 0.0), @@ -171,9 +171,23 @@ func gutter_draw_color_preview(line: int, gutter: int, area: Rect2) -> void: var line_color = get_line_color(current_textedit, line) # black is falsey, comparing to null allows us to preview it - if line_color != null: + if line_color is Color: + line_color = line_color as Color + + if line_color.a < 1: # transparent -> add checkered bg + no-alpha corner + current_textedit.draw_rect(icon_region, Color.WHITE) + current_textedit.draw_rect( Rect2( + Vector2(icon_region.position.x + icon_region.size.x/2, icon_region.position.y), + icon_region.size/2 + ), Color.DIM_GRAY) + current_textedit.draw_rect( Rect2( + Vector2(icon_region.position.x, icon_region.position.y + icon_region.size.y/2), + icon_region.size/2 + ), Color.DIM_GRAY) + + current_textedit.draw_colored_polygon(icon_corner_region, Color(line_color, 1.0)) + current_textedit.draw_rect(icon_region, line_color) - current_textedit.draw_colored_polygon(icon_corner_region, Color(line_color, 1.0)) current_textedit.set_line_gutter_clickable(line, gutter_position, true) if hovering: @@ -213,7 +227,7 @@ func set_line_color(textedit: TextEdit, line: int, color = null) -> void: func get_line_color(textedit: TextEdit, line: int): var meta = textedit.get_line_gutter_metadata(line, gutter_position) - return meta if meta != null else null + return meta if meta is Color else null ### ### ### COLOR PICKER ### ### ### diff --git a/addons/ColorPreview/Picker.tscn b/addons/ColorPreview/Picker.tscn index e25ab35..0f94fb6 100644 --- a/addons/ColorPreview/Picker.tscn +++ b/addons/ColorPreview/Picker.tscn @@ -1,4 +1,4 @@ -[gd_scene format=3 uid="uid://bd8slp7oko0my"] +[gd_scene format=3 uid="uid://dlhe1fiimv8if"] [node name="Popup" type="Popup"] size = Vector2i(465, 775) @@ -8,10 +8,11 @@ content_scale_aspect = 1 content_scale_factor = 1.5 [node name="ColorPicker" type="ColorPicker" parent="."] -offset_left = 9.0 -offset_top = 9.0 -offset_right = 299.0 -offset_bottom = 506.0 +offset_left = 5.0 +offset_top = 5.0 +offset_right = 295.0 +offset_bottom = 502.0 +deferred_mode = true __meta__ = { "_edit_use_custom_anchors": false } diff --git a/addons/ColorPreview/plugin.cfg b/addons/ColorPreview/plugin.cfg index 2d7c8de..175431d 100644 --- a/addons/ColorPreview/plugin.cfg +++ b/addons/ColorPreview/plugin.cfg @@ -2,6 +2,6 @@ name="ColorPreview" description="An Editor Plugin which lets you preview and adjust colors from code directly next to them" -author="Ste" -version="2.0" +author="Ste and Contributors" +version="2.1.0" script="ColorPreview.gd" diff --git a/colors.png b/colors.png index 85a9158..3fa30a6 100644 Binary files a/colors.png and b/colors.png differ