blob: 907ec8084bb8fef1d075bc20f336477b096584ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#include "Base.hpp"
namespace cru::platform::gui {
struct CRU_PLATFORM_GUI_API SaveDialogOptions {
String title;
String prompt;
String message;
std::vector<String> allowed_file_types;
bool allow_all_file_types = false;
};
struct CRU_PLATFORM_GUI_API OpenDialogOptions : SaveDialogOptions {
bool can_choose_files = true;
bool can_choose_directories = false;
bool allow_mulitple_selection = false;
};
template <typename T>
struct CRU_PLATFORM_GUI_API SaveDialogOptionsBuilderTemplate {
T options;
SaveDialogOptionsBuilderTemplate& SetTitle(String title) {
options.title = std::move(title);
return *this;
}
SaveDialogOptionsBuilderTemplate& SetPrompt(String prompt) {
options.prompt = std::move(prompt);
return *this;
}
SaveDialogOptionsBuilderTemplate& SetMessage(String message) {
options.message = std::move(message);
return *this;
}
SaveDialogOptionsBuilderTemplate& SetAllowedFileTypes(
std::vector<String> allowed_file_types) {
options.allowed_file_types = std::move(allowed_file_types);
return *this;
}
SaveDialogOptionsBuilderTemplate& AddAllowedFileType(
String allowed_file_type) {
options.allowed_file_types.push_back(allowed_file_type);
return *this;
}
SaveDialogOptionsBuilderTemplate& SetAllowAllFileTypes(
bool allow_all_file_types) {
options.allow_all_file_types = allow_all_file_types;
return *this;
}
T Build() { return options; }
};
using SaveDialogOptionsBuilder =
SaveDialogOptionsBuilderTemplate<SaveDialogOptions>;
struct CRU_PLATFORM_GUI_API OpenDialogOptionsBuilder
: SaveDialogOptionsBuilderTemplate<OpenDialogOptions> {
OpenDialogOptionsBuilder& SetCanChooseFiles(bool can_choose_files) {
options.can_choose_files = can_choose_files;
return *this;
}
OpenDialogOptionsBuilder& SetCanChooseDirectories(
bool can_choose_directories) {
options.can_choose_directories = can_choose_directories;
return *this;
}
OpenDialogOptionsBuilder& SetAllowMultipleSelection(
bool allow_mulitple_selection) {
options.allow_mulitple_selection = allow_mulitple_selection;
return *this;
}
};
} // namespace cru::platform::gui
|