Skip to content

Commit

Permalink
[graphics] Add FillType & DropShadow
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 17, 2023
1 parent 4d20d1b commit e9268a9
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 14 deletions.
2 changes: 2 additions & 0 deletions module/lua_juce/lua_juce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ auto allModules(sol::state& lua) -> void
juce_Colour(table);
juce_ColourGradient(table);
juce_Colours(table);
juce_DropShadow(table);
juce_FillType(table);
juce_Font(table);
juce_Graphics(table);
juce_Image(table);
Expand Down
36 changes: 36 additions & 0 deletions module/lua_juce_graphics/colour/FillType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace lua_juce {

auto juce_FillType(sol::table& state) -> void
{
auto fill = state.new_usertype<juce::FillType>( //
"FillType", //
sol::constructors< //
juce::FillType(), //
juce::FillType(juce::Colour), //
juce::FillType(juce::ColourGradient const&), //
juce::FillType(juce::Image const&, juce::AffineTransform const&) //
>() //
);

// member functions
fill["isColour"] = LUA_JUCE_C_CALL(&juce::FillType::isColour);
fill["isGradient"] = LUA_JUCE_C_CALL(&juce::FillType::isGradient);
fill["isTiledImage"] = LUA_JUCE_C_CALL(&juce::FillType::isTiledImage);
fill["setColour"] = LUA_JUCE_C_CALL(&juce::FillType::setColour);
fill["setGradient"] = LUA_JUCE_C_CALL(&juce::FillType::setGradient);
fill["setTiledImage"] = LUA_JUCE_C_CALL(&juce::FillType::setTiledImage);
fill["setOpacity"] = LUA_JUCE_C_CALL(&juce::FillType::setOpacity);
fill["getOpacity"] = LUA_JUCE_C_CALL(&juce::FillType::getOpacity);
fill["isInvisible"] = LUA_JUCE_C_CALL(&juce::FillType::isInvisible);
fill["transformed"] = LUA_JUCE_C_CALL(&juce::FillType::transformed);

// member vars
fill["colour"] = &juce::FillType::colour;
fill["image"] = &juce::FillType::image;
fill["transform"] = &juce::FillType::transform;

// TODO(tobi): unique_ptr crashes on gcc 13.2. Other platforms not tested
// fill["gradient"] = &juce::FillType::gradient;
}

} // namespace lua_juce
24 changes: 24 additions & 0 deletions module/lua_juce_graphics/effects/DropShadow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace lua_juce {

auto juce_DropShadow(sol::table& state) -> void
{
auto fill = state.new_usertype<juce::DropShadow>( //
"DropShadow", //
sol::constructors< //
juce::DropShadow(), //
juce::DropShadow(juce::Colour, int, juce::Point<int>) //
>() //
);

// member functions
fill["drawForImage"] = LUA_JUCE_C_CALL(&juce::DropShadow::drawForImage);
fill["drawForPath"] = LUA_JUCE_C_CALL(&juce::DropShadow::drawForPath);
fill["drawForRectangle"] = LUA_JUCE_C_CALL(&juce::DropShadow::drawForRectangle);

// member vars
fill["colour"] = &juce::DropShadow::colour;
fill["radius"] = &juce::DropShadow::radius;
fill["offset"] = &juce::DropShadow::offset;
}

} // namespace lua_juce
28 changes: 15 additions & 13 deletions module/lua_juce_graphics/lua_juce_graphics.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <lua_juce_graphics/lua_juce_graphics.hpp>

