cgv
Loading...
Searching...
No Matches
cgv::gui::directory_helper Class Reference

A convenience class that provides a directory input gui control. More...

#include <directory_helper.h>

Public Types

enum class  Mode { kOpen , kSave }
 Operation mode enum. More...
 

Public Member Functions

 directory_helper ()
 Construct with default parameters.
 
 directory_helper (provider *p, const std::string &title, Mode mode)
 Construct with arguments.
 
bool can_open () const
 Return true if this directory_helper supports opening files, false otherwise.
 
bool can_save () const
 Return true if this directory_helper supports saving files, false otherwise.
 
const std::string & get_title () const
 Get the title.
 
void set_title (const std::string &title)
 Set the title.
 
const std::string & get_default_path () const
 Get the default path.
 
void set_default_path (const std::string &path)
 Set the default path.
 
void set_directory_name (const std::string &directory_name)
 Set the current directory name.
 
void create_gui (const std::string &label, const std::string &extra_options="")
 Create the gui control for the directoy input.
 
bool is_save_action () const
 Check whether a save action was performed.
 

Public Attributes

std::string directory_name = ""
 The current directory name This member is public to make it accessible to the GUI control flow.
 

Protected Attributes

providerprovider_ptr_ = nullptr
 The pointer to the gui provider for the control.
 
Mode mode_ = Mode::kOpen
 Operating mode of the control that controls the visibility of open and save buttons. Defaults to Mode::kOpen.
 
std::string title_ = ""
 The title shown in the file system dialog.
 
std::string path_ = ""
 The default path used for the file system dialog.
 

Detailed Description

A convenience class that provides a directory input gui control.

Usage: Add as a member to your provider class: cgv::gui::directory_helper input;

Set the provider pointer and mode in the constructor of your class: input = cgv::gui::file_helper(this, "Title", cgv::gui::file_helper::Mode::kOpenAndSave);

Create the gui in your create_gui method: input.create_gui("Label");

Testing for value changes in on_set(void* member_ptr): if(member_ptr == &input.file_name) { if(input.is_save_action()) { ...handle save } else { ...handle open } }

Definition at line 29 of file directory_helper.h.

Member Enumeration Documentation

◆ Mode

Operation mode enum.

Definition at line 32 of file directory_helper.h.

Constructor & Destructor Documentation

◆ directory_helper() [1/2]

cgv::gui::directory_helper::directory_helper ( )
inline

Construct with default parameters.

Default constructor is given to enable using this class as a stack variable member in other classes. Before usage it must be re-assigned with a valid provider pointer.

Definition at line 56 of file directory_helper.h.

◆ directory_helper() [2/2]

cgv::gui::directory_helper::directory_helper ( provider p,
const std::string &  title,
Mode  mode 
)
inline

Construct with arguments.

Parameters
pThe gui provider pointer.
titleThe title shown in the directory dialog.
modeThe operating mode.

Definition at line 62 of file directory_helper.h.

Member Function Documentation

◆ can_open()

bool cgv::gui::directory_helper::can_open ( ) const
inline

Return true if this directory_helper supports opening files, false otherwise.

Definition at line 65 of file directory_helper.h.

References mode_.

Referenced by create_gui().

◆ can_save()

bool cgv::gui::directory_helper::can_save ( ) const
inline

Return true if this directory_helper supports saving files, false otherwise.

Definition at line 70 of file directory_helper.h.

References mode_.

Referenced by create_gui().

◆ create_gui()

void cgv::gui::directory_helper::create_gui ( const std::string &  label,
const std::string &  extra_options = "" 
)
inline

Create the gui control for the directoy input.

Parameters
labelThe control label
extra_optionsAdditional options applied to the string input control.

Definition at line 121 of file directory_helper.h.

References cgv::gui::property_string::add(), cgv::gui::property_string::add_bracketed(), cgv::gui::provider::add_gui(), can_open(), can_save(), directory_name, path_, and provider_ptr_.

◆ get_default_path()

const std::string & cgv::gui::directory_helper::get_default_path ( ) const
inline

Get the default path.

Returns
The default path string.

Definition at line 94 of file directory_helper.h.

References path_.

◆ get_title()

const std::string & cgv::gui::directory_helper::get_title ( ) const
inline

Get the title.

Returns
The title string.

Definition at line 77 of file directory_helper.h.

References title_.

◆ is_save_action()

bool cgv::gui::directory_helper::is_save_action ( ) const
inline

Check whether a save action was performed.

Returns
True if a save action occured, false otherwise.

Definition at line 137 of file directory_helper.h.

References directory_name, provider_ptr_, and cgv::gui::provider::ref_tree_node_visible_flag().

◆ set_default_path()

void cgv::gui::directory_helper::set_default_path ( const std::string &  path)
inline

Set the default path.

Parameters
pathThe new defautl path.

Definition at line 101 of file directory_helper.h.

References directory_name, path_, provider_ptr_, and cgv::gui::provider::set_control_property().

◆ set_directory_name()

void cgv::gui::directory_helper::set_directory_name ( const std::string &  directory_name)
inline

Set the current directory name.

Parameters
directory_nameThe directory name.

Definition at line 111 of file directory_helper.h.

References directory_name, provider_ptr_, and cgv::gui::provider::update_member().

◆ set_title()

void cgv::gui::directory_helper::set_title ( const std::string &  title)
inline

Set the title.

Parameters
titleThe new title.

Definition at line 84 of file directory_helper.h.

References directory_name, provider_ptr_, cgv::gui::provider::set_control_property(), and title_.

Member Data Documentation

◆ directory_name

std::string cgv::gui::directory_helper::directory_name = ""

The current directory name This member is public to make it accessible to the GUI control flow.

It should never be set directly and set_directory_name should be used instead.

Definition at line 50 of file directory_helper.h.

Referenced by create_gui(), is_save_action(), set_default_path(), set_directory_name(), and set_title().

◆ mode_

Mode cgv::gui::directory_helper::mode_ = Mode::kOpen
protected

Operating mode of the control that controls the visibility of open and save buttons. Defaults to Mode::kOpen.

Definition at line 40 of file directory_helper.h.

Referenced by can_open(), and can_save().

◆ path_

std::string cgv::gui::directory_helper::path_ = ""
protected

The default path used for the file system dialog.

Definition at line 44 of file directory_helper.h.

Referenced by create_gui(), get_default_path(), and set_default_path().

◆ provider_ptr_

provider* cgv::gui::directory_helper::provider_ptr_ = nullptr
protected

The pointer to the gui provider for the control.

Definition at line 38 of file directory_helper.h.

Referenced by create_gui(), is_save_action(), set_default_path(), set_directory_name(), and set_title().

◆ title_

std::string cgv::gui::directory_helper::title_ = ""
protected

The title shown in the file system dialog.

Definition at line 42 of file directory_helper.h.

Referenced by get_title(), and set_title().


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