-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from endlessm/T35538-control-block-borders
Improve ControlBlock background drawing
- Loading branch information
Showing
5 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
addons/block_code/ui/blocks/utilities/background/gutter.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@tool | ||
extends Control | ||
|
||
const Constants = preload("res://addons/block_code/ui/constants.gd") | ||
|
||
var outline_color: Color | ||
|
||
@export var color: Color: | ||
set = _set_color | ||
|
||
|
||
func _set_color(new_color): | ||
color = new_color | ||
outline_color = color.darkened(0.2) | ||
queue_redraw() | ||
|
||
|
||
func _draw(): | ||
var fill_polygon: PackedVector2Array | ||
fill_polygon.append(Vector2(0.0, 0.0)) | ||
fill_polygon.append(Vector2(size.x, 0.0)) | ||
fill_polygon.append(Vector2(size.x, size.y)) | ||
fill_polygon.append(Vector2(0.0, size.y)) | ||
fill_polygon.append(Vector2(0.0, 0.0)) | ||
|
||
var left_polygon: PackedVector2Array | ||
var right_polygon: PackedVector2Array | ||
|
||
left_polygon.append(Vector2(0.0, 0.0)) | ||
left_polygon.append(Vector2(0.0, size.y)) | ||
|
||
right_polygon.append(Vector2(size.x, 0.0)) | ||
right_polygon.append(Vector2(size.x, size.y)) | ||
|
||
draw_colored_polygon(fill_polygon, color) | ||
draw_polyline(left_polygon, outline_color, Constants.OUTLINE_WIDTH) | ||
draw_polyline(right_polygon, outline_color, Constants.OUTLINE_WIDTH) |