added partial mouse events for Windows, implemented clipping rect intersection, added auto value to width and height attributes
This commit is contained in:
@@ -1,45 +1,43 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<layout>
|
<layout>
|
||||||
<flex dir="col" wrap="0" width="100%" height="100%" pad="10">
|
<flex dir="col" wrap="0" width="100%" height="100%" pad="5">
|
||||||
<!-- toolbar -->
|
<!-- toolbar -->
|
||||||
<plane height="50" width="100%" pad="5" dir="row" color=".2">
|
<plane height="50" width="100%" pad="5" dir="row" color=".2">
|
||||||
<plane width="50" margin="0 5 0 0" color=".1"></plane>
|
<plane width="50" margin="0 5 0 0" color=".1"></plane>
|
||||||
<plane width="50" margin="0 5 0 0" color=".2"></plane>
|
<plane width="50" margin="0 5 0 0" color=".2"></plane>
|
||||||
<plane width="50" margin="0 5 0 0" color=".3"></plane>
|
<plane width="50" margin="0 5 0 0" color=".3"></plane>
|
||||||
<separator width="10" />
|
<separator width="10" />
|
||||||
<plane width="50" margin="0 5 0 0" color=".1"></plane>
|
<plane width="50" margin="0 5 0 0" color=".1"></plane>
|
||||||
<plane width="50" margin="0 5 0 0" color=".2"></plane>
|
<plane width="50" margin="0 5 0 0" color=".2"></plane>
|
||||||
<plane width="50" margin="0 5 0 0" color=".3"></plane>
|
<plane width="50" margin="0 5 0 0" color=".3"></plane>
|
||||||
<separator width="10" />
|
<separator width="10" />
|
||||||
<plane width="50" margin="0 5 0 0"></plane>
|
<plane width="50" margin="0 5 0 0"></plane>
|
||||||
<plane width="50" margin="0 5 0 0"></plane>
|
<plane width="50" margin="0 5 0 0"></plane>
|
||||||
<plane width="50" margin="0 5 0 0"></plane>
|
<plane width="50" margin="0 5 0 0"></plane>
|
||||||
|
</plane>
|
||||||
|
<!-- central row -->
|
||||||
|
<plane grow="1" dir="row" wrap="1" height="0">
|
||||||
|
<!-- side bar -->
|
||||||
|
<plane width="200" height="100%" dir="col" color=".2">
|
||||||
|
<plane pad="15" margin="2 2 10 2" color=".3" width="100%" height="auto">
|
||||||
|
<plane height="30" color=".4" />
|
||||||
|
<plane height="30" color=".4" />
|
||||||
|
<plane height="30" color=".4" />
|
||||||
|
<plane height="30" color=".4" />
|
||||||
</plane>
|
</plane>
|
||||||
<!-- central row -->
|
<plane pad="15" margin="2 2 10 2" color=".3" width="100%" height="auto">
|
||||||
<plane grow="1" dir="row" wrap="1" height="0">
|
<plane height="30" color=".4" />
|
||||||
<!-- side bar -->
|
<plane height="30" color=".4" />
|
||||||
<plane width="200" height="100%" wrap="1" dir="col">
|
<plane height="30" color=".4" />
|
||||||
<plane pad="5" margin="2 2 10 2" color=".9" width="100%" height="10">
|
<plane height="30" color=".4" />
|
||||||
<plane height="30" color=".4" />
|
|
||||||
<plane height="30" color=".4" />
|
|
||||||
<plane height="30" color=".4" />
|
|
||||||
<plane height="30" color=".4" />
|
|
||||||
</plane>
|
|
||||||
<plane width="100%" height="1" grow="1" color=".4"/>
|
|
||||||
</plane>
|
|
||||||
<!-- content panel -->
|
|
||||||
<plane width="1" grow="1" height="100%" pad="30" wrap="1">
|
|
||||||
<plane color=".2"></plane>
|
|
||||||
</plane>
|
|
||||||
</plane>
|
</plane>
|
||||||
<!-- status bar -->
|
</plane>
|
||||||
<plane height="30" width="100%" />
|
<!-- content panel -->
|
||||||
<!--<plane height="100%" width="50%" wrap="1" dir="col">
|
<plane width="1" grow="1" height="100%" pad="30" wrap="1">
|
||||||
<plane height="150" width="100%" />
|
<plane color=".2"></plane>
|
||||||
<plane height="50%" width="50%">
|
</plane>
|
||||||
<plane height="30" width="45" />
|
</plane>
|
||||||
<plane height="30" width="45" />
|
<!-- status bar -->
|
||||||
</plane>
|
<plane height="30" width="100%" />
|
||||||
</plane>-->
|
</flex>
|
||||||
</flex>
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ void App::create()
|
|||||||
height = 500;
|
height = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec4 rect_intersection(glm::vec4 a, glm::vec4 b)
|
||||||
|
{
|
||||||
|
// convert from [x,y,w,h] to [x1,y1,x2,y1]
|
||||||
|
a = glm::vec4(a.xy(), a.xy() + a.zw());
|
||||||
|
b = glm::vec4(b.xy(), b.xy() + b.zw());
|
||||||
|
auto o = glm::vec4(glm::max(a.xy(), b.xy()), glm::min(a.zw(), b.zw()));
|
||||||
|
o = glm::vec4(o.xy(), glm::max({ 0, 0 }, o.zw() - o.xy()));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
void App::update_layout()
|
void App::update_layout()
|
||||||
{
|
{
|
||||||
YGNodeCalculateLayout(y_root, YGUndefined, YGUndefined, YGDirectionLTR);
|
YGNodeCalculateLayout(y_root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
@@ -21,14 +31,18 @@ void App::update_layout()
|
|||||||
auto ctx = reinterpret_cast<glm::vec4*>(YGNodeGetContext(y_current));
|
auto ctx = reinterpret_cast<glm::vec4*>(YGNodeGetContext(y_current));
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
{
|
{
|
||||||
float x = YGNodeLayoutGetLeft(y_current);
|
ctx = new glm::vec4();
|
||||||
float y = YGNodeLayoutGetTop(y_current);
|
|
||||||
float w = YGNodeLayoutGetWidth(y_current);
|
|
||||||
float h = YGNodeLayoutGetHeight(y_current);
|
|
||||||
ctx = new glm::vec4(x, y, w, h);
|
|
||||||
YGNodeSetContext(y_current, ctx);
|
YGNodeSetContext(y_current, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (y_current == y_root)
|
||||||
|
{
|
||||||
|
ctx->x = YGNodeLayoutGetLeft(y_current);
|
||||||
|
ctx->y = YGNodeLayoutGetTop(y_current);
|
||||||
|
ctx->z = YGNodeLayoutGetWidth(y_current);
|
||||||
|
ctx->w = YGNodeLayoutGetHeight(y_current);
|
||||||
|
}
|
||||||
|
|
||||||
int n = YGNodeGetChildCount(y_current);
|
int n = YGNodeGetChildCount(y_current);
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@@ -39,14 +53,11 @@ void App::update_layout()
|
|||||||
float y = YGNodeLayoutGetTop(y_child);
|
float y = YGNodeLayoutGetTop(y_child);
|
||||||
float w = YGNodeLayoutGetWidth(y_child);
|
float w = YGNodeLayoutGetWidth(y_child);
|
||||||
float h = YGNodeLayoutGetHeight(y_child);
|
float h = YGNodeLayoutGetHeight(y_child);
|
||||||
float pt = 0;//YGNodeLayoutGetPadding(y_current, YGEdgeTop);
|
ctx_child->x = ctx->x + x;
|
||||||
float pr = 0;//YGNodeLayoutGetPadding(y_current, YGEdgeRight);
|
ctx_child->y = ctx->y + y;
|
||||||
float pb = 0;//YGNodeLayoutGetPadding(y_current, YGEdgeBottom);
|
ctx_child->z = w;
|
||||||
float pl = 0;//YGNodeLayoutGetPadding(y_current, YGEdgeLeft);
|
ctx_child->w = h;
|
||||||
ctx_child->x = ctx->x + x + pl;
|
*ctx_child = rect_intersection(*ctx_child, *ctx);
|
||||||
ctx_child->y = ctx->y + y + pt;
|
|
||||||
ctx_child->z = w - (pl + pr);
|
|
||||||
ctx_child->w = h - (pt + pb);
|
|
||||||
YGNodeSetContext(y_child, ctx_child);
|
YGNodeSetContext(y_child, ctx_child);
|
||||||
y_stack.emplace(y_child);
|
y_stack.emplace(y_child);
|
||||||
}
|
}
|
||||||
@@ -126,6 +137,9 @@ void App::load_layout()
|
|||||||
YGNodeStyleSetPosition(y_node, YGEdgeRight, 0);
|
YGNodeStyleSetPosition(y_node, YGEdgeRight, 0);
|
||||||
YGNodeStyleSetPosition(y_node, YGEdgeBottom, 0);
|
YGNodeStyleSetPosition(y_node, YGEdgeBottom, 0);
|
||||||
YGNodeStyleSetPosition(y_node, YGEdgeLeft, 0);
|
YGNodeStyleSetPosition(y_node, YGEdgeLeft, 0);
|
||||||
|
|
||||||
|
YGNodeStyleSetOverflow(y_node, YGOverflowHidden);
|
||||||
|
|
||||||
while (attr)
|
while (attr)
|
||||||
{
|
{
|
||||||
const auto ka = att::value(attr->Name());
|
const auto ka = att::value(attr->Name());
|
||||||
@@ -133,10 +147,18 @@ void App::load_layout()
|
|||||||
switch (ka)
|
switch (ka)
|
||||||
{
|
{
|
||||||
case att::kAttribute::Width:
|
case att::kAttribute::Width:
|
||||||
if (strchr(attr->Value(), '%'))
|
if (strcmp(attr->Value(), "auto") == 0)
|
||||||
YGNodeStyleSetWidthPercent(y_node, attr->FloatValue());
|
{
|
||||||
|
YGNodeStyleSetWidth(y_node, YGUndefined);
|
||||||
|
YGNodeStyleSetWidthPercent(y_node, YGUndefined);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
YGNodeStyleSetWidth(y_node, attr->FloatValue());
|
{
|
||||||
|
if (strchr(attr->Value(), '%'))
|
||||||
|
YGNodeStyleSetWidthPercent(y_node, attr->FloatValue());
|
||||||
|
else
|
||||||
|
YGNodeStyleSetWidth(y_node, attr->FloatValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case att::kAttribute::MinWidth:
|
case att::kAttribute::MinWidth:
|
||||||
if (strchr(attr->Value(), '%'))
|
if (strchr(attr->Value(), '%'))
|
||||||
@@ -148,10 +170,18 @@ void App::load_layout()
|
|||||||
YGNodeStyleSetMaxWidth(y_node, attr->FloatValue());
|
YGNodeStyleSetMaxWidth(y_node, attr->FloatValue());
|
||||||
break;
|
break;
|
||||||
case att::kAttribute::Height:
|
case att::kAttribute::Height:
|
||||||
if (strchr(attr->Value(), '%'))
|
if (strcmp(attr->Value(), "auto") == 0)
|
||||||
YGNodeStyleSetHeightPercent(y_node, attr->FloatValue());
|
{
|
||||||
|
YGNodeStyleSetHeight(y_node, YGUndefined);
|
||||||
|
YGNodeStyleSetHeightPercent(y_node, YGUndefined);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
YGNodeStyleSetHeight(y_node, attr->FloatValue());
|
{
|
||||||
|
if (strchr(attr->Value(), '%'))
|
||||||
|
YGNodeStyleSetHeightPercent(y_node, attr->FloatValue());
|
||||||
|
else
|
||||||
|
YGNodeStyleSetHeight(y_node, attr->FloatValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case att::kAttribute::MinHeight:
|
case att::kAttribute::MinHeight:
|
||||||
YGNodeStyleSetMinHeight(y_node, attr->FloatValue());
|
YGNodeStyleSetMinHeight(y_node, attr->FloatValue());
|
||||||
|
|||||||
@@ -460,13 +460,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
keys[wp] = false;
|
keys[wp] = false;
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
//current->pointerMove(LOWORD(lp), HIWORD(lp));
|
App::I.mouse_move(LOWORD(lp), HIWORD(lp));
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
//current->pointerDown(LOWORD(lp), HIWORD(lp));
|
App::I.mouse_down(0, LOWORD(lp), HIWORD(lp));
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
//current->pointerUp(LOWORD(lp), HIWORD(lp));
|
App::I.mouse_up(0, LOWORD(lp), HIWORD(lp));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return DefWindowProc(hWnd, msg, wp, lp);
|
return DefWindowProc(hWnd, msg, wp, lp);
|
||||||
|
|||||||
Reference in New Issue
Block a user