Widgets Additions and sketch3d new gui

This commit is contained in:
IlyaShurupov 2024-10-20 12:01:42 +03:00 committed by Ilya Shurupov
parent afad2c80e5
commit e10a494223
44 changed files with 1015 additions and 322 deletions

View file

@ -61,6 +61,8 @@ void DockLayout::toggleWidgetVisibility(Side side) {
void DockLayout::calculateSideAreas() {
auto startArea = getArea().relative();
if (startArea.size.x <= 0 || startArea.size.y <= 0) return;
for (auto& sideWidget : mSideWidgets) {
const auto side = sideWidget.order;
@ -99,11 +101,13 @@ void DockLayout::calculateResizeHandles() {
RectF area = getArea().relative();
for (auto& sideWidget : mSideWidgets) {
if (!sideWidget.widget) continue;
auto& sideSize = sideWidget.absoluteSize;
auto& resizeHandle = sideWidget.resizeHandle;
if (resizeHandle.end < mSideSizePadding * 2) {
sideSize = resizeHandle.end / 2.f;
// sideSize = resizeHandle.end / 2.f;
} else {
sideSize = clamp(sideSize, resizeHandle.start + mSideSizePadding, resizeHandle.end - mSideSizePadding);
}

View file

@ -1,29 +0,0 @@
#include "OverlayLayout.hpp"
#include "Widget.hpp"
using namespace tp;
void OverlayLayout::updateLayout(bool vertical) {
if (vertical) return;
if (children().empty()) return;
for (auto child : children()) {
child->getLayout()->setArea(getArea().relative());
}
/*
if (children().empty()) return;
auto first = children().front();
first->getLayout()->setArea(getArea().relative());
for (auto child : children()) {
if (child == first) continue;
child->getLayout()->setArea(getArea().relative());
}
*/
}

View file

@ -30,9 +30,9 @@ void ScrollableLayout::updateWidgetRects(const RectF& area, Widget* content, Scr
auto sizeFactor = (area.size[dir] / content->getLayout()->getArea().size[dir]);
auto splitFactor = 1 - ((sizeFactor > 1.f) ? 0 : mScrollerSize / area.size[!dir]);
auto holderArea = area.splitByFactorHL(splitFactor);
auto holderArea = dir ? area.splitByFactorHL(splitFactor) : area.splitByFactorVT(splitFactor);
auto contentArea = content->getLayout()->getArea();
auto scrollerArea = area.splitByFactorHR(splitFactor);
auto scrollerArea = dir ? area.splitByFactorHR(splitFactor) : area.splitByFactorVB(splitFactor);
scroller->updateSizeFactor(sizeFactor);

View file

@ -0,0 +1,32 @@
#include "SimpleLayouts.hpp"
#include "Widget.hpp"
using namespace tp;
void OverlayLayout::updateLayout(bool vertical) {
if (vertical) return;
if (children().empty()) return;
for (auto child : children()) {
child->getLayout()->setArea(getArea().relative());
}
}
void ToolBarLayout::updateLayout(bool vertical) {
if (vertical) return;
if (children().size() != 2) return;
auto toolbar = children().back();
auto content = children().front();
auto factor = mToolBarHeight / getArea().w;
auto area = getArea().relative();
toolbar->getLayout()->setArea(area.splitByFactorVT(factor));
content->getLayout()->setArea(area);
}