Skip to content

Commit

Permalink
Refactor, added clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyPanda07 committed Jul 17, 2021
1 parent c86c445 commit 35b2972
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 32 deletions.
20 changes: 10 additions & 10 deletions GUIFramework/GUIFramework.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@
<ClInclude Include="src\Styles\Composites\DialogBoxStyles.h" />
<ClInclude Include="src\Styles\Composites\SeparateWindowStyles.h" />
<ClInclude Include="src\Styles\DefaultStyles.h" />
<ClInclude Include="src\Utility\Holders\BaseLoadableHolder.h" />
<ClInclude Include="src\Utility\Holders\CursorsHolder.h" />
<ClInclude Include="src\Utility\Holders\IconsHolder.h" />
<ClInclude Include="src\Utility\Holders\ImagesHolder.h" />
<ClInclude Include="src\Utility\Holders\LoadableHolders\BaseLoadableHolder.h" />
<ClInclude Include="src\Utility\Holders\LoadableHolders\CursorsHolder.h" />
<ClInclude Include="src\Utility\Holders\LoadableHolders\IconsHolder.h" />
<ClInclude Include="src\Utility\Holders\LoadableHolders\ImagesHolder.h" />
<ClInclude Include="src\Interfaces\Components\IResizableComponent.h" />
<ClInclude Include="src\Interfaces\Components\ITextOperations.h" />
<ClInclude Include="src\Interfaces\Iterators\IBaseConstForwardIterator.h" />
Expand All @@ -181,7 +181,7 @@
<ClInclude Include="src\Utility\ComponentSettings.h" />
<ClInclude Include="src\Utility\Paint\DrawImage.h" />
<ClInclude Include="src\Utility\Utility.h" />
<ClInclude Include="src\WindowHolder.h" />
<ClInclude Include="src\Utility\Holders\WindowHolder.h" />
<ClInclude Include="src\WindowMessages.h" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -316,10 +316,10 @@
<ClCompile Include="src\Styles\Composites\DialogBoxStyles.cpp" />
<ClCompile Include="src\Styles\Composites\SeparateWindowStyles.cpp" />
<ClCompile Include="src\Styles\DefaultStyles.cpp" />
<ClCompile Include="src\Utility\Holders\BaseLoadableHolder.cpp" />
<ClCompile Include="src\Utility\Holders\CursorsHolder.cpp" />
<ClCompile Include="src\Utility\Holders\IconsHolder.cpp" />
<ClCompile Include="src\Utility\Holders\ImagesHolder.cpp" />
<ClCompile Include="src\Utility\Holders\LoadableHolders\BaseLoadableHolder.cpp" />
<ClCompile Include="src\Utility\Holders\LoadableHolders\CursorsHolder.cpp" />
<ClCompile Include="src\Utility\Holders\LoadableHolders\IconsHolder.cpp" />
<ClCompile Include="src\Utility\Holders\LoadableHolders\ImagesHolder.cpp" />
<ClCompile Include="src\Interfaces\Components\IResizableComponent.cpp" />
<ClCompile Include="src\Interfaces\Components\ITextOperations.cpp" />
<ClCompile Include="src\Interfaces\Menu\IMenuItem.cpp" />
Expand All @@ -332,7 +332,7 @@
<ClCompile Include="src\Utility\ComponentSettings.cpp" />
<ClCompile Include="src\Utility\Paint\DrawImage.cpp" />
<ClCompile Include="src\Utility\Utility.cpp" />
<ClCompile Include="src\WindowHolder.cpp" />
<ClCompile Include="src\Utility\Holders\WindowHolder.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="GUIFrameworkMacros.props" />
Expand Down
20 changes: 10 additions & 10 deletions GUIFramework/GUIFramework.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
<ClInclude Include="src\BaseComponents\Creators\TabControlCreator.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\WindowHolder.h">
<ClInclude Include="src\Utility\Holders\WindowHolder.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Exceptions\NotImplemented.h">
Expand All @@ -249,7 +249,7 @@
<ClInclude Include="src\BaseComponents\StandardComponents\ListViews\BaseListView.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Utility\Holders\ImagesHolder.h">
<ClInclude Include="src\Utility\Holders\LoadableHolders\ImagesHolder.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\BaseComponents\StandardComponents\ListViews\BaseTextListView.h">
Expand Down Expand Up @@ -285,13 +285,13 @@
<ClInclude Include="src\BaseComponents\StandardComponents\ListViews\BaseListTextIconListView.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Utility\Holders\BaseLoadableHolder.h">
<ClInclude Include="src\Utility\Holders\LoadableHolders\BaseLoadableHolder.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Utility\Holders\IconsHolder.h">
<ClInclude Include="src\Utility\Holders\LoadableHolders\IconsHolder.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Utility\Holders\CursorsHolder.h">
<ClInclude Include="src\Utility\Holders\LoadableHolders\CursorsHolder.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="src\Components\ListViews\IconListView.h">
Expand Down Expand Up @@ -686,7 +686,7 @@
<ClCompile Include="src\BaseComponents\Creators\TabControlCreator.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\WindowHolder.cpp">
<ClCompile Include="src\Utility\Holders\WindowHolder.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Exceptions\NotImplemented.cpp">
Expand All @@ -695,7 +695,7 @@
<ClCompile Include="src\BaseComponents\StandardComponents\ListViews\BaseListView.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Utility\Holders\ImagesHolder.cpp">
<ClCompile Include="src\Utility\Holders\LoadableHolders\ImagesHolder.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\BaseComponents\StandardComponents\ListViews\BaseTextListView.cpp">
Expand Down Expand Up @@ -731,13 +731,13 @@
<ClCompile Include="src\BaseComponents\StandardComponents\ListViews\BaseListTextIconListView.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Utility\Holders\BaseLoadableHolder.cpp">
<ClCompile Include="src\Utility\Holders\LoadableHolders\BaseLoadableHolder.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Utility\Holders\IconsHolder.cpp">
<ClCompile Include="src\Utility\Holders\LoadableHolders\IconsHolder.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Utility\Holders\CursorsHolder.cpp">
<ClCompile Include="src\Utility\Holders\LoadableHolders\CursorsHolder.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="src\Components\ListViews\IconListView.cpp">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "BaseComponents/BaseComponent.h"
#include "Utility/Holders/ImagesHolder.h"
#include "Utility/Holders/LoadableHolders/ImagesHolder.h"

