-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Default to opaque white color in more CanvasItem::draw_*
methods
#79666
base: master
Are you sure you want to change the base?
Default to opaque white color in more CanvasItem::draw_*
methods
#79666
Conversation
I think we should do that as well for consistency. |
Looks like this will require compatibility methods for GDExtension and C#. Take a look at the "files changed" tab for more info |
c7ddf07
to
e823d10
Compare
Changed some.
Added compat methods, based on #76577. Kinda no idea what I'm doing though. 🙃 |
servers/rendering_server.h
Outdated
void canvas_item_add_line_79666(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = -1.0, bool p_antialiased = false); | ||
void canvas_item_add_rect_79666(RID p_item, const Rect2 &p_rect, const Color &p_color); | ||
void canvas_item_add_circle_79666(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color); |
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.
Note these are for pure virtual methods. Is it fine like this? 🤔
1fdcc88
to
3c94a4d
Compare
We currently don't generate compat methods for C#, so they have to be added manually: diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Compat.cs b/modules/mono/glue/GodotSharp/GodotSharp/Compat.cs
index 41cea031ab..b8f8ff7927 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Compat.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Compat.cs
@@ -24,6 +24,65 @@ partial class AnimationNode
}
}
+partial class CanvasItem
+{
+ /// <inheritdoc cref="DrawArc(Vector2, float, float, float, int, Nullable{Color}, float, bool)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawArc(Vector2 center, float radius, float startAngle, float endAngle, int pointCount, Color color, float width, bool antialiased)
+ {
+ DrawArc(center, radius, startAngle, endAngle, pointCount, new Nullable<Color>(color), width, antialiased);
+ }
+
+ /// <inheritdoc cref="DrawCircle(Vector2, float, Nullable{Color})"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawCircle(Vector2 position, float radius, Color color)
+ {
+ DrawCircle(position, radius, new Nullable<Color>(color));
+ }
+
+ /// <inheritdoc cref="DrawColoredPolygon(Vector2[], Nullable{Color}, Vector2[], Texture2D)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawColoredPolygon(Vector2[] points, Color color, Vector2[] uvs, Texture2D texture)
+ {
+ DrawColoredPolygon(points, new Nullable<Color>(color), uvs, texture);
+ }
+
+ /// <inheritdoc cref="DrawDashedLine(Vector2, Vector2, Nullable{Color}, float, float, bool)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawDashedLine(Vector2 from, Vector2 to, Color color, float width, float dash, bool aligned)
+ {
+ DrawDashedLine(from, to, new Nullable<Color>(color), width, dash, aligned);
+ }
+
+ /// <inheritdoc cref="DrawLine(Vector2, Vector2, Nullable{Color}, float, bool)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawLine(Vector2 from, Vector2 to, Color color, float width, bool antialiased)
+ {
+ DrawLine(from, to, new Nullable<Color>(color), width, antialiased);
+ }
+
+ /// <inheritdoc cref="DrawMultiline(Vector2[], Nullable{Color}, float)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawMultiline(Vector2[] points, Color color, float width)
+ {
+ DrawMultiline(points, new Nullable<Color>(color), width);
+ }
+
+ /// <inheritdoc cref="DrawPolyline(Vector2[], Nullable{Color}, float, bool)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawPolyline(Vector2[] points, Color color, float width, bool antialiased)
+ {
+ DrawPolyline(points, new Nullable<Color>(color), width, antialiased);
+ }
+
+ /// <inheritdoc cref="DrawRect(Rect2, Nullable{Color}, bool, float)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DrawRect(Rect2 rect, Color color, bool filled, float width)
+ {
+ DrawRect(rect, new Nullable<Color>(color), filled, width);
+ }
+}
+
partial class CodeEdit
{
/// <inheritdoc cref="AddCodeCompletionOption(CodeCompletionKind, string, string, Nullable{Color}, Resource, Nullable{Variant})"/>
@@ -81,6 +140,30 @@ partial class RenderingDevice
}
}
+partial class RenderingServer
+{
+ /// <inheritdoc cref="CanvasItemAddCircle(Rid, Vector2, float, Nullable{Color})"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void CanvasItemAddCircle(Rid item, Vector2 pos, float radius, Color color)
+ {
+ CanvasItemAddCircle(item, pos, radius, new Nullable<Color>(color));
+ }
+
+ /// <inheritdoc cref="CanvasItemAddLine(Rid, Vector2, Vector2, Nullable{Color}, float, bool)"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void CanvasItemAddLine(Rid item, Vector2 from, Vector2 to, Color color, float width, bool antialiased)
+ {
+ CanvasItemAddLine(item, from, to, new Nullable<Color>(color), width, antialiased);
+ }
+
+ /// <inheritdoc cref="CanvasItemAddRect(Rid, Rect2, Nullable{Color})"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void CanvasItemAddRect(Rid item, Rect2 rect, Color color)
+ {
+ CanvasItemAddRect(item, rect, new Nullable<Color>(color));
+ }
+}
+
partial class RichTextLabel
{
/// <inheritdoc cref="PushList(int, ListType, bool, string)"/>
|
3c94a4d
to
023e66f
Compare
023e66f
to
77c8967
Compare
Thanks! I've skimmed them and they look good to me. :-) Unfortunately, they won't actually work until after PR #79702 is merged. I think it'd be good for that to be merged first, so that CI can double check that you've gotten them all correct. |
77c8967
to
5793f99
Compare
Rebased, seeing #79702 was merged. Hopefully they are correct, will see. Anyway, thanks all of you for the help with this! 🙂 |
Unfortunately, CI is still not happy:
Looking at the code, perhaps it's because all the orignal For example, for
|
5793f99
to
54301e8
Compare
I was looking at this for some time and everything looked the same to me. Now that you've pointed it out it's so obvious, definitely needed another pair of eyes. Thanks again! I wonder why it wasn't complaining about |
Makes the
color
parameter default to opaque white (Color(1, 1, 1, 1)
) for these methods:CanvasItem::draw_dashed_line
,CanvasItem::draw_line
,CanvasItem::draw_polyline
,CanvasItem::draw_arc
,CanvasItem::draw_multiline
,CanvasItem::draw_rect
,CanvasItem::draw_circle
,CanvasItem::draw_colored_polygon
,RenderingServer::canvas_item_add_line
,RenderingServer::canvas_item_add_rect
,RenderingServer::canvas_item_add_circle
.Resolves godotengine/godot-proposals#7310.
Notes:
Color(1, 1, 1, 1)
,Color(1, 1, 1)
,Color(1.0, 1.0, 1.0)
. They are equivalent, I've changed all of them toColor(1, 1, 1, 1)
which seemed to be used the most. Could be changed to some other variant if preferred. Edit: it was done incanvas_item.h/cpp
. But e.g. inRenderingServer.h/cpp
Color(1, 1, 1)
seems to be used instead, haven't touched these.