Skip to content

Commit 605bff7

Browse files
Show the index of the palette swatches when color indices are visible on the canvas
1 parent 206773c commit 605bff7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Palette/PaletteGrid.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func draw_palette() -> void:
6464
var grid_index := i + grid_size.x * j
6565
var index := convert_grid_index_to_palette_index(grid_index)
6666
var swatch := swatches[grid_index]
67+
swatch.color_index = index
6768
swatch.show_left_highlight = Palettes.left_selected_color == index
6869
swatch.show_right_highlight = Palettes.right_selected_color == index
6970
var color = current_palette.get_color(index)

src/Palette/PaletteSwatch.gd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ signal dropped(source_index: int, new_index: int)
88
const DEFAULT_COLOR := Color(0.0, 0.0, 0.0, 0.0)
99

1010
var index := -1
11+
var color_index := -1
1112
var show_left_highlight := false
1213
var show_right_highlight := false
1314
var empty := true:
@@ -48,6 +49,23 @@ func _draw() -> void:
4849
draw_rect(
4950
Rect2(margin - Vector2.ONE, size - margin * 2 + Vector2(2, 2)), Color.WHITE, false, 1
5051
)
52+
if Global.show_pixel_indices:
53+
var font := Themes.get_font()
54+
var str_pos := Vector2(size.x / 2, size.y - 2)
55+
var text_color := Global.control.theme.get_color(&"font_color", &"Label")
56+
draw_string_outline(
57+
font,
58+
str_pos,
59+
str(color_index),
60+
HORIZONTAL_ALIGNMENT_RIGHT,
61+
-1,
62+
size.x / 2,
63+
1,
64+
text_color.inverted()
65+
)
66+
draw_string(
67+
font, str_pos, str(color_index), HORIZONTAL_ALIGNMENT_RIGHT, -1, size.x / 2, text_color
68+
)
5169

5270

5371
## Enables drawing of highlights which indicate selected swatches

0 commit comments

Comments
 (0)