Skip to content

Commit

Permalink
Merge pull request Neko-Box-Coder#33 from Neko-Box-Coder/Tabbable
Browse files Browse the repository at this point in the history
Window Tab extension (Rf8FO9AQjv)
  • Loading branch information
Neko-Box-Coder authored Oct 28, 2023
2 parents fc4dc6c + 44e2155 commit 85c4d96
Show file tree
Hide file tree
Showing 17 changed files with 3,423 additions and 49 deletions.
36 changes: 18 additions & 18 deletions Include/ssGUI/DataClasses/Hierarchy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ namespace ssGUI

virtual void NotifyAndRemoveOnObjectDestroyEventCallbackIfExist();

void AddChild(ssGUI::GUIObject* guiObject, bool compositeChild);
void AddChild( ssGUI::GUIObject* guiObject,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild);
void SetChildParent(ssGUI::GUIObject* guiObject, bool compositeChild);
void SetChildParent(ssGUI::GUIObject* guiObject,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild);

void AddChildWithWrapper(ssGUI::GUIObject* guiObject, bool compositeChild);
void SetChildParentWithWrapper(ssGUI::GUIObject* guiObject, bool compositeChild);

void AddChildWithWrapper( ssGUI::GUIObject* guiObject,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild);
void SetChildParentWithWrapper( ssGUI::GUIObject* guiObject,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild);

public:
Hierarchy();
Expand Down Expand Up @@ -175,7 +175,7 @@ namespace ssGUI
ssGUI_BASE_CHECK_RETURN_NULL();

auto* guiObject = ssGUI::Factory::Create<T>();
AddChild(guiObject, compositeChild);
SetChildParent(guiObject, compositeChild);
return guiObject;
}

Expand All @@ -189,7 +189,7 @@ namespace ssGUI
ssGUI_BASE_CHECK_RETURN_NULL();

auto* guiObject = ssGUI::Factory::Create<T>();
AddChild(guiObject, horizontalAlignment, verticalAlignment, compositeChild);
SetChildParent(guiObject, horizontalAlignment, verticalAlignment, compositeChild);
return guiObject;
}

Expand All @@ -201,7 +201,7 @@ namespace ssGUI
ssGUI_BASE_CHECK_RETURN_NULL();

auto* guiObject = ssGUI::Factory::Create<T>();
AddChildWithWrapper(guiObject, compositeChild);
SetChildParentWithWrapper(guiObject, compositeChild);
return guiObject;
}

Expand All @@ -215,7 +215,7 @@ namespace ssGUI
ssGUI_BASE_CHECK_RETURN_NULL();

auto* guiObject = ssGUI::Factory::Create<T>();
AddChildWithWrapper(guiObject, horizontalAlignment, verticalAlignment, compositeChild);
SetChildParentWithWrapper(guiObject, horizontalAlignment, verticalAlignment, compositeChild);
return guiObject;
}

