Sdk/BaseWidget: Widget::Add now returns a pointer (easier to use)
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Ndk
|
||||
BaseWidget(BaseWidget&&) = default;
|
||||
virtual ~BaseWidget();
|
||||
|
||||
template<typename T, typename... Args> T& Add(Args&&... args);
|
||||
template<typename T, typename... Args> T* Add(Args&&... args);
|
||||
inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
|
||||
|
||||
inline void Center();
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace Ndk
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
inline T& BaseWidget::Add(Args&&... args)
|
||||
inline T* BaseWidget::Add(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<T> widget = std::make_unique<T>(this, std::forward<Args>(args)...);
|
||||
T& widgetRef = *widget;
|
||||
T* widgetPtr = widget.get();
|
||||
AddChild(std::move(widget));
|
||||
|
||||
return widgetRef;
|
||||
return widgetPtr;
|
||||
}
|
||||
|
||||
inline void BaseWidget::AddChild(std::unique_ptr<BaseWidget>&& widget)
|
||||
|
||||
Reference in New Issue
Block a user