Fixed more issues with grid and scroll area
This commit is contained in:
parent
0853df4d2a
commit
4e1ab6fc50
6 changed files with 9 additions and 29 deletions
|
|
@ -125,7 +125,7 @@ void GUIHolder::draw(SkCanvas* canvas, bool skiaAA) {
|
|||
gui.io.redrawSurface = true;
|
||||
}
|
||||
|
||||
gui.draw_force(canvas, skiaAA);
|
||||
gui.draw(canvas, skiaAA);
|
||||
}
|
||||
|
||||
void GUIHolder::input_paste_callback(const CustomEvents::PasteEvent& paste) {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@ ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const Scro
|
|||
.innerContent = [&](const ScrollArea::InnerContentParameters& params) {
|
||||
if(options.innerContentExtraCallback) options.innerContentExtraCallback(params);
|
||||
|
||||
if(params.containerDimensions.y() == 0.0f)
|
||||
return;
|
||||
|
||||
float absScrollAmount = std::fabs(params.scrollOffset->y());
|
||||
size_t startPoint = absScrollAmount / options.entryHeight;
|
||||
size_t elementsContainable = (params.containerDimensions.y() / options.entryHeight) + 2; // Displaying 2 more elements ensures that there isn't any empty space in the container
|
||||
elementsContainable = std::min<size_t>(elementsContainable, 100);
|
||||
size_t endPoint = std::min(options.entryCount, startPoint + elementsContainable);
|
||||
|
||||
if(startPoint != 0) {
|
||||
|
|
@ -29,7 +31,7 @@ ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const Scro
|
|||
|
||||
gui.new_id("many element list", [&] {
|
||||
for(size_t i = startPoint; i < endPoint; i++) {
|
||||
gui.new_id(i, [&] {
|
||||
gui.new_id(i - startPoint, [&] {
|
||||
gui.element<LayoutElement>("elem", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||
CLAY(lId, {
|
||||
.layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(options.entryHeight)}}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void GridScrollArea::layout(const Clay_ElementId& id, const Options& o) {
|
|||
size_t startIndex = rowIndex * entriesPerRow;
|
||||
size_t endIndex = std::min(rowIndex * entriesPerRow + entriesPerRow, o.entryCount);
|
||||
for(size_t i = startIndex; i < endIndex; i++) {
|
||||
gui.new_id(static_cast<int64_t>(i), [&] {
|
||||
gui.new_id(static_cast<int64_t>(i - startIndex), [&] {
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {.sizing = {.width = CLAY_SIZING_FIXED(entryWidth), .height = CLAY_SIZING_FIXED(options.entryHeight)}}
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -72,10 +72,8 @@ void SelectableButton::input_mouse_button_callback(const InputManager::MouseButt
|
|||
bool oldIsHeld = isHeld;
|
||||
isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
if(isHeld) {
|
||||
if(instantResponse) {
|
||||
std::cout << "INSTANT" << std::endl;
|
||||
if(instantResponse)
|
||||
gui.set_post_callback_func(onClick);
|
||||
}
|
||||
gui.set_to_layout();
|
||||
}
|
||||
else if(mouseHovering && oldIsHeld && button.button == InputManager::MouseButton::LEFT && !button.down) {
|
||||
|
|
|
|||
|
|
@ -7,33 +7,21 @@
|
|||
#include <include/core/SkPath.h>
|
||||
#include <include/core/SkPathBuilder.h>
|
||||
#include "Elements/GUIStuffHelpers.hpp"
|
||||
#include "Elements/SVGIcon.hpp"
|
||||
#include "Elements/FontPicker.hpp"
|
||||
#include "Elements/SelectableButton.hpp"
|
||||
#include "Elements/RotateWheel.hpp"
|
||||
#include "Elements/TextParagraph.hpp"
|
||||
#include "Elements/MovableTabList.hpp"
|
||||
#include "Elements/Element.hpp"
|
||||
#include "Elements/TextParagraph.hpp"
|
||||
#include <Helpers/ConvertVec.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <Helpers/Logger.hpp>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <modules/skparagraph/src/ParagraphBuilderImpl.h>
|
||||
#include <modules/skparagraph/include/ParagraphStyle.h>
|
||||
#include <modules/skparagraph/include/FontCollection.h>
|
||||
#include <modules/skparagraph/include/TextStyle.h>
|
||||
#include <modules/skunicode/include/SkUnicode_icu.h>
|
||||
#include "../FontData.hpp"
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
GUIManager::GUIManager()
|
||||
{
|
||||
Clay_SetMaxMeasureTextCacheWordCount(100000);
|
||||
Clay_SetMaxElementCount(32768);
|
||||
clayArena = Clay_CreateArenaWithCapacityAndMemory(Clay_MinMemorySize(), malloc(Clay_MinMemorySize()));
|
||||
clayInstance = Clay_Initialize(clayArena, Clay_Dimensions(1.0f, 1.0f), (Clay_ErrorHandler)clay_error_handler);
|
||||
Clay_SetMeasureTextFunction(clay_skia_measure_text, this);
|
||||
|
|
|
|||
|
|
@ -23,19 +23,11 @@ void FileSelectScreen::gui_layout_run() {
|
|||
},
|
||||
}) {
|
||||
text_label(gui, "Test grid");
|
||||
//scroll_area_many_entries(gui, "Test scroll", ScrollBarManyEntriesOptions{
|
||||
// .entryHeight = 100.0f,
|
||||
// .entryCount = 2000,
|
||||
// .clipHorizontal = true,
|
||||
// .elementContent = [&] (size_t i) {
|
||||
// text_button_sized(gui, "button", "Square " + std::to_string(i), CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0));
|
||||
// }
|
||||
//});
|
||||
gui.element<GridScrollArea>("Test grid", GridScrollArea::Options{
|
||||
.entryMaximumWidth = 100.0f,
|
||||
.childAlignmentX = CLAY_ALIGN_X_LEFT,
|
||||
.entryHeight = 100.0f,
|
||||
.entryCount = 200,
|
||||
.entryCount = 20000,
|
||||
.elementContent = [&](size_t i) {
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue