Skip to content

Commit

Permalink
Rework input status, Adding input status for last frame & Docking v2...
Browse files Browse the repository at this point in the history
Rework input status (4F85J3oD98),
Adding input status for last frame (9uoLK4Po9J),
Docking v2 (Js3lpwy7AJ)
  • Loading branch information
Neko-Box-Coder committed Sep 10, 2023
1 parent 9ced04c commit 5358f4e
Show file tree
Hide file tree
Showing 84 changed files with 3,247 additions and 286 deletions.
73 changes: 73 additions & 0 deletions Include/ssGUI/DataClasses/BlockData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#ifndef SSGUI_BLOCK_DATA_HPP
#define SSGUI_BLOCK_DATA_HPP

#include "ssGUI/Enums/BlockDataType.hpp"
#include <string>

namespace ssGUI
{
class GUIObject;
class EventCallback;
namespace Extensions
{
class Extension;
}

//class: ssGUI::BlockData
//This class holds the data that is currently blocking the input
class BlockData
{
private:
ssGUI::Enums::BlockDataType CurrentBlockDataType = ssGUI::Enums::BlockDataType::NONE;
std::string CustomDataIdentifier = "";

union
{
ssGUI::GUIObject* CurrentGUIObject;
ssGUI::Extensions::Extension* CurrentExtension;
ssGUI::EventCallback* CurrentEventCallback;
void* CurrentCustomData;
} Data;

public:
//function: UnsetBlockData
//Unsets the block data, meaning <GetBlockDataType> will return <ssGUI::Enums::BlockDataType::NONE>
void UnsetBlockData();

//function: GetBlockDataType
//Gets the block data type
ssGUI::Enums::BlockDataType GetBlockDataType() const;

//function: SetCustomDataIdentifier
//Sets the identifier for custom data for the block data type <ssGUI::Enums::BlockDataType::CUSTOM>
void SetCustomDataIdentifier(const std::string& identifier);

//function: GetCustomDataIdentifier
//Gets the identifier for custom data for the block data type <ssGUI::Enums::BlockDataType::CUSTOM>
std::string GetCustomDataIdentifier() const;

//function: SetBlockData
//Sets the block data for <ssGUI::GUIObject>
void SetBlockData(ssGUI::GUIObject* data);

//function: SetBlockData
//Sets the block data for <ssGUI::Extensions::Extension>
void SetBlockData(ssGUI::Extensions::Extension* data);

//function: SetBlockData
//Sets the block data for <ssGUI::EventCallback>
void SetBlockData(ssGUI::EventCallback* data);

//function: SetBlockData
//Sets the block data for custom data
void SetBlockData(void* data);

//function: GetBlockData
//Sets the block data for the corresponding data type.
//To see which data type, call <GetBlockDataType>
template<typename T>
T* GetBlockData() const;
};
}

#endif
20 changes: 20 additions & 0 deletions Include/ssGUI/DataClasses/DockEventInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef SSGUI_DOCK_EVENT_INFO_HPP
#define SSGUI_DOCK_EVENT_INFO_HPP

#include "ssGUI/Enums/DockSide.hpp"
namespace ssGUI
{
//struct: ssGUI::DockEventInfo
struct DockEventInfo
{
public:
//var: AbortDocking
bool AbortDocking = false;

//var: CurrentDockSide
ssGUI::Enums::DockSide CurrentDockSide;
};
}


#endif
72 changes: 72 additions & 0 deletions Include/ssGUI/DataClasses/DragData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifndef SSGUI_DRAG_DATA_HPP
#define SSGUI_DRAG_DATA_HPP

#include "ssGUI/Enums/DragDataType.hpp"
#include <string>

namespace ssGUI
{
class GUIObject;

/*class: ssGUI::DragData
This class holds the data that the mouse is currently dragging
Variables:
============================== C++ ==============================
private:
ssGUI::Enums::DragDataType CurrentDragDataType = ssGUI::Enums::DragDataType::NONE;
std::string CustomDataIdentifier = "";
union
{
ssGUI::GUIObject* GUIObject;
void* CustomData;
} Data;
=================================================================
*/
class DragData
{
private:
ssGUI::Enums::DragDataType CurrentDragDataType = ssGUI::Enums::DragDataType::NONE;
std::string CustomDataIdentifier = "";

union
{
ssGUI::GUIObject* GUIObject;
void* CustomData;
} Data;

public:
//function: UnsetDragData
//Unsets the drag data, meaning <GetDragDataType> will return <ssGUI::Enums::DragDataType::NONE>
void UnsetDragData();

//function: GetDragDataType
//Gets the drag data type
ssGUI::Enums::DragDataType GetDragDataType() const;

//function: SetCustomDataIdentifier
//Sets the identifier for custom data for the block data type <ssGUI::Enums::DragDataType::CUSTOM>
void SetCustomDataIdentifier(const std::string& identifier);

//function: GetCustomDataIdentifier
//Gets the identifier for custom data for the block data type <ssGUI::Enums::DragDataType::CUSTOM>
std::string GetCustomDataIdentifier() const;

//function: SetDragData
//Sets the drag data for <ssGUI::GUIObject>
void SetDragData(ssGUI::GUIObject* data);

//function: SetDragData
//Sets the drag data for custom data
void SetDragData(void* data);

//function: GetDragData
//Sets the drag data for the corresponding data type.
//To see which data type, call <GetDragDataType>
template<typename T>
T* GetDragData() const;
};
}

