[−][src]Struct xosd_rs::Xosd
Implementations
impl Xosd
[src]
pub fn new<'a>(lines: i32) -> Result<Self>
[src]
Create a new Xosd
object.
This creates a new xosd window that can be used to display textual or numerical data on a X11 display in a unmanaged, shaped window that appears to be transparent. It provides a similar effect to the on-screen display of many televisions and video recorders.
lines
is the maximum number of lines that the window can display.
Errors
- If
lines
is less than 1Error::InvalidLineCount
is returned. - If
xosd_create
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.display(0, Command::string("Example XOSD output")?)?;
pub fn set_bar_length(&mut self, percentage: Option<u16>) -> Result<()>
[src]
Change the length of the percentage bar or slider.
This changes the percentage of the display used by a slider or percentage bar. Normally the XOSD choses a sensible length for the bar, but you may wish to change the default behavior if there are only a small number of possible values to be displayed.
percentage
is the percentage of the display to be used up by the slider
or percentage bar, as an interger between 0 and 100. Passing None
reverts to the default behaviour.
Errors
- If
percentage
is greater than 100Error::OutOfRangePercentage
is returned. - If
xosd_set_bar_lengh
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_bar_length(Some(10))?; // Set lenght to 10% osd.set_bar_length(None)?; // Automatically determine length
pub fn display(&mut self, line: i32, command: Command) -> Result<u16>
[src]
Display data to an XOSD window.
This function displays a Command
to the XOSD window.
This function returns immediatly but the data is displayed until the
timeout limit is reached. You can set the timeout with
Xosd::set_timeout
. Use Xosd::wait_until_no_display
to block until
the data is not displayed anymore. A window that is displaying data can
be hidden by calling Xosd::hide
.
Returns
- If
command
isCommand::String
the number of characters written is returned. - If
command
isCommand::Percentage
orCommand::Slider
the value of the bar is returned.
Errors
- If
xosd_display
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(2)?; let message = "A message on your screen"; assert_eq!(osd.display(0, Command::string(&message)?)?, message.len() as u16); assert_eq!(osd.display(1, Command::percentage(13)?)?, 13);
pub fn onscreen(&mut self) -> Result<bool>
[src]
Returns wether the XOSD window is shown.
Determines wether a XOSD window is currently beeing shown.
Use Xosd::show
and Xosd::hide
to alter the visibility of the XOSD
window.
Errors
- If
xosd_is_onscreen
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; assert_eq!(osd.onscreen()?, false); osd.show()?; assert_eq!(osd.onscreen()?, true);
pub fn wait_until_no_display(&mut self) -> Result<()>
[src]
Wait until the XOSD window is not displaying anything.
Block until the timeout limit is reached and nothing is displayed on the XOSD window.
Errors
- If
xosd_wait_until_no_display
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_timeout(1)?; osd.display(0, Command::string("Example XOSD output")?)?; if osd.onscreen()? { osd.wait_until_no_display()?; }
pub fn hide(&mut self) -> Result<()>
[src]
Hide the XOSD window
This unmaps the XOSD window. Use Xosd::show
to remap it.
If Xosd::display
is used when the window is not visible, the window becomes visible again.
Errors
- If
xosd_hide
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; assert!(!osd.onscreen()?, "XOSD window initializes as hidden"); osd.display(0, Command::string("Example XOSD output")?)?; assert!(osd.onscreen()?, "using Xosd::display shows the display"); osd.hide()?; assert!(!osd.onscreen()?, "after using Xosd::hide the windows is not visible anymore");
pub fn show(&mut self) -> Result<()>
[src]
Show the XOSD window
Redisplay the data that has been previously displayed by Xosd::display
.
Errors
- If
xosd_show
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; assert!(!osd.onscreen()?, "XOSD window initializes as hidden"); osd.display(0, Command::string("Example XOSD output")?)?; assert!(osd.onscreen()?, "using Xosd::display shows the display"); osd.hide()?; assert!(!osd.onscreen()?, "after using Xosd::hide the windows is not visible anymore"); osd.show()?; assert!(!osd.onscreen()?, "after using Xosd::show the windows is visible again");
pub fn set_vertical_align(&mut self, align: VerticalAlign) -> Result<()>
[src]
Change the vertical alignment of the XOSD window
Errors
- If
xosd_set_pos
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_vertical_align(VerticalAlign::Top)?;
pub fn set_horizontal_align(&mut self, align: HorizontalAlign) -> Result<()>
[src]
Change the horizontal alignment of the XOSD window
Errors
- If
xosd_set_align
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_horizontal_align(HorizontalAlign::Right)?;
pub fn set_shadow_offset(&mut self, offset: i32) -> Result<()>
[src]
Change the shadow offset of the XOSD window
XOSD draws a shadow beneath the main XOSD window to increase readability.
Change the size of the XOSD window by altering how many pixels the shadow is offset to the bottom-right. One to four pixels result in a good effect.
Errors
- If
xosd_set_shadow_offset
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_shadow_offset(2)?;
pub fn set_outline_offset(&mut self, offset: i32) -> Result<()>
[src]
Change the outline offset of the text
XOSD draws a outline around the text on the XOSD window.
Change the thickness of the outline in pixels.
Errors
- If
xosd_set_outline_offset
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_outline_offset(2)?;
pub fn set_shadow_color<S>(&mut self, color: S) -> Result<()> where
S: Into<Vec<u8>>,
[src]
S: Into<Vec<u8>>,
Set the shadow color of the XOSD window
Change the color to one defined by X11 in
rgb.txt
.
Errors
- If
xosd_set_shadow_colour
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_shadow_color("White")?;
pub fn set_outline_color<S>(&mut self, color: S) -> Result<()> where
S: Into<Vec<u8>>,
[src]
S: Into<Vec<u8>>,
Set the outline color of the text
Change the color to one defined by X11 in
rgb.txt
.
Errors
- If
xosd_set_outline_colour
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_outline_color("Grey")?;
pub fn set_horizontal_offset(&mut self, offset: i32) -> Result<()>
[src]
Change the horizontal offset of the XOSD window
Changes the number of pixels the XOSD window is offset from left of the screen.
Errors
- If
xosd_set_horizontal_offset
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_horizontal_offset(20)?;
pub fn set_vertical_offset(&mut self, offset: i32) -> Result<()>
[src]
Change the vertical offset of the XOSD window
Changes the number of pixels the XOSD window is offset from the top or bottom of the screen. Set this to 48 to avoid desktop-panels like in GNOME or KDE.
Errors
- If
xosd_set_vertical_offset
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_vertical_offset(48)?;
pub fn set_timeout(&mut self, timeout: u16) -> Result<()>
[src]
Change the time until the XOSD window is hidden.
Changes the number of seconds to wait after displaying data to hide the XOSD window.
Errors
- If
xosd_set_timeout
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_timeout(3)?; osd.display(0, Command::string("Test")?)?; if osd.onscreen()? { osd.wait_until_no_display()?; }
pub fn set_color<S>(&mut self, color: S) -> Result<()> where
S: Into<Vec<u8>>,
[src]
S: Into<Vec<u8>>,
Change the text color
Change the color to one defined by X11 in
rgb.txt
.
Errors
- If
xosd_set_colour
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_color("LimeGreen")?;
pub fn set_font<S>(&mut self, font: S) -> Result<()> where
S: Into<Vec<u8>>,
[src]
S: Into<Vec<u8>>,
Change the text font
Changes the font used to render text on the XOSD window. A X11 font description name must be passed.
Errors
- If
xosd_set_font
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(1)?; osd.set_font("fixed")?;
pub fn color(&mut self) -> Result<(u8, u8, u8)>
[src]
Get the current text color
Returns a RGB8 tuple with (red, green, blue). XOSD originally returns RGB16 but since X11 RGB colors are defined as RGB8, it gets converted to RGB8.
Errors
If xosd_get_colour
fails the xosd error message is wrapped in a
Error::XosdError
and returned. If the color conversion from u16 to u8
fails Error::TryFromIntError
gets returned.
Example
let mut osd = Xosd::new(1)?; assert_eq!(osd.color()?, (0, 255, 0)); osd.set_color("LimeGreen")?; assert_eq!(osd.color()?, (50, 205, 50));
pub fn scroll(&mut self, lines: i32) -> Result<()>
[src]
Scroll the display
Scrolls the display by a number of lines up
Errors
- If
xosd_get_number_lines
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
let mut osd = Xosd::new(2)?; osd.display(0, Command::string("Hello,")?)?; osd.display(1, Command::string("World!")?)?; // The display shows: // Hello, // World! osd.scroll(1)?; // The display shows: // World! //
pub fn max_lines(&mut self) -> Result<i32>
[src]
Get the maximum number of lines that can be displayed on the XOSD window.
Errors
- If
xosd_get_number_lines
fails the xosd error message is wrapped in aError::XosdError
and returned.
Example
assert_eq!(Xosd::new(1)?.max_lines()?, 1); assert_eq!(Xosd::new(123)?.max_lines()?, 123);
Trait Implementations
impl Clone for Xosd
[src]
impl Debug for Xosd
[src]
impl Drop for Xosd
[src]
Calls the destructor for the XOSD object.
Panics
If xsod_uninit
fails. Or if getting the error message fails after
destroying the XOSD object fails.
impl Hash for Xosd
[src]
Auto Trait Implementations
impl RefUnwindSafe for Xosd
impl !Send for Xosd
impl !Sync for Xosd
impl Unpin for Xosd
impl UnwindSafe for Xosd
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,