Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::editor::BrowserFileDialog Class Reference

Asynchronous browser-owned file access; the host window must outlive this object. More...

#include "donner/editor/BrowserFileDialog.h"

Classes

struct  Result
 Owning result consumed by the editor thread. More...

Public Types

enum class  Operation {
  Open ,
  ChooseSaveTarget ,
  Write ,
  ChooseExportTarget
}
 Browser operation whose completion is being delivered.
enum class  Status {
  Success ,
  Cancelled ,
  Failed ,
  Downloaded
}
 Completion outcome, with cancellation distinct from failure.

Public Member Functions

 BrowserFileDialog (std::function< void()> wake)
 Register a thread-safe wake callback for completed browser requests.
 BrowserFileDialog (const BrowserFileDialog &)=delete
BrowserFileDialog & operator= (const BrowserFileDialog &)=delete
bool pending () const
 Whether a picker/write is running or its completion still awaits consumption.
bool open ()
 Request one SVG through the browser's native picker.
void acceptOpen (bool accepted)
 Adopt the selected open handle only after the editor accepts its SVG contents.
bool chooseSaveTarget (std::string_view name, bool saveAs, bool replaceBacking=true)
 Choose a destination before waiting for document synchronization.
bool write (std::string_view source)
 Write the supplied immutable source to the previously selected destination.
std::optional< Result > takeResult ()
 Consume a completed request, if any.

Static Public Member Functions

static bool available ()
 Whether this platform uses browser file pickers.
static void reportError (std::string_view message)
 Show a file-operation error using the browser's dialog surface.

Detailed Description

Asynchronous browser-owned file access; the host window must outlive this object.


Class Documentation

◆ donner::editor::BrowserFileDialog::Result

struct donner::editor::BrowserFileDialog::Result

Owning result consumed by the editor thread.

Class Members
string error User-facing failure message.
string name Selected filename, without a host path.
Operation operation Completed operation.
string source SVG text returned by Open.
Status status Success, cancellation or failure.

Constructor & Destructor Documentation

◆ BrowserFileDialog()

donner::editor::BrowserFileDialog::BrowserFileDialog ( std::function< void()> wake)
explicit

Register a thread-safe wake callback for completed browser requests.

Parameters
wakeNonblocking callback; its captured host must outlive this object.

Member Function Documentation

◆ acceptOpen()

void donner::editor::BrowserFileDialog::acceptOpen ( bool accepted)

Adopt the selected open handle only after the editor accepts its SVG contents.

Parameters
acceptedWhether parsing and loading succeeded.

◆ chooseSaveTarget()

bool donner::editor::BrowserFileDialog::chooseSaveTarget ( std::string_view name,
bool saveAs,
bool replaceBacking = true )

Choose a destination before waiting for document synchronization.

Parameters
nameSuggested filename.
saveAsAlways prompt for a new destination.
replaceBackingWhether a successful write becomes the document save destination.

◆ reportError()

void donner::editor::BrowserFileDialog::reportError ( std::string_view message)
static

Show a file-operation error using the browser's dialog surface.

Parameters
messageUser-facing failure detail.

◆ write()

bool donner::editor::BrowserFileDialog::write ( std::string_view source)

Write the supplied immutable source to the previously selected destination.

Parameters
sourceExact SVG bytes to write.

The documentation for this class was generated from the following file: