pub struct UserData {Show 26 fields
pub id: i64,
pub text: String,
pub font: Font,
pub font_size: i32,
pub fg_color: Color,
pub bg_color: Option<Color>,
pub underline: bool,
pub fg_color_index: u8,
pub bg_color_index: u8,
pub strong: bool,
pub font_size_index: u8,
pub clickable: bool,
pub expired: bool,
pub blink: bool,
pub disabled: bool,
pub strike_through: bool,
pub data_type: DataType,
pub image: Option<RgbImage>,
pub image_width: i32,
pub image_height: i32,
pub image_target_width: i32,
pub image_target_height: i32,
pub image_src_url: Option<String>,
pub image_file_path: Option<PathBuf>,
pub custom_font_color: bool,
pub action: Option<Action>,
/* private fields */
}Expand description
用户提供的数据段结构。。
Fields§
§id: i64数据ID,在初始化新实例时可随意赋值。当源自RichData时,为RichData的ID值。
text: String§font: Font§font_size: i32§fg_color: Color§bg_color: Option<Color>§underline: bool§fg_color_index: u8前景色序号,从1到8对应ANSI/CSI/SGR的黑、红、绿、黄、蓝、品红、青、白的颜色序列。
bg_color_index: u8背景色序号,从1到8对应ANSI/CSI/SGR的黑、红、绿、黄、蓝、品红、青、白的颜色序列。
strong: bool显示效果是否加强,对应与ANSI/CSI的0和1参数。
font_size_index: u8文字大小编号,从1到7对应MXP协议中的SMALL、H6、H5、H4、H3、H2、H1。
clickable: bool§expired: bool§blink: bool§disabled: bool§strike_through: bool§data_type: DataType§image: Option<RgbImage>§image_width: i32原始宽度
image_height: i32原始高度
image_target_width: i32希望绘制的目标宽度
image_target_height: i32希望绘制的目标高度
image_src_url: Option<String>图片来源地址
image_file_path: Option<PathBuf>图片文件临时保存路径。
custom_font_color: bool§action: Option<Action>互动属性。
Implementations§
Source§impl UserData
impl UserData
pub fn new_text(text: String) -> Self
pub fn new_text_with_id(id: i64, text: String) -> Self
Sourcepub fn new_image(
image: RgbImage,
origin_width: i32,
origin_height: i32,
target_width: i32,
target_height: i32,
src: Option<String>,
) -> Self
pub fn new_image( image: RgbImage, origin_width: i32, origin_height: i32, target_width: i32, target_height: i32, src: Option<String>, ) -> Self
创建新的图形类型的数据段。
如果传入的图形源自SvgImage,则必须在调用本方法之前首先执行SvgImage::normalize()方法进行初始化。
§Arguments
image: RGB图像对象。original_width: 原始宽度。original_height: 原始高度。target_width: 目标宽度,可能与原始宽度不同。target_height: 目标高度,可能与原始高度不同。src: 图像来源地址。
returns: UserData
§Examples
use fltk::image::{SvgImage};
use fltk::prelude::ImageExt;
use fltkrs_richdisplay::UserData;
let mut svg = SvgImage::load("res/test.svg").unwrap();
svg.normalize();
let image = svg.to_rgb().unwrap();
let _data = UserData::new_image(image, 100, 100, 100, 100, Some("res/test.svg".to_string()));pub fn set_font_and_size(self, font: Font, size: i32) -> Self
Sourcepub fn set_font_and_size2(&mut self, font: Font, size: i32)
pub fn set_font_and_size2(&mut self, font: Font, size: i32)
pub fn set_font_size_index(self, index: u8) -> Self
pub fn set_fg_color(self, fg_color: Color) -> Self
pub fn set_fg_color_index(self, index: u8) -> Self
pub fn set_bg_color(self, bg_color: Option<Color>) -> Self
pub fn set_bg_color_index(self, index: u8) -> Self
pub fn set_strong(self, strong: bool) -> Self
pub fn set_underline(self, u: bool) -> Self
pub fn set_clickable(self, clickable: bool) -> Self
pub fn set_blink(self, blink: bool) -> Self
pub fn set_disabled(self, disabled: bool) -> Self
Sourcepub fn set_action(self, action: Action) -> Self
pub fn set_action(self, action: Action) -> Self
Sourcepub fn change_action(&mut self, action: Option<Action>)
pub fn change_action(&mut self, action: Option<Action>)
pub fn set_image_file_path(self, path: Option<PathBuf>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UserData
impl RefUnwindSafe for UserData
impl Send for UserData
impl Sync for UserData
impl Unpin for UserData
impl UnwindSafe for UserData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more