Add AlignType type
This commit is contained in:
39
src/types/align_type.rs
Normal file
39
src/types/align_type.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum AlignType {
|
||||
Undefined = bindings::AlignType_UndefinedAlign,
|
||||
Left = bindings::AlignType_LeftAlign,
|
||||
Center = bindings::AlignType_CenterAlign,
|
||||
Right = bindings::AlignType_RightAlign,
|
||||
}
|
||||
|
||||
impl Default for AlignType {
|
||||
fn default() -> Self {
|
||||
return AlignType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AlignType> for bindings::AlignType {
|
||||
fn from(value: AlignType) -> Self {
|
||||
return value as bindings::AlignType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::AlignType> for AlignType {
|
||||
fn from(value: bindings::AlignType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `AlignType` has the same repr as `bindings::AlignType` - u32
|
||||
*
|
||||
* If `value` is less than Right than it is in the vaild range and can be safely
|
||||
* reinterpreted as `AlignType`
|
||||
*/
|
||||
if value <= bindings::AlignType_RightAlign {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return AlignType::default();
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
mod align_type;
|
||||
mod alpha_channel_option;
|
||||
mod clip_path_units;
|
||||
mod colorspace_type;
|
||||
@ -23,6 +24,7 @@ mod statistic_type;
|
||||
mod stretch_type;
|
||||
mod style_type;
|
||||
|
||||
pub use self::align_type::AlignType;
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
pub use self::clip_path_units::ClipPathUnits;
|
||||
pub use self::colorspace_type::ColorspaceType;
|
||||
|
||||
@ -21,6 +21,7 @@ use bindings;
|
||||
use crate::result::MagickError;
|
||||
use crate::result::Result;
|
||||
use crate::{
|
||||
AlignType,
|
||||
ClipPathUnits,
|
||||
FillRule,
|
||||
GravityType,
|
||||
@ -115,7 +116,7 @@ impl DrawingWand {
|
||||
get_stroke_width, set_stroke_width, DrawGetStrokeWidth, DrawSetStrokeWidth, f64
|
||||
get_stroke_antialias, set_stroke_antialias, DrawGetStrokeAntialias, DrawSetStrokeAntialias, bindings::MagickBooleanType
|
||||
|
||||
get_text_alignment, set_text_alignment, DrawGetTextAlignment, DrawSetTextAlignment, bindings::AlignType
|
||||
get_text_alignment, set_text_alignment, DrawGetTextAlignment, DrawSetTextAlignment, AlignType
|
||||
get_text_antialias, set_text_antialias, DrawGetTextAntialias, DrawSetTextAntialias, bindings::MagickBooleanType
|
||||
get_text_decoration, set_text_decoration, DrawGetTextDecoration, DrawSetTextDecoration, bindings::DecorationType
|
||||
get_text_direction, set_text_direction, DrawGetTextDirection, DrawSetTextDirection, bindings::DirectionType
|
||||
|
||||
Reference in New Issue
Block a user