Fixed many element scroll area and added color palette picker
This commit is contained in:
parent
c90c09b169
commit
c1cd3e4e49
14 changed files with 156 additions and 124 deletions
|
|
@ -3,9 +3,9 @@
|
|||
#include "../GUIHolder.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/ScrollAreaHelpers.hpp"
|
||||
#include "Helpers/ConvertVec.hpp"
|
||||
#include "../GUIStuff/Elements/GridScrollArea.hpp"
|
||||
#include "../GUIStuff/Elements/ManyElementScrollArea.hpp"
|
||||
#include "../GUIStuff/Elements/ImageDisplay.hpp"
|
||||
#include "../GUIStuff/Elements/LayoutElement.hpp"
|
||||
#include "../GUIStuff/Elements/SVGIcon.hpp"
|
||||
|
|
@ -683,7 +683,7 @@ void FileSelectScreen::file_view() {
|
|||
};
|
||||
|
||||
if(fileViewType == FileViewType::LIST) {
|
||||
fileViewScrollArea = scroll_area_many_entries(gui, "File selector list", ScrollBarManyEntriesOptions{
|
||||
fileViewScrollArea = gui.element<ManyElementScrollArea>("File selector list", ManyElementScrollArea::Options{
|
||||
.entryHeight = 150.0f,
|
||||
.entryCount = fileList.size(),
|
||||
.clipHorizontal = true,
|
||||
|
|
@ -691,7 +691,7 @@ void FileSelectScreen::file_view() {
|
|||
.elementContent = [&](size_t i) {
|
||||
fileButton(i, true, Vector2f{100.0f, 100.0f});
|
||||
}
|
||||
});
|
||||
})->scrollArea;
|
||||
}
|
||||
else {
|
||||
Vector2f entrySize{0.0f, 0.0f};
|
||||
|
|
@ -712,7 +712,7 @@ void FileSelectScreen::file_view() {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
GridScrollArea* gridArea = gui.element<GridScrollArea>("File selector grid", GridScrollArea::Options{
|
||||
fileViewScrollArea = gui.element<GridScrollArea>("File selector grid", GridScrollArea::Options{
|
||||
.entryWidth = entrySize.x(),
|
||||
.childAlignmentX = CLAY_ALIGN_X_LEFT,
|
||||
.entryHeight = entrySize.y(),
|
||||
|
|
@ -721,8 +721,7 @@ void FileSelectScreen::file_view() {
|
|||
.elementContent = [&](size_t i) {
|
||||
fileButton(i, false, iconSize);
|
||||
}
|
||||
});
|
||||
fileViewScrollArea = gridArea->scrollArea;
|
||||
})->scrollArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "../MainProgram.hpp"
|
||||
#include "DrawingProgramScreen.hpp"
|
||||
#include "Helpers/ConvertVec.hpp"
|
||||
#include "../GUIStuff/Elements/GridScrollArea.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/LayoutHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
||||
|
|
@ -116,8 +117,10 @@ void PhoneDrawingProgramScreen::bottom_toolbar() {
|
|||
tool_settings_popup();
|
||||
break;
|
||||
case SettingsMenuPopup::FG_COLOR:
|
||||
color_settings_popup(&main.toolConfig.globalConf.foregroundColor);
|
||||
break;
|
||||
case SettingsMenuPopup::BG_COLOR:
|
||||
color_settings_popup(&main.toolConfig.globalConf.backgroundColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -198,10 +201,10 @@ void PhoneDrawingProgramScreen::bottom_toolbar_gui() {
|
|||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::tool_settings_popup() {
|
||||
GUIManager& gui = main.g.gui;
|
||||
auto& drawP = main.world->drawProg;
|
||||
auto& gui = main.g.gui;
|
||||
auto& io = gui.io;
|
||||
|
||||
|
||||
gui.element<LayoutElement>("tool settings popup", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||
CLAY(lId, {
|
||||
.layout = {
|
||||
|
|
@ -231,6 +234,40 @@ void PhoneDrawingProgramScreen::tool_settings_popup() {
|
|||
});
|
||||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::color_settings_popup(Vector4f* color) {
|
||||
auto& gui = main.g.gui;
|
||||
auto& palette = main.conf.palettes[paletteData.selectedPalette];
|
||||
gui.element<LayoutElement>("color settings popup", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||
CLAY(lId, {
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(gui.io.theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1)
|
||||
}) {
|
||||
gui.element<GridScrollArea>("color selector grid", GridScrollArea::Options{
|
||||
.entryWidth = BIG_BUTTON_SIZE,
|
||||
.childAlignmentX = CLAY_ALIGN_X_CENTER,
|
||||
.entryHeight = BIG_BUTTON_SIZE,
|
||||
.entryCount = palette.colors.size(),
|
||||
.elementContent = [&](size_t i) {
|
||||
auto newC = std::make_shared<Vector3f>(palette.colors[i].x(), palette.colors[i].y(), palette.colors[i].z());
|
||||
color_button(gui, "c", newC.get(), {
|
||||
.isSelected = newC->x() == color->x() && newC->y() == color->y() && newC->z() == color->z(),
|
||||
.hasAlpha = false,
|
||||
.onClick = [newC, color] {
|
||||
// We want to keep the old color's alpha
|
||||
color->x() = newC->x();
|
||||
color->y() = newC->y();
|
||||
color->z() = newC->z();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::bottom_extra_toolbar_gui() {
|
||||
GUIManager& gui = main.g.gui;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,16 @@ class PhoneDrawingProgramScreen : public DrawingProgramScreen {
|
|||
void bottom_toolbar();
|
||||
void main_display();
|
||||
void tool_settings_popup();
|
||||
void color_settings_popup(Vector4f* color);
|
||||
enum class SettingsMenuPopup {
|
||||
NONE,
|
||||
SETTINGS,
|
||||
FG_COLOR,
|
||||
BG_COLOR
|
||||
} settingsMenuPopup = SettingsMenuPopup::NONE;
|
||||
struct PaletteData {
|
||||
size_t selectedPalette = 0;
|
||||
bool addingPalette = false;
|
||||
std::string newPaletteStr;
|
||||
} paletteData;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue