pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
306 stars 59 forks source link

Some wxGraphicsContext methods accept Lua table as an array of wxPoint2DDoubles #53

Closed toshinagata closed 4 years ago

toshinagata commented 4 years ago

DrawLines(), StrokeLines() (two variants) need an array of wxPoint2DDoubles, just like wxDC:DrawLines() needs an array of wxPoints. The arguments of these methods are modified so that they work similarly as in wxDC:DrawLines(). One of the variants of StrokeLines() needs an override, because it accepts only one 'n' (= the number of wxPoint2DDoubles) argument but two arrays of wxPoint2DDoubles.

pkulchenko commented 4 years ago

@toshinagata, looks good, thank you for the patch!

I have couple of questions/suggestions:

toshinagata commented 4 years ago

@pkulchenko, you're right. I have just pushed one more commit. Is that all right?

toshinagata commented 4 years ago

Sorry, one more commit. I overlooked the overridden StrokeLines().

pkulchenko commented 4 years ago

@toshinagata, the changes look good, but I get compilation errors on Windows (gcc version 9.2.0 (Rev2, Built by MSYS2 project)):

Scanning dependencies of target wxLuaModule
[  2%] Building CXX object modules/luamodule/CMakeFiles/wxLuaModule.dir/luamodule.cpp.obj
In file included from .../wxlua/wxLua/modules/wxlua/wxlstate.h:14,
                 from .../wxlua/wxLua/modules/luamodule/luamodule.cpp:35:
.../wxlua/wxLua/modules/wxlua/wxllua.h:556:46: error: 'wxPoint2DDouble' was not declared in this scope
  556 | WXDLLIMPEXP_WXLUA wxLuaSharedPtr<std::vector<wxPoint2DDouble> > LUACALL wxlua_getwxPoint2DDoubleArray(lua_State* L, int stack_idx);
      |                                              ^~~~~~~~~~~~~~~
.../wxlua/wxLua/modules/wxlua/wxllua.h:556:61: error: template argument 1 is invalid
  556 | WXDLLIMPEXP_WXLUA wxLuaSharedPtr<std::vector<wxPoint2DDouble> > LUACALL wxlua_getwxPoint2DDoubleArray(lua_State* L, int stack_idx);
      |                                                             ^
.../wxlua/wxLua/modules/wxlua/wxllua.h:556:61: error: template argument 2 is invalid
.../wxlua/wxLua/modules/wxlua/wxllua.h:556:63: error: template argument 1 is invalid
  556 | WXDLLIMPEXP_WXLUA wxLuaSharedPtr<std::vector<wxPoint2DDouble> > LUACALL wxlua_getwxPoint2DDoubleArray(lua_State* L, int stack_idx);
      |                                                               ^
make[2]: *** [modules/luamodule/CMakeFiles/wxLuaModule.dir/build.make:63: modules/luamodule/CMakeFiles/wxLuaModule.dir/luamodule.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:328: modules/luamodule/CMakeFiles/wxLuaModule.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
Error: failed to build wxLua

Do you know what may be missing?

toshinagata commented 4 years ago

It looks like we need #include <wx/geometry.h> somewhere. Does this patch work?

pkulchenko commented 4 years ago

Yes, the patched worked; thank you.