#include "colour/Colour.cpp"
#include "colour/ColourGradient.cpp"
#include "colour/Colours.cpp"
#include "contexts/Graphics.cpp"
#include "font/Font.cpp"
#include "geometry/AffineTransform.cpp"
#include "geometry/Line.cpp"
#include "geometry/Path.cpp"
#include "geometry/Point.cpp"
#include "geometry/Rectangle.cpp"
#include "images/Image.cpp"
#include "images/ImageCache.cpp"
#include "placement/Justification.cpp"
#include "colour/Colour.cpp" // NOLINT
#include "colour/ColourGradient.cpp" // NOLINT
#include "colour/Colours.cpp" // NOLINT
#include "colour/FillType.cpp" // NOLINT
#include "contexts/Graphics.cpp" // NOLINT
#include "effects/DropShadow.cpp" // NOLINT
#include "font/Font.cpp" // NOLINT
#include "geometry/AffineTransform.cpp" // NOLINT
#include "geometry/Line.cpp" // NOLINT
#include "geometry/Path.cpp" // NOLINT
#include "geometry/Point.cpp" // NOLINT
#include "geometry/Rectangle.cpp" // NOLINT
#include "images/Image.cpp" // NOLINT
#include "images/ImageCache.cpp" // NOLINT
#include "placement/Justification.cpp" // NOLINT
2 changes: 2 additions & 0 deletions module/lua_juce_graphics/lua_juce_graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace lua_juce {
auto juce_Colour(sol::table& state) -> void;
auto juce_ColourGradient(sol::table& state) -> void;
auto juce_Colours(sol::table& state) -> void;
auto juce_DropShadow(sol::table& state) -> void;
auto juce_Graphics(sol::table& state) -> void;
auto juce_FillType(sol::table& state) -> void;
auto juce_Font(sol::table& state) -> void;
auto juce_AffineTransform(sol::table& state) -> void;
auto juce_Line(sol::table& state) -> void;
Expand Down
69 changes: 69 additions & 0 deletions tool/jml-docgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
- [AffineTransform](#AffineTransform)
- [Colour](#Colour)
- [ColourGradient](#ColourGradient)
- [DropShadow](#DropShadow)
- [FillType](#FillType)
- [Font](#Font)
- [Graphics](#Graphics)
- [Image](#Image)
- [Path](#Path)
- [juce_gui_basics](#juce_gui_basics)
- [ComboBox](#ComboBox)
- [ComponentListener](#ComponentListener)
Expand Down Expand Up @@ -675,6 +678,35 @@ juce.ColourGradient.removeColour(...)
juce.ColourGradient.setColour(...)
juce.ColourGradient.vertical(...)
```
## DropShadow

```lua
juce.DropShadow.colour(...)
juce.DropShadow.drawForImage(...)
juce.DropShadow.drawForPath(...)
juce.DropShadow.drawForRectangle(...)
juce.DropShadow.new(...)
juce.DropShadow.offset(...)
juce.DropShadow.radius(...)
```
## FillType

```lua
juce.FillType.colour(...)
juce.FillType.getOpacity(...)
juce.FillType.image(...)
juce.FillType.isColour(...)
juce.FillType.isGradient(...)
juce.FillType.isInvisible(...)
juce.FillType.isTiledImage(...)
juce.FillType.new(...)
juce.FillType.setColour(...)
juce.FillType.setGradient(...)
juce.FillType.setOpacity(...)
juce.FillType.setTiledImage(...)
juce.FillType.transform(...)
juce.FillType.transformed(...)
```
## Font

```lua
Expand Down Expand Up @@ -765,6 +797,43 @@ juce.Image.new(...)
juce.Image.rescaled(...)
juce.Image.setPixelAt(...)
```
## Path

```lua
juce.Path.addArc(...)
juce.Path.addArrow(...)
juce.Path.addBubble(...)
juce.Path.addCentredArc(...)
juce.Path.addLineSegment(...)
juce.Path.addPolygon(...)
juce.Path.addQuadrilateral(...)
juce.Path.addStar(...)
juce.Path.applyTransform(...)
juce.Path.clear(...)
juce.Path.closeSubPath(...)
juce.Path.contains(...)
juce.Path.createPathWithRoundedCorners(...)
juce.Path.getBounds(...)
juce.Path.getBoundsTransformed(...)
juce.Path.getClippedLine(...)
juce.Path.getCurrentPosition(...)
juce.Path.getLength(...)
juce.Path.getNearestPoint (...)
juce.Path.getPointAlongPath(...)
juce.Path.intersectsLine(...)
juce.Path.isEmpty(...)
juce.Path.isUsingNonZeroWinding(...)
juce.Path.loadPathFromData(...)
juce.Path.loadPathFromStream(...)
juce.Path.new(...)
juce.Path.preallocateSpace(...)
juce.Path.restoreFromString(...)
juce.Path.scaleToFit(...)
juce.Path.setUsingNonZeroWinding(...)
juce.Path.swapWithPath(...)
juce.Path.toString(...)
juce.Path.writePathToStream(...)
```
## juce_gui_basics

## ComboBox
Expand Down
5 changes: 4 additions & 1 deletion tool/jml-docgen/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,14 @@ local classes = {
juce_data_structures = {juce.UndoManager.new(0, 0), juce.ValueTree.new()},
juce_graphics = {
juce.AffineTransform.new(),
juce.Font.new(12.0),
juce.Colour.new(0, 0, 0, 0),
juce.ColourGradient.new(),
juce.DropShadow.new(),
juce.FillType.new(),
juce.Font.new(12.0),
juce.Image.new(),
juce.Graphics.new(juce.Image.new()),
juce.Path.new(),
},
juce_gui_basics = {
juce.ComponentListener.new(),
Expand Down

0 comments on commit e9268a9

Please sign in to comment.