namespace gui_framework
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "IBaseListViewOperations.h"
#include "Utility/Holders/IconsHolder.h"
#include "Utility/Holders/LoadableHolders/IconsHolder.h"

namespace gui_framework
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "IBaseListViewOperations.h"
#include "Utility/Holders/IconsHolder.h"
#include "Utility/Holders/LoadableHolders/IconsHolder.h"

namespace gui_framework
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ using namespace std;

namespace gui_framework
{
WindowHolder::WindowHolder(unique_ptr<BaseComposite>&& compositeWindow) noexcept :
compositeWindow(move(compositeWindow))
WindowHolder::WindowHolder(unique_ptr<BaseComposite>&& compositeWindow, bool unregisterClass) noexcept :
compositeWindow(move(compositeWindow)),
unregisterClass(unregisterClass)
{

}
Expand All @@ -23,7 +24,7 @@ namespace gui_framework
return compositeWindow.get();
}

void WindowHolder::runMainLoop()
void WindowHolder::runMainLoop(const vector<uint32_t>& registeredHotkeyIds)
{
MSG message = {};
int code;
Expand All @@ -40,9 +41,24 @@ namespace gui_framework
DispatchMessageW(&message);
}

GUIFramework& instance = GUIFramework::get();

for (const auto& i : registeredHotkeyIds)
{
instance.unregisterHotkey(i);
}

if (code == -1)
{
throw exceptions::GetLastErrorException(code);
}
}

WindowHolder::~WindowHolder()
{
if (unregisterClass)
{
utility::unregisterClass(compositeWindow->getClassName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ namespace gui_framework
{
private:
std::unique_ptr<BaseComposite> compositeWindow;
bool unregisterClass;

public:
WindowHolder(std::unique_ptr<BaseComposite>&& compositeWindow) noexcept;
/// @brief
/// @param compositeWindow
/// @param clearClass Unregister class after window destroy
WindowHolder(std::unique_ptr<BaseComposite>&& compositeWindow, bool unregisterClass = false) noexcept;

template<std::derived_from<BaseComposite> T>
T* getDerived();
Expand All @@ -23,11 +27,12 @@ namespace gui_framework

const BaseComposite* get() const;

/// @brief
/// @exception GetLastErrorException
void runMainLoop();
/// @brief Process messages. Must be called after initialization
/// @param registeredHotkeyIds You may pass all registered hotkeys for unregister them after window destroy
/// @exception GetLastErrorException
void runMainLoop(const std::vector<uint32_t>& registeredHotkeyIds = {});

~WindowHolder() = default;
~WindowHolder();
};

template<std::derived_from<BaseComposite> T>
Expand Down
2 changes: 1 addition & 1 deletion GUIFramework/src/Utility/Paint/DrawImage.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Utility/Holders/BaseLoadableHolder.h"
#include "Utility/Holders/LoadableHolders/BaseLoadableHolder.h"
#include "BaseComposites/StandardComposites/BaseWindow.h"

namespace gui_framework
Expand Down

0 comments on commit 35b2972

Please sign in to comment.