Skip to content

Commit

Permalink
widget: add new widget prop for transparent add child
Browse files Browse the repository at this point in the history
  • Loading branch information
s.kushnirenko committed Mar 26, 2020
1 parent 0736b69 commit 9de2a0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions honsu/honsu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,10 @@ class IssuePanel : public Frame
issue(_issue), day(_day)
{
auto& header = hstack(2, 2);
header.label(WidgetId{ "#timelb" }, TextColor{ Color::grey }, FontSize{ 18 }, Caption{ "[00:00:00]" })
.spinner(WidgetId{ "#spinner" }, SpinnerRadius{ 0.5f }, BackgroundColor{ Color::ligthDarkGrey }, IsSubElement{ true }, RelativeSize{ 1.f, 1.f });
header.label(WidgetId{ "#timelb" }, TextColor{ Color::grey }, FontSize{ 18 }, Caption{ "[00:00:00]" },
Element{ spinner(WidgetId{ "#spinner" }, SpinnerRadius{ 0.5f },
BackgroundColor{ Color::ligthDarkGrey }, IsSubElement{ true }, RelativeSize{ 1.f, 1.f })
});
header.label(Caption{ issue->summary }, FontSize{ 18 }, TextColor{ Color::white }, TextWrapped{ true });

label(Caption{ issue->sprints.empty() ? "Not found projects" : issue->sprints.front() }, FontSize{ 14 });
Expand Down
3 changes: 3 additions & 0 deletions include/nanogui/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ DECLSETTERARGSNEW(WidgetGridLayout, GridLayout)
DECLSETTERARGSNEW(WidgetBoxLayout, BoxLayout)
DECLSETTERARGS(FixedSize, Vector2i)
DECLSETTER(WidgetId, std::string)
DECLSETTER(Element, Widget&)
DECLSETTER(FloatValue, float)
DECLSETTER(Icon, int)
DECLSETTER(IconColor, Color)
Expand Down Expand Up @@ -350,6 +351,7 @@ class NANOGUI_EXPORT Widget : public Object {

/// Convenience function which appends a widget at the end
void addChild(Widget *widget);
void addChild(Widget& widget) { addChild(&widget); }

void remove(); // this function should be used in screen::drawWidgets call
void removeLater(); // push widget to removes array
Expand Down Expand Up @@ -587,6 +589,7 @@ class NANOGUI_EXPORT Widget : public Object {
PROPSETTER(FixedHeight, setFixedHeight)
PROPSETTER(FixedWidth, setFixedWidth)
PROPSETTER(WidgetId, setId)
PROPSETTER(Element, addChild)
PROPSETTER(Position, setPosition)
PROPSETTER(WidgetSize, setSize)
PROPSETTER(MinimumSize, setMinSize)
Expand Down
3 changes: 2 additions & 1 deletion src/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ Vector2i BoxLayout::preferredSize(NVGcontext *ctx, const Widget *widget) const

bool first = true;
int axis1 = (int) mOrientation % 2, axis2 = ((int) mOrientation + 1)%2;
for (auto w : widget->children())
for (size_t i=0; i < widget->children().size(); i++)
{
auto w = widget->children().at(i);
if (!w->visible() || w->isSubElement())
continue;
if (first)
Expand Down

0 comments on commit 9de2a0a

Please sign in to comment.