Added list view mode
This commit is contained in:
parent
9ea5a1eae9
commit
68a4998993
2 changed files with 95 additions and 39 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../GUIHolder.hpp"
|
#include "../GUIHolder.hpp"
|
||||||
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
||||||
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
||||||
|
#include "../GUIStuff/ElementHelpers/ScrollAreaHelpers.hpp"
|
||||||
#include "Helpers/ConvertVec.hpp"
|
#include "Helpers/ConvertVec.hpp"
|
||||||
#include "../GUIStuff/Elements/GridScrollArea.hpp"
|
#include "../GUIStuff/Elements/GridScrollArea.hpp"
|
||||||
#include "../GUIStuff/Elements/ImageDisplay.hpp"
|
#include "../GUIStuff/Elements/ImageDisplay.hpp"
|
||||||
|
|
@ -371,6 +372,10 @@ void FileSelectScreen::title_bar() {
|
||||||
fileViewType = FileViewType::SMALL_GRID;
|
fileViewType = FileViewType::SMALL_GRID;
|
||||||
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
||||||
});
|
});
|
||||||
|
text_transparent_option_button("List", "List", [&] {
|
||||||
|
fileViewType = FileViewType::LIST;
|
||||||
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, LayoutElement::Callbacks{
|
}, LayoutElement::Callbacks{
|
||||||
|
|
@ -441,43 +446,53 @@ void FileSelectScreen::file_view() {
|
||||||
auto& gui = main.g.gui;
|
auto& gui = main.g.gui;
|
||||||
std::filesystem::path folderPath = (selectedMenu == SelectedMenu::TRASH) ? trashPath : savePath;
|
std::filesystem::path folderPath = (selectedMenu == SelectedMenu::TRASH) ? trashPath : savePath;
|
||||||
|
|
||||||
Vector2f entrySize{0.0f, 0.0f};
|
auto fileButton = [&] (size_t i, bool isList, const Vector2f& iconSize) {
|
||||||
Vector2f iconSize{0.0f, 0.0f};
|
std::filesystem::path filePath = folderPath / (fileList[i].fileName + "." + World::FILE_EXTENSION);
|
||||||
switch(fileViewType) {
|
gui.element<SelectableButton>("file button", SelectableButton::Data{
|
||||||
case FileViewType::LARGE_GRID:
|
.isSelected = editMode && fileList[i].selected,
|
||||||
entrySize = {200.0f, 220.0f};
|
.onClick = [&, filePath, i] {
|
||||||
iconSize = {150.0f, 150.0f};
|
if(editMode)
|
||||||
break;
|
fileList[i].selected = !fileList[i].selected;
|
||||||
case FileViewType::MEDIUM_GRID:
|
else {
|
||||||
entrySize = {170.0f, 190.0f};
|
CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
|
||||||
iconSize = {120.0f, 120.0f};
|
.isClient = false,
|
||||||
break;
|
.filePathSource = filePath
|
||||||
case FileViewType::SMALL_GRID:
|
});
|
||||||
entrySize = {140.0f, 160.0f};
|
}
|
||||||
iconSize = {90.0f, 90.0f};
|
},
|
||||||
break;
|
.innerContent = [&](const SelectableButton::InnerContentCallbackParameters& c){
|
||||||
}
|
if(isList) {
|
||||||
|
CLAY_AUTO_ID({
|
||||||
gui.element<GridScrollArea>("File selector grid", GridScrollArea::Options{
|
.layout = {
|
||||||
.entryWidth = entrySize.x(),
|
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||||
.childAlignmentX = CLAY_ALIGN_X_LEFT,
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
||||||
.entryHeight = entrySize.y(),
|
.childGap = 6,
|
||||||
.entryCount = fileList.size(),
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
||||||
.elementContent = [&](size_t i) {
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||||
std::filesystem::path filePath = folderPath / (fileList[i].fileName + "." + World::FILE_EXTENSION);
|
}
|
||||||
gui.element<SelectableButton>("file button", SelectableButton::Data{
|
}) {
|
||||||
.isSelected = editMode && fileList[i].selected,
|
CLAY_AUTO_ID({
|
||||||
.onClick = [&, filePath, i] {
|
.layout = { .sizing = {.width = CLAY_SIZING_FIXED(iconSize.x()), .height = CLAY_SIZING_FIXED(iconSize.y()) }},
|
||||||
if(editMode)
|
}) {
|
||||||
fileList[i].selected = !fileList[i].selected;
|
gui.element<ImageDisplay>("ico", ImageDisplay::Data{
|
||||||
else {
|
.imgPath = folderPath / (fileList[i].fileName + ".jpg"),
|
||||||
CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
|
.radius = 20
|
||||||
.isClient = false,
|
});
|
||||||
.filePathSource = filePath
|
}
|
||||||
});
|
CLAY_AUTO_ID({
|
||||||
|
.layout = {
|
||||||
|
.sizing = { .width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
|
||||||
|
.childGap = 6,
|
||||||
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
||||||
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
text_label(gui, fileList[i].fileName);
|
||||||
|
text_label_light(gui, fileList[i].lastModifyDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
.innerContent = [&](const SelectableButton::InnerContentCallbackParameters& c){
|
else {
|
||||||
CLAY_AUTO_ID({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||||
|
|
@ -499,9 +514,49 @@ void FileSelectScreen::file_view() {
|
||||||
text_label_light(gui, fileList[i].lastModifyDate);
|
text_label_light(gui, fileList[i].lastModifyDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if(fileViewType == FileViewType::LIST) {
|
||||||
|
scroll_area_many_entries(gui, "File selector list", ScrollBarManyEntriesOptions{
|
||||||
|
.entryHeight = 150.0f,
|
||||||
|
.entryCount = fileList.size(),
|
||||||
|
.clipHorizontal = true,
|
||||||
|
.elementContent = [&](size_t i) {
|
||||||
|
fileButton(i, true, Vector2f{100.0f, 100.0f});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Vector2f entrySize{0.0f, 0.0f};
|
||||||
|
Vector2f iconSize{0.0f, 0.0f};
|
||||||
|
switch(fileViewType) {
|
||||||
|
case FileViewType::LARGE_GRID:
|
||||||
|
entrySize = {200.0f, 220.0f};
|
||||||
|
iconSize = {150.0f, 150.0f};
|
||||||
|
break;
|
||||||
|
case FileViewType::MEDIUM_GRID:
|
||||||
|
entrySize = {170.0f, 190.0f};
|
||||||
|
iconSize = {120.0f, 120.0f};
|
||||||
|
break;
|
||||||
|
case FileViewType::SMALL_GRID:
|
||||||
|
entrySize = {140.0f, 160.0f};
|
||||||
|
iconSize = {90.0f, 90.0f};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
gui.element<GridScrollArea>("File selector grid", GridScrollArea::Options{
|
||||||
|
.entryWidth = entrySize.x(),
|
||||||
|
.childAlignmentX = CLAY_ALIGN_X_LEFT,
|
||||||
|
.entryHeight = entrySize.y(),
|
||||||
|
.entryCount = fileList.size(),
|
||||||
|
.elementContent = [&](size_t i) {
|
||||||
|
fileButton(i, false, iconSize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSelectScreen::menu_black_box() {
|
void FileSelectScreen::menu_black_box() {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ class FileSelectScreen : public Screen {
|
||||||
enum class FileViewType {
|
enum class FileViewType {
|
||||||
LARGE_GRID,
|
LARGE_GRID,
|
||||||
MEDIUM_GRID,
|
MEDIUM_GRID,
|
||||||
SMALL_GRID
|
SMALL_GRID,
|
||||||
|
LIST
|
||||||
} fileViewType = FileViewType::LARGE_GRID;
|
} fileViewType = FileViewType::LARGE_GRID;
|
||||||
|
|
||||||
enum class MoreOptionsMenu {
|
enum class MoreOptionsMenu {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue