This commit is contained in:
Isuru Samarathunga
2025-11-14 09:43:09 +05:30
parent 9ff39d7245
commit a2b80ef600
32 changed files with 928 additions and 295 deletions

View File

@ -22,6 +22,13 @@ namespace ia::iae
{
class TabContainer
{
struct Tab
{
IView* View{};
BOOL IsOpen{true};
BOOL IsCloseable{false};
};
public:
TabContainer();
@ -31,10 +38,13 @@ namespace ia::iae
VOID Update();
VOID ProcessEvent(IN SDL_Event *event);
template<typename ViewType> INLINE VOID AddTab(IN CONST String &name);
template<typename ViewType> INLINE VOID AddTab(IN CONST String &name, IN BOOL isCloseable = false);
IView *GetTab(IN CONST String &name);
VOID RemoveTab(IN CONST String &name);
VOID OpenTab(IN CONST String& name);
VOID CloseTab(IN CONST String& name);
VOID ChangeActiveTab(IN PCCHAR name);
private:
@ -42,14 +52,14 @@ namespace ia::iae
CONST String m_containerID;
PCCHAR m_activeTabName{};
PCCHAR m_pendingActiveTabName{};
Map<String, IView *> m_tabViews;
Map<String, Tab> m_tabViews;
private:
VOID AddTab(IN CONST String &name, IN IView *view);
VOID AddTab(IN CONST String &name, IN IView *view, IN BOOL isCloseable);
};
template<typename ViewType> VOID TabContainer::AddTab(IN CONST String &name)
template<typename ViewType> VOID TabContainer::AddTab(IN CONST String &name, IN BOOL isCloseable)
{
AddTab(name, new ViewType());
AddTab(name, new ViewType(), isCloseable);
}
} // namespace ia::iae

View File

@ -33,10 +33,16 @@ namespace ia::iae
STATIC VOID AlignCursorHCenter(IN CONST ImRect &rect, IN FLOAT32 width);
STATIC VOID AlignCursorVCenter(IN CONST ImRect &rect, IN FLOAT32 height);
public:
STATIC VOID FocusAssetView();
STATIC VOID DrawTextCentered(IN CONST ImVec2& viewExtent, IN CONST String& text);
STATIC class View_Asset *GetAssetView();
public:
STATIC VOID OpenFilePreviewView();
STATIC VOID CloseFilePreviewView();
STATIC VOID OpenAssetView();
STATIC VOID CloseAssetView();
STATIC class View_Asset* GetAssetView();
STATIC class View_FilePreview *GetFilePreviewView();
STATIC class IView *GetFocusedView()
{

View File

@ -18,12 +18,14 @@
#include <UI/View/IView.hpp>
#include <IAEngine/Asset/IAsset.hpp>
namespace ia::iae
{
class View_Asset : public IView
{
public:
VOID Open(IN Path path);
VOID Open(IN String assetName);
VOID Close();
public:
@ -36,6 +38,19 @@ namespace ia::iae
VOID OnEvent(IN SDL_Event *event);
private:
Path m_assetPath{};
VOID RenderTextureAsset();
VOID RenderSpriteAsset();
VOID RenderTileSheetAsset();
VOID RenderSpriteSheetAsset();
VOID DrawAssetTypePicker();
VOID DrawAssetImage(IN FLOAT32 relativeWidth, IN IVec2 gridSize);
private:
class IAsset *m_asset{};
String m_assetName{};
Handle m_assetImageHandle{};
IVec2 m_assetImageExtent{};
EAssetType m_assetType{};
};
} // namespace ia::iae

View File

@ -0,0 +1,58 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <UI/View/IView.hpp>
namespace ia::iae
{
class View_FilePreview : public IView
{
enum class EFileType
{
UNKNOWN,
TEXT,
IMAGE,
};
public:
VOID Open(IN Path path);
VOID Close();
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private:
VOID RenderTextFile();
VOID RenderImageFile();
VOID RenderUnknownFile();
private:
Path m_filePath{};
EFileType m_fileType{EFileType::UNKNOWN};
PVOID m_fileData{};
SIZE_T m_fileDataSize{};
IVec2 m_fileDataExtent{};
};
} // namespace ia::iae

View File

@ -0,0 +1,43 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <UI/View/IView.hpp>
namespace ia::iae
{
class View_Game : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
public:
VOID ProcessEvent(IN SDL_Event *event)
{
OnEvent(event);
}
private:
class RDC_Texture* m_gameRenderTexture;
};
} // namespace ia::iae

View File

@ -71,7 +71,7 @@ namespace ia::iae
VOID IView::PreRender()
{
m_extent = ImGui::GetWindowSize();
m_extent = ImGui::GetContentRegionAvail();
ImGui::BeginChild("##");
}

View File

@ -36,8 +36,5 @@ namespace ia::iae
{
OnEvent(event);
}
private:
class RDC_Texture* m_gamePreviewTexture;
};
} // namespace ia::iae