Skip to content

Commit

Permalink
moveToWindowTopLeft is modified to take into account the case when th…
Browse files Browse the repository at this point in the history
…e starting point of bounds is nonzero.
  • Loading branch information
szn409 committed Jun 18, 2024
1 parent fea08a5 commit 9aac3ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/Application/AttrBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ class TransformHelper
const TDesignMatrix& desMatrix);

// Note: When the matrix of the top-level frame is [1, 0, 0, 1, 0, 0], it is positioned at the top
// left corner of the window.
// left corner of the window. boundOriginX and boundOriginY based on the design coordinate system.
static TDesignMatrix moveToWindowTopLeft(
double boundOriginX,
double boundOriginY,
double width,
double height,
const TDesignMatrix& matrix);
Expand Down
8 changes: 7 additions & 1 deletion src/Application/AttrBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,12 +946,18 @@ TDesignMatrix TransformHelper::transform(
}

TDesignMatrix TransformHelper::moveToWindowTopLeft(
double boundOriginX,
double boundOriginY,
double width,
double height,
const TDesignMatrix& matrix)
{
auto result = TransformHelper::getLTRB(width, height, matrix);
return TransformHelper::translate(-result[0], -result[1], matrix);
return TransformHelper::translate(
-(result[0] + boundOriginX),
-(result[1] + boundOriginY),
matrix);
// return TransformHelper::translate(-result[0], -result[1], matrix);
}

TDesignMatrix TransformHelper::translate(double x, double y, const TDesignMatrix& matrix)
Expand Down
8 changes: 7 additions & 1 deletion src/Application/UIViewImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,14 @@ void UIViewImpl::moveFramesToTopLeft()

if (auto maybeMatrix = layerBridge->getMatrix(paintNode))
{
auto origin = frame->bounds().origin;
auto size = frame->bounds().size;
auto newMatrix = TransformHelper::moveToWindowTopLeft(size.width, size.height, *maybeMatrix);
auto newMatrix = TransformHelper::moveToWindowTopLeft(
origin.x,
-origin.y,
size.width,
size.height,
*maybeMatrix);
layerBridge->updateMatrix(frame, paintNode, newMatrix, false);
}
}
Expand Down

0 comments on commit 9aac3ff

Please sign in to comment.