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

@ -20,7 +20,9 @@ namespace ia::iae
{
INT32 g_tabContainerCount{0};
TabContainer::TabContainer() : m_containerID(BuildString("TabContainer##", g_tabContainerCount++)), m_tabBarID(BuildString("TabBar##", g_tabContainerCount++))
TabContainer::TabContainer()
: m_containerID(BuildString("TabContainer##", g_tabContainerCount++)),
m_tabBarID(BuildString("TabBar##", g_tabContainerCount++))
{
}
@ -52,9 +54,10 @@ namespace ia::iae
m_pendingActiveTabName = nullptr;
}
if (ImGui::BeginTabItem(v->Value->IconAndName().c_str(), nullptr, flags))
BOOL* isOpen = v->Value.IsCloseable ? &v->Value.IsOpen : nullptr;
if (ImGui::BeginTabItem(v->Value.View->IconAndName().c_str(), isOpen, flags))
{
v->Value->Render();
v->Value.View->Render();
ImGui::EndTabItem();
m_activeTabName = v->Key.c_str();
@ -68,20 +71,20 @@ namespace ia::iae
VOID TabContainer::Update()
{
for (const auto &t : m_tabViews)
t->Value->Update();
t->Value.View->Update();
}
VOID TabContainer::ProcessEvent(IN SDL_Event *event)
{
for (const auto &t : m_tabViews)
t->Value->ProcessEvent(event);
t->Value.View->ProcessEvent(event);
}
VOID TabContainer::AddTab(IN CONST String &name, IN IView *view)
VOID TabContainer::AddTab(IN CONST String &name, IN IView *view, IN BOOL isCloseable)
{
RemoveTab(name);
view->Initialize();
m_tabViews[name] = view;
m_tabViews[name] = Tab{.View = view, .IsCloseable = isCloseable};
if (!m_activeTabName)
m_activeTabName = name.c_str();
}
@ -90,10 +93,25 @@ namespace ia::iae
{
if (!m_tabViews.contains(name))
return;
if (m_tabViews[name])
m_tabViews[name]->Terminate();
delete m_tabViews[name];
m_tabViews[name] = nullptr;
m_tabViews[name].IsOpen = false;
if (m_tabViews[name].View)
m_tabViews[name].View->Terminate();
delete m_tabViews[name].View;
m_tabViews[name] = {};
}
VOID TabContainer::OpenTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
m_tabViews[name].IsOpen = true;
}
VOID TabContainer::CloseTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
m_tabViews[name].IsOpen = false;
}
VOID TabContainer::ChangeActiveTab(IN PCCHAR name)
@ -103,6 +121,6 @@ namespace ia::iae
IView *TabContainer::GetTab(IN CONST String &name)
{
return m_tabViews[name];
return m_tabViews[name].View;
}
} // namespace ia::iae