cgv
|
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 | |
provider * | provider_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. | |
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.
|
strong |
Operation mode enum.
Definition at line 32 of file directory_helper.h.
|
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.
|
inline |
Construct with arguments.
p | The gui provider pointer. |
title | The title shown in the directory dialog. |
mode | The operating mode. |
Definition at line 62 of file directory_helper.h.
|
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().
|
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().
|
inline |
Create the gui control for the directoy input.
label | The control label |
extra_options | Additional 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_.
|
inline |
Get the default path.
Definition at line 94 of file directory_helper.h.
References path_.
|
inline |
Get the title.
Definition at line 77 of file directory_helper.h.
References title_.
|
inline |
Check whether a save action was performed.
Definition at line 137 of file directory_helper.h.
References directory_name, provider_ptr_, and cgv::gui::provider::ref_tree_node_visible_flag().
|
inline |
Set the default path.
path | The 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().
|
inline |
Set the current directory name.
directory_name | The directory name. |
Definition at line 111 of file directory_helper.h.
References directory_name, provider_ptr_, and cgv::gui::provider::update_member().
|
inline |
Set the title.
title | The new title. |
Definition at line 84 of file directory_helper.h.
References directory_name, provider_ptr_, cgv::gui::provider::set_control_property(), and title_.
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().
|
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().
|
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().
|
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().
|
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().