UserData

Struct UserData 

Source
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的01参数。

§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

Source

pub fn new_text(text: String) -> Self

Source

pub fn new_text_with_id(id: i64, text: String) -> Self

Source

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()));
Source

pub fn set_font_and_size(self, font: Font, size: i32) -> Self

Source

pub fn set_font_and_size2(&mut self, font: Font, size: i32)

设置字体和大小,同时确认自定义字体标记。非流式调用接口。

§Arguments
  • font:
  • size:

returns: ()

§Examples
Source

pub fn set_font_size_index(self, index: u8) -> Self

Source

pub fn set_fg_color(self, fg_color: Color) -> Self

Source

pub fn set_fg_color_index(self, index: u8) -> Self

Source

pub fn set_bg_color(self, bg_color: Option<Color>) -> Self

Source

pub fn set_bg_color_index(self, index: u8) -> Self

Source

pub fn set_strong(self, strong: bool) -> Self

Source

pub fn set_underline(self, u: bool) -> Self

Source

pub fn set_clickable(self, clickable: bool) -> Self

Source

pub fn set_disabled(self, disabled: bool) -> Self

Source

pub fn set_action(self, action: Action) -> Self

设置数据段互动行为。

§Arguments
  • action: 互动操作。

returns: UserData

§Examples
Source

pub fn change_action(&mut self, action: Option<Action>)

更改当前数据段的互动行为。

§Arguments
  • action: 互动操作。

returns: ()

§Examples
Source

pub fn set_text(self, text: String) -> Self

为图片设置简短的文字描述,居中显示。 若文字较长请使用换行符'\n'进行换行,避免文字超出图片边界。

§Arguments
  • text:

returns: UserData

§Examples
Source

pub fn set_image_file_path(self, path: Option<PathBuf>) -> Self

Trait Implementations§

Source§

impl Clone for UserData

Source§

fn clone(&self) -> UserData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for UserData

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.