Expand Down Expand Up @@ -303,7 +303,7 @@ namespace ssGUI
//function: AddChildAfter
//Same as above but with <AdvancedPosition: ssGUI::Extensions::AdvancedPosition> extension added
template<typename T>
T* AddChildAfter( ssGUI::GUIObject* target,
T* AddChildAfter( ssGUI::GUIObject* target,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild = false)
Expand Down Expand Up @@ -336,7 +336,7 @@ namespace ssGUI
//function: AddChildAfterWithWrapper
//Same as above but with <AdvancedPosition: ssGUI::Extensions::AdvancedPosition> extension added
template<typename T>
T* AddChildAfterWithWrapper( ssGUI::GUIObject* target,
T* AddChildAfterWithWrapper( ssGUI::GUIObject* target,
ssGUI::Enums::AlignmentHorizontal horizontalAlignment,
ssGUI::Enums::AlignmentVertical verticalAlignment,
bool compositeChild = false)
Expand Down Expand Up @@ -526,11 +526,11 @@ namespace ssGUI
virtual std::vector<ssGUI::GUIObject*> GetListOfChildren() const;

//function: HasChildRecursively
//Returns true if the searchChild is an recursive child of this GUI Object
//Returns true if the searchChild is an recursive child (including this GUI Object) of this GUI Object
virtual bool HasChildRecursively(ssGUI::GUIObject* searchChild) const;

//function: HasParentRecursively
//Returns true if the searchChild is an recursive parent of this GUI Object
//Returns true if the searchChild is an recursive parent (including this GUI Object) of this GUI Object.
virtual bool HasParentRecursively(ssGUI::GUIObject* searchParent) const;

//function: Internal_AddChild
Expand Down
29 changes: 29 additions & 0 deletions Include/ssGUI/DataClasses/TabEventInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef SSGUI_TAB_EVENT_INFO_HPP
#define SSGUI_TAB_EVENT_INFO_HPP

//namespace: ssGUI
namespace ssGUI
{
class GUIObject;

class Tab;

//struct: ssGUI::TabEventInfo
//Custom event info for NEW_TAB_CONTENT_ADDED, TAB_CONTENT_SWITCHED and TAB_CONTENT_UNTABBED
//events
struct TabEventInfo
{
//var: TabAreaContainer
//Pointer to the GUI Object that has the tab area extension attached
ssGUI::GUIObject* TabAreaContainer = nullptr;

//var: Tab
//Pointer to the tab that is related to the event.
//For TAB_CONTENT_UNTABBED event, this will be nullptr.
//For TAB_CONTENT_SWITCHED event, this can be nullptr if no tab is selected.
ssGUI::Tab* Tab = nullptr;
};

}

#endif
98 changes: 98 additions & 0 deletions Include/ssGUI/Enums/Direction.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef SSGUI_DIRECTION_HPP
#define SSGUI_DIRECTION_HPP

#include "ssGUI/HelperClasses/EnumToStringMacro.hpp"
#include <cstdint>
#include <string>

namespace ssGUI
{

//namespace: ssGUI::Enums
namespace Enums
{
/*enum: Direction
Bitfiled type that represents a combination of directions.
TOP - Top
RIGHT - Right
BOTTOM - Bottom
LEFT - Left
COUNT - Count
*/
enum class Direction : uint8_t
{
TOP = 1 << 0,
RIGHT = 1 << 1,
BOTTOM = 1 << 2,
LEFT = 1 << 3,
COUNT = 1 << 4
};

namespace
{
inline std::string Internal_DirectionToString(Direction anchor)
{
static_assert((uint8_t)Direction::COUNT == 1 << 4, "ToString");
switch(anchor)
{
RETURN_ENUM_STRING(Direction::TOP);
RETURN_ENUM_STRING(Direction::RIGHT);
RETURN_ENUM_STRING(Direction::BOTTOM);
RETURN_ENUM_STRING(Direction::LEFT);
RETURN_ENUM_STRING(Direction::COUNT);
}

return "";
}
}

inline ssGUI::Enums::Direction operator|(ssGUI::Enums::Direction a,
ssGUI::Enums::Direction b)
{
return static_cast<ssGUI::Enums::Direction>(static_cast<uint8_t>(a) |
static_cast<uint8_t>(b));
};

inline ssGUI::Enums::Direction operator&(ssGUI::Enums::Direction a,
ssGUI::Enums::Direction b)
{
return static_cast<ssGUI::Enums::Direction>(static_cast<uint8_t>(a) &
static_cast<uint8_t>(b));
};

inline bool operator==(ssGUI::Enums::Direction a, ssGUI::Enums::Direction b)
{
return (static_cast<uint8_t>(a & b) == static_cast<uint8_t>(b));
};

inline bool operator!=(ssGUI::Enums::Direction a, ssGUI::Enums::Direction b)
{
return !(a == b);
};

//function: DirectionToString
inline std::string DirectionToString(Direction direction)
{
static_assert((uint8_t)Direction::COUNT == 1 << 4, "ToString");

std::string curString;
for(int i = 0; i < 4; ++i)
{
std::string returnString =
Internal_DirectionToString(direction & (Direction)(1 << i));
if(!returnString.empty())
curString += returnString + ", ";
}

//Remove last comma
if(!curString.empty())
curString.erase(curString.begin() + curString.size() - 2);

return curString;
}
}

}

#endif
19 changes: 18 additions & 1 deletion Include/ssGUI/Enums/EventType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ namespace ssGUI
<ssGUI::EventInfo::CustomInfo> will be pointer to <ssGUI::DockEventInfo> struct.
<ssGUI::DockEventInfo::AbortDocking> has no effect.
NEW_TAB_CONTENT_ADDED - Triggered *after* there's a new tab content added to TabArea extension. The content being added will be the source for triggering this event callback.
<ssGUI::EventInfo::CustomInfo> will be pointer to <ssGUI::TabEventInfo> struct.
TAB_CONTENT_SWITCHED - Triggered *after* a new tab content is switched. The new tab content will be the source for triggering this event callback.
<ssGUI::EventInfo::CustomInfo> will be pointer to <ssGUI::TabEventInfo> struct.
TAB_CONTENT_UNTABBED - Triggered *after* the tabbed content is untabbed. The untabbed content will be the source for triggering this event callback.
<ssGUI::EventInfo::CustomInfo> will be pointer to <ssGUI::TabEventInfo> struct.
COUNT - Count
SCROLLBAR_VALUE_CHANGED - Same as <SLIDER_VALUE_CHANGED>
Expand Down Expand Up @@ -126,6 +135,10 @@ namespace ssGUI
OBJECT_DOCKED,
EXTERNAL_OBJECT_DOCKED,

NEW_TAB_CONTENT_ADDED,
TAB_CONTENT_SWITCHED,
TAB_CONTENT_UNTABBED,

COUNT,

SCROLLBAR_VALUE_CHANGED = SLIDER_VALUE_CHANGED,
Expand All @@ -136,7 +149,7 @@ namespace ssGUI
//function: EventTypeToString
inline std::string EventTypeToString(EventType event)
{
static_assert((int)EventType::COUNT == 33, "ToString");
static_assert((int)EventType::COUNT == 36, "ToString");
switch(event)
{
RETURN_ENUM_STRING(EventType::NONE);
Expand Down Expand Up @@ -177,6 +190,10 @@ namespace ssGUI
RETURN_ENUM_STRING(EventType::OBJECT_DOCKED);
RETURN_ENUM_STRING(EventType::EXTERNAL_OBJECT_DOCKED);

RETURN_ENUM_STRING(EventType::NEW_TAB_CONTENT_ADDED);
RETURN_ENUM_STRING(EventType::TAB_CONTENT_SWITCHED);
RETURN_ENUM_STRING(EventType::TAB_CONTENT_UNTABBED);

RETURN_ENUM_STRING(EventType::COUNT);
}

Expand Down
14 changes: 8 additions & 6 deletions Include/ssGUI/Enums/GUIObjectType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ namespace Enums
IMAGE_CANVAS = 1 << 15,
STANDARD_SLIDER = 1 << 16,
STANDARD_CHECKBOX = 1 << 17,
COUNT = 1 << 18
TAB = 1 << 18,
COUNT = 1 << 19
};

inline ssGUI::Enums::GUIObjectType operator|(ssGUI::Enums::GUIObjectType a, ssGUI::Enums::GUIObjectType b)
Expand All @@ -96,9 +97,9 @@ namespace Enums

namespace
{
inline std::string InternalGUIObjectTypeToString(GUIObjectType guiObjectType)
inline std::string Internal_GUIObjectTypeToString(GUIObjectType guiObjectType)
{
static_assert((int)GUIObjectType::COUNT == 1 << 18, "ToString");
static_assert((int)GUIObjectType::COUNT == 1 << 19, "ToString");
switch(guiObjectType)
{
RETURN_ENUM_STRING(GUIObjectType::WINDOW);
Expand All @@ -119,6 +120,7 @@ namespace Enums
RETURN_ENUM_STRING(GUIObjectType::IMAGE_CANVAS);
RETURN_ENUM_STRING(GUIObjectType::STANDARD_SLIDER);
RETURN_ENUM_STRING(GUIObjectType::STANDARD_CHECKBOX);
RETURN_ENUM_STRING(GUIObjectType::TAB);
RETURN_ENUM_STRING(GUIObjectType::COUNT);
}

Expand All @@ -129,12 +131,12 @@ namespace Enums
//function: GUIObjectTypeToString
inline std::string GUIObjectTypeToString(GUIObjectType guiObjectType)
{
static_assert((int)GUIObjectType::COUNT == 1 << 18, "ToString");
static_assert((int)GUIObjectType::COUNT == 1 << 19, "ToString");

std::string curString;
for(int i = 0; i < 19; ++i)
for(int i = 0; i < 20; ++i)
{
std::string returnString = InternalGUIObjectTypeToString(guiObjectType & (GUIObjectType)(1 << i));
std::string returnString = Internal_GUIObjectTypeToString(guiObjectType & (GUIObjectType)(1 << i));
if(!returnString.empty())
curString += returnString + ", ";
}
Expand Down
Loading

0 comments on commit 85c4d96

Please sign in to comment.