Skip to content

Commit

Permalink
Show the index of the palette swatches when color indices are visible…
Browse files Browse the repository at this point in the history
… on the canvas
  • Loading branch information
OverloadedOrama committed Dec 14, 2024
1 parent 206773c commit 605bff7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Palette/PaletteGrid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func draw_palette() -> void:
var grid_index := i + grid_size.x * j
var index := convert_grid_index_to_palette_index(grid_index)
var swatch := swatches[grid_index]
swatch.color_index = index
swatch.show_left_highlight = Palettes.left_selected_color == index
swatch.show_right_highlight = Palettes.right_selected_color == index
var color = current_palette.get_color(index)
Expand Down
18 changes: 18 additions & 0 deletions src/Palette/PaletteSwatch.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ signal dropped(source_index: int, new_index: int)
const DEFAULT_COLOR := Color(0.0, 0.0, 0.0, 0.0)

var index := -1
var color_index := -1
var show_left_highlight := false
var show_right_highlight := false
var empty := true:
Expand Down Expand Up @@ -48,6 +49,23 @@ func _draw() -> void:
draw_rect(
Rect2(margin - Vector2.ONE, size - margin * 2 + Vector2(2, 2)), Color.WHITE, false, 1
)
if Global.show_pixel_indices:
var font := Themes.get_font()
var str_pos := Vector2(size.x / 2, size.y - 2)
var text_color := Global.control.theme.get_color(&"font_color", &"Label")
draw_string_outline(
font,
str_pos,
str(color_index),
HORIZONTAL_ALIGNMENT_RIGHT,
-1,
size.x / 2,
1,
text_color.inverted()
)
draw_string(
font, str_pos, str(color_index), HORIZONTAL_ALIGNMENT_RIGHT, -1, size.x / 2, text_color
)


## Enables drawing of highlights which indicate selected swatches
Expand Down

0 comments on commit 605bff7

Please sign in to comment.