Skip to main content

ExportDialog

Struct ExportDialog 

Source
pub struct ExportDialog { /* private fields */ }
Expand description

Export dialog for configuring and executing chart exports

The dialog offers:

  • Format selection (PNG, CSV, Clipboard)
  • Image dimensions, title, timestamp and transparent background
  • File save path entry

The dialog only collects the request; the host performs the export. Use with_formats to offer only the formats the host can produce. The dialog stays open after a request; report its result with mark_success or mark_error.

§Example

use egui_charts::ui::export::{ExportDialog, ExportResponse};

let mut export_dialog = ExportDialog::new();

// Open the dialog
export_dialog.open();

// In your egui update loop
match export_dialog.show(ctx) {
    ExportResponse::Export { config, save_path } => {
        // Perform the actual export
        println!("Exporting with config: {:?}", config);
    }
    ExportResponse::Closed => {
        println!("Dialog closed");
    }
    ExportResponse::None => {}
}

Implementations§

Source§

impl ExportDialog

Source

pub fn new() -> Self

Creates a new export dialog with default configuration

Source

pub fn with_formats(self, formats: &[ExportFormat]) -> Self

Offers only formats, in the given order, for hosts that cannot perform every export. Selects the first of them if the current format is not offered.

Source

pub fn open(&mut self)

Opens the export dialog

This resets the export status to idle and shows the dialog.

Source

pub fn close(&mut self)

Closes the export dialog

Source

pub fn is_open(&self) -> bool

Returns whether the dialog is currently open

Source

pub fn show(&mut self, ctx: &Context) -> ExportResponse

Shows the export dialog and returns the user’s action

This displays a dialog with export configuration options. Returns ExportResponse indicating what action the user took.

§Example
let mut dialog = ExportDialog::new();
dialog.open();

match dialog.show(ctx) {
    ExportResponse::Export { config, save_path } => {
        // Perform export
    }
    ExportResponse::Closed => {}
    ExportResponse::None => {}
}
Source

pub fn show_with( &mut self, ctx: &Context, content: impl FnMut(&mut Ui, ExportFormat), ) -> ExportResponse

Shows the dialog with host controls below its title, such as an image scope chooser. content receives the currently selected format; the host keeps its own control state.

Source

pub fn mark_success(&mut self)

Marks the current export as successful

Call this after completing an export to show success status in the dialog.

Source

pub fn mark_error(&mut self, error: String)

Marks the current export as failed with an error message

Call this if an export fails to show the error in the dialog.

§Arguments
  • error - A description of what went wrong
Source

pub fn reset_status(&mut self)

Resets the export status to idle

Trait Implementations§

Source§

impl Default for ExportDialog

Source§

fn default() -> Self

Returns the “default value” for a type. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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.