On Tuesday, 17 March 2020 at 09:31:21 UTC, Виталий Фадеев wrote:
Main goal is: get content "xywh" from given rect and padding.
Of course content.x is dynamic.
//
import core.sys.windows.windows;
import std.stdio;
class Base
{
RECT rect = { 0, 0, 500, 400 };
RECT padding = { 10, 10, 10, 10 };
// ...content...
??? content
{
@property int x() const { return rect.left +
padding.left; }
}
}
int main()
{
auto b = new Base();
writeln( b.content.x );
}
How to implement "b.content.x" ( sequence call "content" of the
"b" and then "x" of that ) ?
How to implement beauty ?
Now working with this variant:
struct Content
{
Base This;
int left() { return This.rect.left + This.padding.left;
}
int right() { return This.rect.right -
This.padding.right; }
int top() { return This.rect.top + This.padding.top;
}
int bottom() { return This.rect.bottom -
This.padding.bottom; }
int x() { return left; }
int y() { return top; }
int w() { return right - left; }
int h() { return bottom - top; }
RECT rect() { return This.rect; }
}
class Base
{
RECT rect;
RECT padding;
Content content()
{
return Content( this );
}
}