-
Notifications
You must be signed in to change notification settings - Fork 28
Improve ControlBlock background drawing #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1265925
to
38ab701
Compare
|
||
var snap_gutter := Control.new() | ||
snap_gutter.name = "Background" | ||
snap_gutter.set_script(preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this in a couple places in here. Why not just instantiate the class directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we don't do that, indeed. I'll fix that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, set_script()
only makes sense in the BlockCode node when it replaces the parent script. All others should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very nice! The set_script
that was there before for other backgrounds and should be changed. Besides that, please leave the Pong scene out of this PR.
|
||
var snap_gutter := Control.new() | ||
snap_gutter.name = "Background" | ||
snap_gutter.set_script(preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, set_script()
only makes sense in the BlockCode node when it replaces the parent script. All others should be fixed.
Instead of reusing the background.gd script to draw a gutter in ControlBlock, define a new script (gutter.gd) specifically for that purpose. In the existing background.gd script, draw a left border which is expected to flow into the gutter if shift_top or shift_bottom is set. https://phabricator.endlessm.com/T35538
38ab701
to
b20005e
Compare
In the newest set of commits, I removed the unnecessary change to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say that I really followed the polygon changes, but I trust their right. I just had one small suggestion on class names.
@@ -144,9 +143,8 @@ func format(): | |||
snap_container.custom_minimum_size.y = 30 | |||
snap_container.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN | |||
|
|||
var snap_gutter := Control.new() | |||
var snap_gutter := BlockGutter.new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've been trying to move away from global classes unless their really needed since it reduces the chance for startup issues with the global class cache. Instead, I think you should just preload them at the top:
const BlockBackground = preload("res://addons/block_code/ui/blocks/utilities/background/background.gd")
const BlockGutter = preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Can you make this last change @dylanmccall ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed that happening! Makes sense :) That's fixed in the newest commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Manuel started it near the beginning of GUADEC in the context of import errors and I happened to notice it since I was trying to wrap up some of my own work that Thursday and Friday.
@@ -144,9 +143,8 @@ func format(): | |||
snap_container.custom_minimum_size.y = 30 | |||
snap_container.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN | |||
|
|||
var snap_gutter := Control.new() | |||
var snap_gutter := BlockGutter.new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Can you make this last change @dylanmccall ?
@@ -1,4 +1,5 @@ | |||
@tool | |||
class_name BlockBackground |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Dan pointed, please remove class_name
and use preload instead.
b20005e
to
d2495b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely, thanks!
Instead of reusing the background.gd script to draw a gutter in ControlBlock, define a new script (gutter.gd) specifically for that purpose. In the existing background.gd script, draw a left border which is expected to flow into the gutter if shift_top or shift_bottom is set.
https://phabricator.endlessm.com/T35538