Skip to content

Commit

Permalink
✨ support ink image widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Roms1383 committed Feb 4, 2024
1 parent 4da6e21 commit 6bef668
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
34 changes: 34 additions & 0 deletions src/ink/widget/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use serde::{Deserialize, Serialize};

use crate::DepotPath;

use super::Flags;


#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct inkTextureAtlas {
depot_path: DepotPath,
flags: Flags,
}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum inkBrushMirrorType
{
NoMirror = 0,
Horizontal = 1,
Vertical = 2,
Both = 3
}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum inkBrushTileType
{
NoTile = 0,
Horizontal = 1,
Vertical = 2,
Both = 3
}
24 changes: 21 additions & 3 deletions src/ink/widget/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@

mod font;
pub(crate) mod implementation;
mod image;
mod layout;
mod properties;

use enum_dispatch::enum_dispatch;
pub use implementation::*;

use serde::{Deserialize, Serialize};
use serde_aux::prelude::deserialize_bool_from_anything;

use crate::{DepotPath, Name};

use self::{
font::{
fontStyle, inkFontFamilyResource, textHorizontalAlignment, textLetterCase,
textOverflowPolicy, textVerticalAlignment,
},
layout::{inkEHorizontalAlign, inkEVerticalAlign, textJustificationType},
}, image::{inkBrushMirrorType, inkBrushTileType, inkTextureAtlas}, layout::{inkEHorizontalAlign, inkEVerticalAlign, inkMargin, textJustificationType}
};

use super::{HandleId, InkWrapper, LocalizationString};
Expand Down Expand Up @@ -106,7 +107,24 @@ native_leaf_widget!(inkTextWidget {
pub scroll_delay: u16,
pub scroll_text_speed: f32,
});
native_leaf_widget!(inkImageWidget);
native_leaf_widget!(inkImageWidget {
#[serde(deserialize_with = "deserialize_bool_from_anything")]
pub use_external_dynamic_texture: bool,
pub external_dynamic_texture: Name,
#[serde(deserialize_with = "deserialize_bool_from_anything")]
pub use_nine_slice_scale: bool,
pub nine_slice_scale: inkMargin,
pub mirror_type: inkBrushMirrorType,
pub tile_type: inkBrushTileType,
pub horizontal_tile_crop: f32,
pub vertical_tile_crop: f32,
pub texture_atlas: inkTextureAtlas,
pub texture_part: Name,
pub content_h_align: inkEHorizontalAlign,
pub content_v_align: inkEVerticalAlign,
pub tile_h_align: inkEHorizontalAlign,
pub tile_v_align: inkEVerticalAlign,
});
native_leaf_widget!(inkVideoWidget);
native_leaf_widget!(inkMaskWidget);
native_leaf_widget!(inkBorderWidget);
Expand Down

0 comments on commit 6bef668

Please sign in to comment.