Add DirectionType type

This commit is contained in:
5ohue
2024-05-11 22:07:01 +03:00
parent d8d6a12d02
commit 24c2a3d2de
3 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,39 @@
use crate::bindings;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum DirectionType {
Undefined = bindings::DirectionType_UndefinedDirection,
RightToLeft = bindings::DirectionType_RightToLeftDirection,
LeftToRight = bindings::DirectionType_LeftToRightDirection,
TopToBottom = bindings::DirectionType_TopToBottomDirection,
}
impl Default for DirectionType {
fn default() -> Self {
return DirectionType::Undefined;
}
}
impl From<DirectionType> for bindings::DirectionType {
fn from(value: DirectionType) -> Self {
return value as bindings::DirectionType;
}
}
impl From<bindings::DirectionType> for DirectionType {
fn from(value: bindings::DirectionType) -> Self {
/*
* SAFETY:
*
* `DirectionType` has the same repr as `bindings::DirectionType` - u32
*
* If `value` is less than TopToBottom than it is in the vaild range and can be safely
* reinterpreted as `DirectionType`
*/
if value <= bindings::DirectionType_TopToBottomDirection {
return unsafe { std::mem::transmute(value) };
}
return DirectionType::default();
}
}

View File

@ -5,6 +5,7 @@ mod colorspace_type;
mod composite_operator; mod composite_operator;
mod compression_type; mod compression_type;
mod decoration_type; mod decoration_type;
mod direction_type;
mod dispose_type; mod dispose_type;
mod dither_method; mod dither_method;
mod endian_type; mod endian_type;
@ -32,6 +33,7 @@ pub use self::colorspace_type::ColorspaceType;
pub use self::composite_operator::CompositeOperator; pub use self::composite_operator::CompositeOperator;
pub use self::compression_type::CompressionType; pub use self::compression_type::CompressionType;
pub use self::decoration_type::DecorationType; pub use self::decoration_type::DecorationType;
pub use self::direction_type::DirectionType;
pub use self::dispose_type::DisposeType; pub use self::dispose_type::DisposeType;
pub use self::dither_method::DitherMethod; pub use self::dither_method::DitherMethod;
pub use self::endian_type::EndianType; pub use self::endian_type::EndianType;

View File

@ -24,6 +24,7 @@ use crate::{
AlignType, AlignType,
ClipPathUnits, ClipPathUnits,
DecorationType, DecorationType,
DirectionType,
FillRule, FillRule,
GravityType, GravityType,
LineCap, LineCap,
@ -120,7 +121,7 @@ impl DrawingWand {
get_text_alignment, set_text_alignment, DrawGetTextAlignment, DrawSetTextAlignment, AlignType get_text_alignment, set_text_alignment, DrawGetTextAlignment, DrawSetTextAlignment, AlignType
get_text_antialias, set_text_antialias, DrawGetTextAntialias, DrawSetTextAntialias, bindings::MagickBooleanType get_text_antialias, set_text_antialias, DrawGetTextAntialias, DrawSetTextAntialias, bindings::MagickBooleanType
get_text_decoration, set_text_decoration, DrawGetTextDecoration, DrawSetTextDecoration, DecorationType get_text_decoration, set_text_decoration, DrawGetTextDecoration, DrawSetTextDecoration, DecorationType
get_text_direction, set_text_direction, DrawGetTextDirection, DrawSetTextDirection, bindings::DirectionType get_text_direction, set_text_direction, DrawGetTextDirection, DrawSetTextDirection, DirectionType
get_text_kerning, set_text_kerning, DrawGetTextKerning, DrawSetTextKerning, f64 get_text_kerning, set_text_kerning, DrawGetTextKerning, DrawSetTextKerning, f64
get_text_interline_spacing, set_text_interline_spacing, DrawGetTextInterlineSpacing, DrawSetTextInterlineSpacing, f64 get_text_interline_spacing, set_text_interline_spacing, DrawGetTextInterlineSpacing, DrawSetTextInterlineSpacing, f64
get_text_interword_spacing, set_text_interword_spacing, DrawGetTextInterwordSpacing, DrawSetTextInterwordSpacing, f64 get_text_interword_spacing, set_text_interword_spacing, DrawGetTextInterwordSpacing, DrawSetTextInterwordSpacing, f64