Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233#include "ActionBar.h"#include "UserInterface/Engine/Geometry.h"#include "Widgets/Button.h"#include "Widgets/Widget.h"namespace UI {
ActionBar::ActionBar() { auto hLayout = std::make_unique<UI::StackLayout>(UI::Orientation::Horizontal, 8.0f); hLayout->SetVerticalAlignment(UI::VerticalAlignment::Center); horizontalLayout = hLayout.get(); // this is a std::fragile_ptr Widget::AddChild(std::move(hLayout)); // avoid recursion
SetBgColor(Color(51.0f/255.0f, 51.0f/255.0f, 51.0f/255.0f, 0.5f)); SetBorder(Color(51.0f/255.0f, 51.0f/255.0f, 51.0f/255.0f, 0.75f), 2.0f, 16.0f); // BUG: border is not normal blend mode (50% + 50% should be 75%), currently invisible, applied workaround by using 75% instead SetPadding(Thickness(8,8));}
void ActionBar::AddChild(std::unique_ptr<Widget> child) { if (!child) return; Button* action = dynamic_cast<Button*>(child.get()); if (action) { action->SetNormalColor(Color(51.0f/255.0f, 51.0f/255.0f, 51.0f/255.0f, 0.0f)); // should be 0.0, see above action->SetBorder(Color(51.0f/255.0f, 51.0f/255.0f, 51.0f/255.0f, 0.75f), 2.0f, 8.0f); if (action->GetLabel().empty()) { action->SetPadding(Thickness(6,6)); } else { action->SetPadding(Thickness(6,6,12,6)); } } horizontalLayout->AddChild(std::move(child));}
}