Backup
This commit is contained in:
parent
d2f722247e
commit
fd8a39903a
@ -135,7 +135,7 @@ class Thread
|
||||
$w =0;$h = 0;
|
||||
\SDL_GetTextureSize($item->texture, $w, $h);
|
||||
$clip = clone $item->renderAt;
|
||||
echo sprintf("Texture W: %d H: %d%s V-W: %d V-H: %d V-X: %d V-Y: %d%s R-AT-X: %d R-AT-Y: %d R-AT-W: %d R-AT-H: %d%s CLIP AT H %d Y %d", $w, $h, PHP_EOL, $width, $height, $x, $y, PHP_EOL, $item->renderAt->x, $item->renderAt->y, $item->renderAt->w, $item->renderAt->h, PHP_EOL, $height-$item->renderAt->y, $item->renderAt->y + $y).PHP_EOL;
|
||||
//echo sprintf("Texture W: %d H: %d%s V-W: %d V-H: %d V-X: %d V-Y: %d%s R-AT-X: %d R-AT-Y: %d R-AT-W: %d R-AT-H: %d%s CLIP AT H %d Y %d", $w, $h, PHP_EOL, $width, $height, $x, $y, PHP_EOL, $item->renderAt->x, $item->renderAt->y, $item->renderAt->w, $item->renderAt->h, PHP_EOL, $height-$item->renderAt->y, $item->renderAt->y + $y).PHP_EOL;
|
||||
if($height) {
|
||||
$clip->x = 0;
|
||||
$clip->y = $y;
|
||||
@ -156,7 +156,7 @@ class Thread
|
||||
\SDL_GetTextureSize($item->texture, $w, $h);
|
||||
$clip = clone $item->renderAt;
|
||||
$height = $item->renderAt->h;
|
||||
echo sprintf("Texture W: %d H: %d%s V-X: %d%s R-AT-X: %d R-AT-Y: %d R-AT-W: %d R-AT-H: %d%s CLIP AT H %d Y %d", $w, $h, PHP_EOL, $y, PHP_EOL, $item->renderAt->x, $item->renderAt->y, $item->renderAt->w, $item->renderAt->h, PHP_EOL, $height-($y-$item->renderAt->y), $item->renderAt->y + $y).PHP_EOL;
|
||||
//echo sprintf("Texture W: %d H: %d%s V-X: %d%s R-AT-X: %d R-AT-Y: %d R-AT-W: %d R-AT-H: %d%s CLIP AT H %d Y %d", $w, $h, PHP_EOL, $y, PHP_EOL, $item->renderAt->x, $item->renderAt->y, $item->renderAt->w, $item->renderAt->h, PHP_EOL, $height-($y-$item->renderAt->y), $item->renderAt->y + $y).PHP_EOL;
|
||||
if($y && $y > $item->renderAt->y) {
|
||||
$clip->x = 0;
|
||||
$clip->y = $y-$item->renderAt->y;
|
||||
|
||||
@ -33,9 +33,7 @@ class Container
|
||||
$viewport->height -= ($m->bottom + $m->top);
|
||||
}
|
||||
|
||||
|
||||
\PHPNative\Renderer\Visuals\Visuals::render($view->getId(), $thread, $styles, $viewport, $index);
|
||||
\PHPNative\Renderer\Visuals\Visuals::changeViewport($view->getId(), $thread, $styles, $viewport);
|
||||
$backgroundViewport = clone $viewport;
|
||||
|
||||
if(isset($styles[Padding::class]) && $m = $styles[Padding::class]) {
|
||||
$viewport->x += $m->left;
|
||||
@ -63,16 +61,16 @@ class Container
|
||||
$view->onClick($thread->worker);
|
||||
}
|
||||
}
|
||||
|
||||
$resultViewPort = null;
|
||||
if($view->getViews() != null) {
|
||||
$view = LayoutParser::sortByStyles($stylesCache, $view, $viewport);
|
||||
if (isset($styles[Flex::class]) && $styles[Flex::class]->direction == DirectionEnum::column) {
|
||||
$resultViewPort = Column::render($stylesCache, $thread, clone $viewport, $view, $index);
|
||||
$resultViewPort = Column::render($stylesCache, $thread, clone $viewport, $view, $index+1);
|
||||
|
||||
if (isset($styles[Overflow::class]) && $f = $styles[Overflow::class] && (
|
||||
$styles[Overflow::class]->y == OverflowEnum::scroll ||
|
||||
($styles[Overflow::class]->y == OverflowEnum::auto && $viewport->height < $resultViewPort->height)
|
||||
)) {
|
||||
) && $resultViewPort->height > 0) {
|
||||
|
||||
\PHPNative\Renderer\Visuals\Scrollbar::renderBackground($view->getId(), $thread, $styles, $viewport);
|
||||
|
||||
@ -106,9 +104,8 @@ class Container
|
||||
$view->setMoveToY($view->getMoveEndY() + $thread->getEvent()->y - $view->getMoveStartY());
|
||||
|
||||
}
|
||||
echo sprintf("COL: %s %d %d %d", $view->getId(), $view->getMoveToY(), $resultViewPort->height, $viewport->height).PHP_EOL;
|
||||
|
||||
if($view->getMoveToY() + ($viewport->height) > ($resultViewPort->height)) {
|
||||
echo sprintf("TOP: %s %d %d %d", $view->getId(), $view->getMoveToY(), $resultViewPort->height, $viewport->height).PHP_EOL;
|
||||
//$view->setMoveToX($view->getMoveEndX() + $thread->getEvent()->x - $view->getMoveStartX());
|
||||
$view->setMoveToY($resultViewPort->height - $viewport->height );
|
||||
}
|
||||
@ -121,214 +118,29 @@ class Container
|
||||
|
||||
}
|
||||
}
|
||||
if (isset($styles[Flex::class]) && $styles[Flex::class]->direction == DirectionEnum::row) {
|
||||
$resultViewPort = Row::render($stylesCache, $thread, clone $viewport, $view, $index);
|
||||
if (!isset($styles[Flex::class]) || (isset($styles[Flex::class]) && $styles[Flex::class]->direction == DirectionEnum::row)) {
|
||||
$resultViewPort = Row::render($stylesCache, $thread, clone $viewport, $view, $index+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if($view->getViews() != null) {
|
||||
|
||||
$viewportWidth = $viewport->width;
|
||||
$viewportHeight = $viewport->height;
|
||||
$width = $viewport->width;
|
||||
$height = $viewport->height;
|
||||
$viewPortY = $viewport->y;
|
||||
foreach ($view->getViews() as $subView) {
|
||||
$found = false;
|
||||
$stylesSubView = $stylesCache->getStyle($subView->getId(), $viewport->windowMediaQuery, $subView->state, $subView->style);
|
||||
if (isset($stylesSubView[Basis::class]) && $b = $stylesSubView[Basis::class]) {
|
||||
if ($b->unit == Unit::Percent) {
|
||||
$width = round($viewportWidth / 100 * $b->value);
|
||||
} else {
|
||||
$width = $b->value;
|
||||
$viewportWidth -= $b->value;
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
if (isset($stylesSubView[Width::class]) && $w = $stylesSubView[Width::class]) {
|
||||
if ($w->unit == Unit::Percent) {
|
||||
$width = round($viewportWidth / 100 * $w->value);
|
||||
} else {
|
||||
$width = $w->value;
|
||||
$viewportWidth -= $w->value;
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
if (isset($stylesSubView[Height::class]) && $h = $stylesSubView[Height::class]) {
|
||||
if ($h->unit == Unit::Percent) {
|
||||
$height = round($viewportHeight / 100 * $h->value);
|
||||
} else {
|
||||
$height = $h->value;
|
||||
$viewportHeight -= $h->value;
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
if (isset($styles[Flex::class]) && $styles[Flex::class]->direction == DirectionEnum::column &&
|
||||
isset($stylesSubView[Flex::class]) && $stylesSubView[Flex::class]->type == FlexTypeEnum::one
|
||||
) {
|
||||
$height = round($viewportHeight / $view->getViews()->countOne);
|
||||
$found = true;
|
||||
}
|
||||
if (isset($styles[Flex::class]) && $styles[Flex::class]->direction == DirectionEnum::row &&
|
||||
isset($stylesSubView[Flex::class]) && $stylesSubView[Flex::class]->type == FlexTypeEnum::one
|
||||
) {
|
||||
$width = round($viewportWidth / $view->getViews()->countOne);
|
||||
$found = true;
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
$viepo = new Viewport($viewport->windowId, $viewport->windowPtr, $viewport->renderPtr, $viewport->x, $viewport->y, $width, $height, $viewport->windowWidth, $viewport->windowHeight, $viewport->windowMediaQuery);
|
||||
$flexStyles[$subView->getRenderSort()] = $viepo;
|
||||
} else {
|
||||
$flexStyles[$subView->getRenderSort()] = clone $viewport;
|
||||
}
|
||||
}
|
||||
|
||||
LayoutParser::sortByRenderSort($view);
|
||||
$topHeight = 0;
|
||||
foreach ($view->getViews() as $subView) {
|
||||
$stylesSubView = $stylesCache->getStyle($subView->getId(), $viewport->windowMediaQuery, $subView->state, $subView->style);
|
||||
if (isset($styles[Flex::class]) && $f = $styles[Flex::class] && $styles[Flex::class]->direction == DirectionEnum::column) {
|
||||
$subViewPort = $flexStyles[$subView->getRenderSort()];
|
||||
$subViewPort->y = $viewport->y - $view->getMoveToY();
|
||||
if($viewport->height < $subViewPort->height) {
|
||||
$subViewPort->height = $viewport->height;
|
||||
}
|
||||
$vp = Widget::render($stylesCache, $thread, clone $subViewPort, $subView, $index+1);
|
||||
echo sprintf('RENDER: %s SV-X %d SV-Y %d SV-W %d SV-H %d%sVP-Y %d VP-H %d ViewportY %d ViewportHeight %d', $subView->getId(), $subViewPort->x, $subViewPort->y, $subViewPort->width, $subViewPort->height, PHP_EOL, $vp->y, $vp->height, $viewPortY, $viewportHeight).PHP_EOL;
|
||||
if((($vp->y + $vp->height) < $viewPortY) &&
|
||||
|
||||
!isset($stylesSubView[Overflow::class])) {
|
||||
echo sprintf('REMOVE: %s V-Y: %d V-H: %d S-Y: %d S-H: %d VP-Y: %d VP-H: %d', $subView->getId(), $viewport->y, $viewport->height, $subViewPort->y, $subViewPort->height, $vp->y, $vp->height).PHP_EOL;
|
||||
$thread->removeFromStack($subView->getId());
|
||||
}
|
||||
if(
|
||||
($vp->y <= ($viewport->y + $viewport->height) && $vp->height > $viewport->height)
|
||||
) {
|
||||
echo sprintf('CLIP-B: %s V-Y: %d V-H: %d S-Y: %d S-H: %d VP-Y: %d VP-H: %d', $subView->getId(), $viewport->y, $viewport->height, $subViewPort->y, $subViewPort->height, $vp->y, $vp->height).PHP_EOL;
|
||||
$thread->clipFromStackB($subView->getId(), y: 0, height: ($viewport->y+$viewport->height));
|
||||
}
|
||||
if( ($vp->y + $vp->height >= $viewPortY) && $subViewPort->y < $viewPortY) {
|
||||
echo sprintf('CLIP-T: %s V-Y: %d V-H: %d S-Y: %d S-H: %d VP-Y: %d VP-H: %d', $subView->getId(), $viewport->y, $viewport->height, $subViewPort->y, $subViewPort->height, $vp->y, $vp->height).PHP_EOL;
|
||||
$thread->clipFromStackT($subView->getId(), y: $viewPortY);
|
||||
}
|
||||
|
||||
if(!isset($stylesSubView[Flex::class])) {
|
||||
$viewport->y += $vp->height;
|
||||
$viewport->height -= $vp->height;
|
||||
}else{
|
||||
$viewport->y += $subViewPort->height;
|
||||
$viewport->height -= $subViewPort->height;
|
||||
}
|
||||
|
||||
|
||||
} elseif(isset($styles[Flex::class]) && $f = $styles[Flex::class] && $styles[Flex::class]->direction == DirectionEnum::row) {
|
||||
$subViewPort = $flexStyles[$subView->getRenderSort()];
|
||||
$subViewPort->x = $viewport->x - $view->getMoveToX();
|
||||
$vp = Widget::render($stylesCache, $thread, clone $subViewPort, $subView, $index+1);
|
||||
if(!isset($stylesSubView[Flex::class])) {
|
||||
$viewport->x += $vp->width;
|
||||
}else{
|
||||
$viewport->x += $subViewPort->width;
|
||||
}
|
||||
$topHeight = max($topHeight, $vp->height);
|
||||
// $viewport->width -= $vp->width;
|
||||
} else{
|
||||
$sfs = $flexStyles[$subView->getRenderSort()];
|
||||
$vp = Widget::render($stylesCache, $thread, $sfs, $subView, $index+1);
|
||||
$topHeight = max($topHeight, $vp->height);
|
||||
if(count($flexStyles) > 0) {
|
||||
if($vp->addX > 0) {
|
||||
$flexStyles[0]->x += $vp->addX;
|
||||
$flexStyles[0]->width -= $vp->addX;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($styles[Flex::class]) && $f = $styles[Flex::class] && $styles[Flex::class]->direction == DirectionEnum::column) {
|
||||
|
||||
} else {
|
||||
$targetViewport->height = $topHeight;
|
||||
$viewport->y += $topHeight;
|
||||
$viewport->height = $topHeight;
|
||||
if(isset($styles[Padding::class]) && $m = $styles[Padding::class]) {
|
||||
$targetViewport->height += ($m->bottom + $m->top);
|
||||
$viewport->height += ($m->bottom + $m->top);
|
||||
}
|
||||
if($resultViewPort != null) {
|
||||
if (isset($styles[Overflow::class]) && $f = $styles[Overflow::class] && (
|
||||
$styles[Overflow::class]->y == OverflowEnum::scroll ||
|
||||
($styles[Overflow::class]->y == OverflowEnum::auto && $viewport->height < $resultViewPort->height)
|
||||
)) {
|
||||
\PHPNative\Renderer\Visuals\Visuals::render($view->getId(), $thread, $styles, $backgroundViewport, $index);
|
||||
}else{
|
||||
if(isset($styles[Margin::class]) && $m = $styles[Margin::class]) {
|
||||
$viewport->height += ($m->bottom + $m->top);
|
||||
$resultViewPort->x -= $m->left;
|
||||
$resultViewPort->width += ($m->right + $m->left);
|
||||
$resultViewPort->y -= $m->top;
|
||||
$resultViewPort->height += ($m->bottom + $m->top);
|
||||
}
|
||||
\PHPNative\Renderer\Visuals\Visuals::render($view->getId(), $thread, $styles, $resultViewPort, $index);
|
||||
}
|
||||
|
||||
if($thread->getEvent() && $thread->getEvent()->getType() === EventType::MOUSEMOVE) {
|
||||
if( $targetViewport->x <= $thread->getEvent()->x &&
|
||||
$thread->getEvent()->x <= $targetViewport->x + $targetViewport->width &&
|
||||
$targetViewport->y <= $thread->getEvent()->y &&
|
||||
$thread->getEvent()->y <= $targetViewport->y + $targetViewport->height ) {
|
||||
$view->state = StateEnum::hover;
|
||||
}else{
|
||||
$view->state = StateEnum::normal;
|
||||
}
|
||||
}
|
||||
|
||||
if($view instanceof \PHPNative\UI\Widget\Button && $thread->getEvent() && $thread->getEvent()->getType() === EventType::MOUSEBUTTON_UP) {
|
||||
if( $targetViewport->x <= $thread->getEvent()->x &&
|
||||
$thread->getEvent()->x <= $targetViewport->x + $targetViewport->width &&
|
||||
$targetViewport->y <= $thread->getEvent()->y && $thread->getEvent()->y <=
|
||||
$targetViewport->y + $targetViewport->height ) {
|
||||
$view->onClick($thread->worker);
|
||||
}
|
||||
}
|
||||
|
||||
if($view->getViews() != null) {
|
||||
|
||||
/*
|
||||
* if ($thread->getEvent() && $thread->getEvent()->getType() === EventType::MOUSEBUTTON_DOWN) {
|
||||
if ($viewport->x + $targetViewport->width - 10 <= $thread->getEvent()->x &&
|
||||
$thread->getEvent()->x <= $targetViewport->x + $targetViewport->width &&
|
||||
$targetViewport->y <= $thread->getEvent()->y &&
|
||||
$thread->getEvent()->y <= $targetViewport->y + $targetViewport->height) {
|
||||
$view->setDragMode(true);
|
||||
$view->setMoveStartX($thread->getEvent()->x);
|
||||
$view->setMoveStartY($thread->getEvent()->y);
|
||||
}
|
||||
}
|
||||
if ($view->isDragMode() && $thread->getEvent() && $thread->getEvent()->getType() === EventType::MOUSEMOVE) {
|
||||
$view->setMoveToX($view->getMoveEndX() + $thread->getEvent()->x - $view->getMoveStartX());
|
||||
$view->setMoveToY($view->getMoveEndY() + $thread->getEvent()->y - $view->getMoveStartY());
|
||||
|
||||
if($view->getMoveToY() <= 0) {
|
||||
$view->setMoveStartY($thread->getEvent()->y);
|
||||
$view->setMoveToX($view->getMoveEndX() + $thread->getEvent()->x - $view->getMoveStartX());
|
||||
$view->setMoveToY($view->getMoveEndY() + $thread->getEvent()->y - $view->getMoveStartY());
|
||||
|
||||
}
|
||||
|
||||
if($view->getMoveToY() > ($viewport->height*-1)) {
|
||||
$view->setMoveToX($view->getMoveEndX() + $thread->getEvent()->x - $view->getMoveStartX());
|
||||
$view->setMoveToY($viewport->height*-1);
|
||||
}
|
||||
}
|
||||
if ($thread->getEvent() && $thread->getEvent()->getType() === EventType::MOUSEBUTTON_UP) {
|
||||
$view->setDragMode(false);
|
||||
$view->setMoveEndX($view->getMoveToX());
|
||||
$view->setMoveEndY($view->getMoveToY());
|
||||
}
|
||||
$sliderViewport = clone $targetViewport;
|
||||
$sliderViewport->width = 10;
|
||||
$sliderViewport->x = $targetViewport->x + $width - 10;
|
||||
$ohP = ($targetViewport->height / 100);
|
||||
$ratio = ($targetViewport->height / ($viewport->height*-1+$targetViewport->height));
|
||||
$sliderViewport->y = $targetViewport->y + (int)($view->getMoveToY()*$ratio);
|
||||
$sliderViewport->height = (int)($ratio*100 * $ohP);
|
||||
|
||||
\PHPNative\Renderer\Visuals\Scrollbar::renderSlider($view->getId(), $thread, $styles, $sliderViewport, $index);
|
||||
}
|
||||
}*/
|
||||
|
||||
}else{
|
||||
\PHPNative\Renderer\Visuals\Visuals::render($view->getId(), $thread, $styles, $viewport, $index);
|
||||
}
|
||||
|
||||
return $myViewport;
|
||||
}
|
||||
|
||||
@ -63,6 +63,19 @@ class Column
|
||||
$vp = Widget::render($stylesCache, $thread, clone $subViewPort, $subView, $index+1);
|
||||
$viewportY += $vp->height;
|
||||
$viewportHeight -= $vp->height;
|
||||
if(((($vp->y + $vp->height) <= $viewport->y) ||
|
||||
($vp->y >= $viewport->y + $viewport->height)) &&
|
||||
isset($styles[Overflow::class])) {
|
||||
$thread->removeFromStack($subView->getId());
|
||||
}
|
||||
if(
|
||||
($vp->y < ($viewport->y + $viewport->height) && $vp->y + $vp->height > $viewport->y + $viewport->height)
|
||||
) {
|
||||
$thread->clipFromStackB($subView->getId(), y: 0, height: ($viewport->y+$viewport->height));
|
||||
}
|
||||
if( ($vp->y + $vp->height) > $viewport->y && $vp->y < $viewport->y) {
|
||||
$thread->clipFromStackT($subView->getId(), y: $viewport->y);
|
||||
}
|
||||
}
|
||||
|
||||
$viewport->height = $viewportY;
|
||||
|
||||
@ -21,6 +21,7 @@ class Row
|
||||
{
|
||||
$flexStyles = [];
|
||||
$viewportWidth = $viewport->width;
|
||||
$viewportHeight = 0;
|
||||
foreach($view->getViews() as $subView) {
|
||||
$found = false;
|
||||
$stylesSubView = $stylesCache->getStyle($subView->getId(), $viewport->windowMediaQuery, $subView->state, $subView->style);
|
||||
@ -35,6 +36,7 @@ class Row
|
||||
}
|
||||
if (isset($stylesSubView[Flex::class]) && $stylesSubView[Flex::class]->type == FlexTypeEnum::one
|
||||
) {
|
||||
//echo $subView->getId().PHP_EOL;
|
||||
$width = round($viewportWidth / $view->getViews()->countOne);
|
||||
$found = true;
|
||||
}
|
||||
@ -53,8 +55,11 @@ class Row
|
||||
$subViewPort->x += $viewportX;
|
||||
$vp = Widget::render($stylesCache, $thread, clone $subViewPort, $subView, $index+1);
|
||||
$viewportX += $vp->width;
|
||||
$viewportHeight = $vp->height > $viewportHeight ? $vp->height : $viewportHeight;
|
||||
}
|
||||
|
||||
$viewport->height = $viewportHeight;
|
||||
|
||||
return $viewport;
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,7 @@ class Button extends Container implements View
|
||||
|
||||
public function __construct(public ?Views $views = null, string $style = "")
|
||||
{
|
||||
parent::__construct($style);
|
||||
parent::__construct(style: $style, views: $views);
|
||||
}
|
||||
|
||||
public function getViews(): ?\PHPNative\UI\Collection\Views
|
||||
|
||||
Loading…
Reference in New Issue
Block a user