godot-rust / gdnative

Rust bindings for Godot 3
https://godot-rust.github.io
MIT License
3.62k stars 210 forks source link

The draw_rect() "width" argument has no effect when "filled" is "true" warning #1017

Closed yue4u closed 1 year ago

yue4u commented 1 year ago

draw_rect method requires width parameter even when setting filled to true which results the following warning being printed.

W 0:00:02.779   draw_rect: The draw_rect() "width" argument has no effect when "filled" is "true".
  <C++ Source>  scene/2d/canvas_item.cpp:756 @ draw_rect()

API Interface:

image

Example: https://github.com/yue4u/zf/blob/7c6b4c68e9ab4129386c06299e265242a605bf4d/crates/zf/src/ui/terminal.rs#L475

I did some search but couldn't find a way to disable this warning. Maybe set the type of width parameter to optional or passing width optionally on the library side can resolve this problem?

chitoyuu commented 1 year ago

Related to #814. This is something we've been trying to find a way to deal with for a long while.

Unfortunately, there isn't a good workaround for the time being. If the warning must be suppressed, you can try calling the method with Object::call, which does allow you to omit parameters, at the cost of not being statically typed.

Keeping this open as a reference for the method generator redesign.

yue4u commented 1 year ago

Thanks for your quick reply!

you can try calling the method with Object::call,

Nice, changing to Object::call makes a lot of sense to me even with the cost of losing typing as this is the only API I have problem with.

hanya commented 1 year ago

Width == 1.0 does not make the warning.

chitoyuu commented 1 year ago

Thanks for the information! Since it has been a while since this issue was first reported, it's possible that this was fixed upstream, which would explain the change in behavior. For now, I'll proceed to close this issue.