diff --git a/.gitignore b/.gitignore index 259148f..6046e0d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,22 @@ # Precompiled Headers *.gch *.pch +*.pdb + +# Visual Studio cache files +*.aps + +# Visual Studio profiler +*.psess + +# Visual Studio Trace Files +*.vsp + +# Visual Studio generated files +*.vspscc + +# Visual Studio project files +*.vcxproj* # Compiled Dynamic libraries *.so diff --git a/src/widgets.cpp b/src/widgets.cpp index f6b5639..aa0f95a 100644 --- a/src/widgets.cpp +++ b/src/widgets.cpp @@ -105,7 +105,7 @@ static Widget *getValidRoot(Context &ctx) { } ctx.mRoot = new Widget; - ctx.mRoot->mType = WidgetType::Container; + ctx.mRoot->mType = WidgetType::RootContainer; ctx.mRoot->mHandle = WidgetHandle::getRootHandle(); return ctx.mRoot; @@ -178,14 +178,14 @@ void eventDispatcher(Context &ctx, int32_t eventId, EventPayload *eventPayload) } } -WidgetHandle Widgets::container(WidgetHandle parentId, const char *text, const Rect &rect) { +WidgetHandle Widgets::rootContainer(WidgetHandle parentId, const char *text, const Rect &rect) { auto &ctx = TinyUi::getContext(); if (ctx.mRoot == nullptr) { return WidgetHandle{WidgetHandle::InvalidId}; } - Widget *widget = createWidget(ctx, parentId, rect, WidgetType::Container); - ctx.mRoot = widget; + Widget *widget = createWidget(ctx, parentId, rect, WidgetType::RootContainer); + ctx.mRoot->mChildren.emplace_back(widget); if (text != nullptr) { widget->mText.assign(text); } @@ -620,7 +620,7 @@ static void render(Context &ctx, const Widget *currentWidget) { } break; - case WidgetType::Container: + case WidgetType::RootContainer: case WidgetType::Box: { Renderer::drawRect(ctx, r.top.x, r.top.y, r.width, r.height, currentWidget->mFilledRect, ctx.mStyle.mBorder); diff --git a/src/widgets.h b/src/widgets.h index c1f64df..3946211 100644 --- a/src/widgets.h +++ b/src/widgets.h @@ -33,7 +33,7 @@ struct Context; /// @brief This enum is used to describe the widget type. enum class WidgetType { Invalid = -1, ///< Not initialized - Container = 0, ///< A container widget + RootContainer = 0, ///< A root container widget Button, ///< A button widget Label, ///< A label widget InputField, ///< An input field widget @@ -70,14 +70,15 @@ struct FilledState { /// @brief This enum is used to describe the alignment of a widget. enum class WidgetStyle { - Invalid = -1, + Invalid = -1, ///< Not initialized BorderStyle, ///< The widget has a border - Count + Count ///< The number of widget styles }; /// @brief This enum is used to describe the alignment of a widget. using WidgetArray = std::vector; +/// @brief This struct is used to describe the checkbox context. struct CheckBoxContext { bool mChecked{false}; ///< The checked state of the checkbox. }; @@ -168,12 +169,12 @@ struct Widgets { /// @brief The class destructor. ~Widgets() = default; - /// @brief Create a new widget from the type container. + /// @brief Create a new widget from the type root container. /// @param[in] parentId The parent id of the widget. /// @param[in] text The text of the widget. /// @param[in] rect The rect of the widget. /// @return ResultOk if the widget was created, ErrorCode if not. - static WidgetHandle container(WidgetHandle parentId, const char *text, const Rect &rect); + static WidgetHandle rootContainer(WidgetHandle parentId, const char *text, const Rect &rect); /// @brief Create a new widget from the type box. /// @param[in] parentId The parent id of the widget.