#endif
5 changes: 4 additions & 1 deletion Include/ssGUI/DataClasses/EventInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ namespace ssGUI
ssGUI::Backend::BackendSystemInputInterface* InputInterface;

//var: InputStatus
ssGUI::InputStatus& InputStatus;
ssGUI::InputStatus& CurrentInputStatus;

//var: LastInputStatus
const ssGUI::InputStatus& LastInputStatus;

//var: MainWindow
ssGUI::GUIObject* MainWindow;
Expand Down
21 changes: 19 additions & 2 deletions Include/ssGUI/DataClasses/Hierarchy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,27 @@ namespace ssGUI
virtual void ChangeChildOrderToAfterPosition( ssGUI::Hierarchy::ChildToken child,
ssGUI::Hierarchy::ChildToken position);

//function: GetListOfChildren
//Gets a list of children
/*function: GetListOfChildren
Gets a list of children.
It is not recommended to do any modification to any of the children since any modification may modify the state of the children.
For example, if there's an event callback that deletes or change the parent of a child (say the 3rd child),
and if it got triggered by an action previously (say when processing the 1st child),
this will lead to the list of children not up to date and that child (3rd child in this example) could be invalid.
To avoid this situation, it is recommended to use child iterator (<GetCurrentChild>, <MoveChildrenIteratorNext>, etc...) to iterate the children instead.
*/
virtual std::vector<ssGUI::GUIObject*> GetListOfChildren() const;

//function: HasChildRecursively
//Returns true if the searchChild is an recursive child 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
virtual bool HasParentRecursively(ssGUI::GUIObject* searchParent) const;

//function: Internal_AddChild
//(Internal ssGUI function) Adds the GUI Object to the children record. Use <SetParent> instead for adding or removing child.
virtual void Internal_AddChild(ssGUI::GUIObject* obj, bool compositeChild);
Expand Down
26 changes: 18 additions & 8 deletions Include/ssGUI/DataClasses/InputStatus.hpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#ifndef SSGUI_INPUT_STATUS_H
#define SSGUI_INPUT_STATUS_H

#include "ssGUI/DataClasses/BlockData.hpp"
#include "ssGUI/DataClasses/DragData.hpp"

//namespace: ssGUI
namespace ssGUI
{
class GUIObject;

//class: ssGUI::InputStatus
class InputStatus
//This holds the status information such as blocking or docking for different inputs
struct InputStatus
{
public:
//var: MouseInputBlockedObject
ssGUI::GUIObject* MouseInputBlockedObject = nullptr;
//var: MouseInputBlockedData
//The object/data that is currently blocking mouse input
BlockData MouseInputBlockedData;

//var: KeyInputBlockedObject
ssGUI::GUIObject* KeyInputBlockedObject = nullptr;
//var: KeyInputBlockedData
//The object/data that is currently blocking key press input
BlockData KeyInputBlockedData;

//var: DockingBlockedObject
//var: LegacyDockingBlockedObject (Deprecated)
//Blocks docking of a window if there's another GUI Object on top of it.
ssGUI::GUIObject* DockingBlockedObject = nullptr;
ssGUI::GUIObject* LegacyDockingBlockedObject = nullptr;

//var: CurrentDragData
//The data currently being dragged by the mouse
DragData CurrentDragData;
};
}


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

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

namespace ssGUI
{
//namespace: ssGUI::Enums
namespace Enums
{
/*enum: BlockDataType
NONE - Nothing is blocking
GUI_OBJECT - <ssGUI::GUIObject> is blocking
EXTENSION - <ssGUI::Extensions::Extension> is blocking
EVENT_CALLBACK - <ssGUI::EventCallback> is blocking
CUSTOM - Custom data (such as user event) is blocking
COUNT - Count
*/
enum class BlockDataType : uint16_t
{
NONE,
GUI_OBJECT,
EXTENSION,
EVENT_CALLBACK,
CUSTOM,
COUNT
};

//function: BlockDataTypeToString
inline std::string BlockDataTypeToString(BlockDataType input)
{
static_assert((int)BlockDataType::COUNT == 5, "ToString");
switch(input)
{
RETURN_ENUM_STRING(BlockDataType::NONE);
RETURN_ENUM_STRING(BlockDataType::GUI_OBJECT);
RETURN_ENUM_STRING(BlockDataType::EXTENSION);
RETURN_ENUM_STRING(BlockDataType::EVENT_CALLBACK);
RETURN_ENUM_STRING(BlockDataType::CUSTOM);
RETURN_ENUM_STRING(BlockDataType::COUNT);
}

return "";
}
}
}

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

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

//namespace: ssGUI::Enums
namespace Enums
{
/*enum: DockSide
TOP - Docking to top half
RIGHT - Docking to right half
BOTTOM - Docking to bottom half
LEFT - Docking to left half
CENTER - Docking to the whole area
COUNT - Count
*/
enum class DockSide
{
TOP,
RIGHT,
BOTTOM,
LEFT,
CENTER,
COUNT
};

//function: DockSideToString
inline std::string DockSideToString(DockSide side)
{
static_assert((int)DockSide::COUNT == 5, "ToString");
switch(side)
{
RETURN_ENUM_STRING(DockSide::TOP);
RETURN_ENUM_STRING(DockSide::RIGHT);
RETURN_ENUM_STRING(DockSide::BOTTOM);
RETURN_ENUM_STRING(DockSide::LEFT);
RETURN_ENUM_STRING(DockSide::CENTER);
RETURN_ENUM_STRING(DockSide::COUNT);
}

return "";
}
}

}

#endif
Loading

0 comments on commit 5358f4e

Please sign in to comment.