Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Nov 19, 2024
1 parent 44c58dc commit 03964d9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
23 changes: 20 additions & 3 deletions client/src/margincontainer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "widget.hpp"
#include "shapeclipboard.hpp"

class MarginContainer: public Widget
{
Expand All @@ -20,6 +21,8 @@ class MarginContainer: public Widget
Widget::VarDir argWidgetDir,
bool argWidgetAutoDelete,

std::function<void(const Widget *, int, int)> argDrawFunc = nullptr,

Widget *argParent = nullptr,
bool argAutoDelete = false)

Expand All @@ -39,7 +42,21 @@ class MarginContainer: public Widget

, m_widgetDir(std::move(argWidgetDir))
{
addChild(argWidget, [this](const Widget *)
Widget::addChild(new ShapeClipBoard
{
DIR_UPLEFT,
0,
0,

[this](const Widget *){ return w(); },
[this](const Widget *){ return h(); },

std::move(argDrawFunc),
},

true);

Widget::addChild(argWidget, [this](const Widget *)
{
return Widget::evalDir(m_widgetDir, this);
},
Expand Down Expand Up @@ -88,6 +105,6 @@ class MarginContainer: public Widget
void addChild(Widget *, Widget::VarDir, Widget::VarOff, Widget::VarOff, bool) override { throw fflreach(); }

public:
const Widget *contained() const { return firstChild(); }
/* */ Widget *contained() { return firstChild(); }
const Widget *contained() const { return lastChild(); }
/* */ Widget *contained() { return lastChild(); }
};
34 changes: 28 additions & 6 deletions client/src/marginwrapper.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "widget.hpp"
#include "shapeclipboard.hpp"

class MarginWrapper: public Widget
{
Expand All @@ -13,6 +14,7 @@ class MarginWrapper: public Widget
bool argWidgetAutoDelete,

std::array<int, 4> argMargin = {},
std::function<void(const Widget *, int, int)> argDrawFunc = nullptr,

Widget *argParent = nullptr,
bool argAutoDelete = false)
Expand All @@ -26,14 +28,34 @@ class MarginWrapper: public Widget
[argWidget, argMargin](const Widget *){ return argWidget->w() + std::max<int>(argMargin[2], 0) + std::max<int>(argMargin[3], 0); },
[argWidget, argMargin](const Widget *){ return argWidget->h() + std::max<int>(argMargin[0], 0) + std::max<int>(argMargin[1], 0); },

{
{argWidget, DIR_UPLEFT, std::max<int>(argMargin[2], 0), std::max<int>(argMargin[0], 0), argWidgetAutoDelete},
},
{},

argParent,
argAutoDelete,
}
{}
{
Widget::addChild(new ShapeClipBoard
{
DIR_UPLEFT,
0,
0,

[this](const Widget *){ return w(); },
[this](const Widget *){ return h(); },

std::move(argDrawFunc),
},

true);

Widget::addChild(argWidget,
DIR_UPLEFT,

std::max<int>(argMargin[2], 0),
std::max<int>(argMargin[0], 0),

argWidgetAutoDelete);
}

public:
bool processEventDefault(const SDL_Event &event, bool valid) override
Expand All @@ -46,6 +68,6 @@ class MarginWrapper: public Widget
void addChild(Widget *, Widget::VarDir, Widget::VarOff, Widget::VarOff, bool) override { throw fflreach(); }

public:
const Widget *wrapped() const { return firstChild(); }
/* */ Widget *wrapped() { return firstChild(); }
const Widget *wrapped() const { return lastChild(); }
/* */ Widget *wrapped() { return lastChild(); }
};
1 change: 1 addition & 0 deletions client/src/menuboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ MenuBoard::MenuBoard(
false,

argMargin,
nullptr,

this,
false,
Expand Down
3 changes: 2 additions & 1 deletion client/src/shapeclipboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class ShapeClipBoard: public Widget
std::function<void(const Widget *, int, int)> m_drawFunc;

public:
ShapeClipBoard(Widget::VarDir,
ShapeClipBoard(
Widget::VarDir,
Widget::VarOff,
Widget::VarOff,

Expand Down

0 comments on commit 03964d9

Please sign in to comment.