Skip to content

Commit

Permalink
Add SvgRect::expand
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Jan 12, 2024
1 parent e4922f1 commit 87ecc0f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api.json
Original file line number Diff line number Diff line change
Expand Up @@ -12643,6 +12643,17 @@
"returns": {"type": "bool"},
"fn_body": "svgrect.contains_point(point.x, point.y)"
},
"expand": {
"fn_args": [
{"self": "ref"},
{"padding_top": "f32"},
{"padding_bottom": "f32"},
{"padding_left": "f32"},
{"padding_right": "f32"}
],
"returns": {"type": "SvgRect"},
"fn_body": "svgrect.expand(padding_top, padding_bottom, padding_left, padding_right)"
},
"tessellate_fill": {
"fn_args": [
{"self": "ref"},
Expand Down
1 change: 1 addition & 0 deletions api/c/azul.h
Original file line number Diff line number Diff line change
Expand Up @@ -13185,6 +13185,7 @@ extern DLLIMPORT AzSvgVector AzSvgCubicCurve_getTangentVectorAtT(const AzSvgCubi
extern DLLIMPORT AzTessellatedSvgNode AzSvgCubicCurve_tessellateStroke(const AzSvgCubicCurve* svgcubiccurve, AzSvgStrokeStyle stroke_style);
extern DLLIMPORT AzSvgPoint AzSvgRect_getCenter(const AzSvgRect* svgrect);
extern DLLIMPORT bool AzSvgRect_containsPoint(const AzSvgRect* svgrect, AzSvgPoint point);
extern DLLIMPORT AzSvgRect AzSvgRect_expand(const AzSvgRect* svgrect, float padding_top, float padding_bottom, float padding_left, float padding_right);
extern DLLIMPORT AzTessellatedSvgNode AzSvgRect_tessellateFill(const AzSvgRect* svgrect, AzSvgFillStyle fill_style);
extern DLLIMPORT AzTessellatedSvgNode AzSvgRect_tessellateStroke(const AzSvgRect* svgrect, AzSvgStrokeStyle stroke_style);
extern DLLIMPORT AzTessellatedSvgNode AzTessellatedSvgNode_empty();
Expand Down
1 change: 1 addition & 0 deletions api/cpp/azul.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11046,6 +11046,7 @@ namespace dll {
TessellatedSvgNode SvgCubicCurve_tessellateStroke(const SvgCubicCurve* svgcubiccurve, AzSvgStrokeStyle stroke_style);
SvgPoint SvgRect_getCenter(const SvgRect* svgrect);
bool SvgRect_containsPoint(const SvgRect* svgrect, AzSvgPoint point);
SvgRect SvgRect_expand(const SvgRect* svgrect, float padding_top, float padding_bottom, float padding_left, float padding_right);
TessellatedSvgNode SvgRect_tessellateFill(const SvgRect* svgrect, AzSvgFillStyle fill_style);
TessellatedSvgNode SvgRect_tessellateStroke(const SvgRect* svgrect, AzSvgStrokeStyle stroke_style);
TessellatedSvgNode TessellatedSvgNode_empty();
Expand Down
4 changes: 4 additions & 0 deletions api/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11157,6 +11157,7 @@ mod dll {
pub(crate) fn AzSvgCubicCurve_tessellateStroke(svgcubiccurve: &AzSvgCubicCurve, stroke_style: AzSvgStrokeStyle) -> AzTessellatedSvgNode { unsafe { transmute(azul::AzSvgCubicCurve_tessellateStroke(transmute(svgcubiccurve), transmute(stroke_style))) } }
pub(crate) fn AzSvgRect_getCenter(svgrect: &AzSvgRect) -> AzSvgPoint { unsafe { transmute(azul::AzSvgRect_getCenter(transmute(svgrect))) } }
pub(crate) fn AzSvgRect_containsPoint(svgrect: &AzSvgRect, point: AzSvgPoint) -> bool { unsafe { transmute(azul::AzSvgRect_containsPoint(transmute(svgrect), transmute(point))) } }
pub(crate) fn AzSvgRect_expand(svgrect: &AzSvgRect, padding_top: f32, padding_bottom: f32, padding_left: f32, padding_right: f32) -> AzSvgRect { unsafe { transmute(azul::AzSvgRect_expand(transmute(svgrect), transmute(padding_top), transmute(padding_bottom), transmute(padding_left), transmute(padding_right))) } }
pub(crate) fn AzSvgRect_tessellateFill(svgrect: &AzSvgRect, fill_style: AzSvgFillStyle) -> AzTessellatedSvgNode { unsafe { transmute(azul::AzSvgRect_tessellateFill(transmute(svgrect), transmute(fill_style))) } }
pub(crate) fn AzSvgRect_tessellateStroke(svgrect: &AzSvgRect, stroke_style: AzSvgStrokeStyle) -> AzTessellatedSvgNode { unsafe { transmute(azul::AzSvgRect_tessellateStroke(transmute(svgrect), transmute(stroke_style))) } }
pub(crate) fn AzTessellatedSvgNode_empty() -> AzTessellatedSvgNode { unsafe { transmute(azul::AzTessellatedSvgNode_empty()) } }
Expand Down Expand Up @@ -11994,6 +11995,7 @@ mod dll {
pub(crate) fn AzSvgCubicCurve_tessellateStroke(_: &AzSvgCubicCurve, _: AzSvgStrokeStyle) -> AzTessellatedSvgNode;
pub(crate) fn AzSvgRect_getCenter(_: &AzSvgRect) -> AzSvgPoint;
pub(crate) fn AzSvgRect_containsPoint(_: &AzSvgRect, _: AzSvgPoint) -> bool;
pub(crate) fn AzSvgRect_expand(_: &AzSvgRect, _: f32, _: f32, _: f32, _: f32) -> AzSvgRect;
pub(crate) fn AzSvgRect_tessellateFill(_: &AzSvgRect, _: AzSvgFillStyle) -> AzTessellatedSvgNode;
pub(crate) fn AzSvgRect_tessellateStroke(_: &AzSvgRect, _: AzSvgStrokeStyle) -> AzTessellatedSvgNode;
pub(crate) fn AzTessellatedSvgNode_empty() -> AzTessellatedSvgNode;
Expand Down Expand Up @@ -18139,6 +18141,8 @@ pub mod svg {
pub fn get_center(&self) -> crate::svg::SvgPoint { unsafe { crate::dll::AzSvgRect_getCenter(self) } }
/// Calls the `SvgRect::contains_point` function.
pub fn contains_point<_1: Into<SvgPoint>>(&self, point: _1) -> bool { unsafe { crate::dll::AzSvgRect_containsPoint(self, point.into()) } }
/// Calls the `SvgRect::expand` function.
pub fn expand(&self, padding_top: f32, padding_bottom: f32, padding_left: f32, padding_right: f32) -> crate::svg::SvgRect { unsafe { crate::dll::AzSvgRect_expand(self, padding_top, padding_bottom, padding_left, padding_right) } }
/// Calls the `SvgRect::tessellate_fill` function.
pub fn tessellate_fill<_1: Into<SvgFillStyle>>(&self, fill_style: _1) -> crate::svg::TessellatedSvgNode { unsafe { crate::dll::AzSvgRect_tessellateFill(self, fill_style.into()) } }
/// Calls the `SvgRect::tessellate_stroke` function.
Expand Down
11 changes: 11 additions & 0 deletions azul-css/src/css_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,17 @@ impl SvgRect {
x > self.x && x < self.x + self.width && y > self.y && y < self.y + self.height
}

/// Expands the rect with a certain amount of padding
pub fn expand(&self, padding_top: f32, padding_bottom: f32, padding_left: f32, padding_right: f32) -> SvgRect {
SvgRect {
width: self.width + padding_left + padding_right,
height: self.height + padding_top + padding_bottom,
x: self.x - padding_left,
y: self.y - padding_top,
.. *self
}
}

pub fn get_center(&self) -> SvgPoint {
SvgPoint {
x: self.x + (self.width / 2.0),
Expand Down
2 changes: 2 additions & 0 deletions azul-dll/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3678,6 +3678,8 @@ pub use AzSvgRectTT as AzSvgRect;
#[no_mangle] pub extern "C" fn AzSvgRect_getCenter(svgrect: &AzSvgRect) -> AzSvgPoint { svgrect.get_center() }
/// Equivalent to the Rust `SvgRect::contains_point()` function.
#[no_mangle] pub extern "C" fn AzSvgRect_containsPoint(svgrect: &AzSvgRect, point: AzSvgPoint) -> bool { svgrect.contains_point(point.x, point.y) }
/// Equivalent to the Rust `SvgRect::expand()` function.
#[no_mangle] pub extern "C" fn AzSvgRect_expand(svgrect: &AzSvgRect, padding_top: f32, padding_bottom: f32, padding_left: f32, padding_right: f32) -> AzSvgRect { svgrect.expand(padding_top, padding_bottom, padding_left, padding_right) }
/// Equivalent to the Rust `SvgRect::tessellate_fill()` function.
#[no_mangle] pub extern "C" fn AzSvgRect_tessellateFill(svgrect: &AzSvgRect, fill_style: AzSvgFillStyle) -> AzTessellatedSvgNode { azul_impl::svg::tessellate_rect_fill(svgrect, fill_style) }
/// Equivalent to the Rust `SvgRect::tessellate_stroke()` function.
Expand Down
9 changes: 9 additions & 0 deletions azul-dll/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31868,6 +31868,15 @@ impl AzSvgRect {
mem::transmute(point),
)) }
}
fn expand(&self, padding_top: f32, padding_bottom: f32, padding_left: f32, padding_right: f32) -> AzSvgRect {
unsafe { mem::transmute(crate::AzSvgRect_expand(
mem::transmute(self),
mem::transmute(padding_top),
mem::transmute(padding_bottom),
mem::transmute(padding_left),
mem::transmute(padding_right),
)) }
}
fn tessellate_fill(&self, fill_style: AzSvgFillStyle) -> AzTessellatedSvgNode {
unsafe { mem::transmute(crate::AzSvgRect_tessellateFill(
mem::transmute(self),
Expand Down

0 comments on commit 87ecc0f

Please sign in to comment.