Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyPanda07 committed Aug 14, 2021
1 parent 3dac5d1 commit 868dfc8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace std;

namespace gui_framework
{
BaseWindow::drawedImages::drawedImages(unique_ptr<utility::BaseLoadableHolder>&& images, utility::BaseLoadableHolder::imageType type) noexcept :
BaseWindow::drawedImages::drawedImages(smartPointerType<utility::BaseLoadableHolder>&& images, utility::BaseLoadableHolder::imageType type) noexcept :
images(move(images)),
type(type)
{
Expand Down Expand Up @@ -50,16 +50,16 @@ namespace gui_framework

void BaseWindow::initDrawing(const string& pictureBlockName, uint16_t imagesWidth, uint16_t imagesHeight, utility::BaseLoadableHolder::imageType type)
{
unique_ptr<utility::BaseLoadableHolder> images;
smartPointerType<utility::BaseLoadableHolder> images;

switch (type)
{
case utility::BaseLoadableHolder::imageType::bitmap:
images = make_unique<utility::ImagesHolder>(imagesWidth, imagesHeight);
images = utility::make_smart_pointer<utility::ImagesHolder>(imagesWidth, imagesHeight);

break;
case utility::BaseLoadableHolder::imageType::icon:
images = make_unique<utility::IconsHolder>(imagesWidth, imagesHeight);
images = utility::make_smart_pointer<utility::IconsHolder>(imagesWidth, imagesHeight);

break;
case utility::BaseLoadableHolder::imageType::cursor:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace gui_framework
private:
struct drawedImages
{
std::unique_ptr<utility::BaseLoadableHolder> images;
smartPointerType<utility::BaseLoadableHolder> images;
std::unordered_map<uint16_t, std::pair<int, int>> coordinates;
utility::BaseLoadableHolder::imageType type;

drawedImages(std::unique_ptr<utility::BaseLoadableHolder>&& images, utility::BaseLoadableHolder::imageType type) noexcept;
drawedImages(smartPointerType<utility::BaseLoadableHolder>&& images, utility::BaseLoadableHolder::imageType type) noexcept;

void addImage(BaseWindow* owner, int x, int y, const std::filesystem::path& pathToImage);

Expand Down
2 changes: 1 addition & 1 deletion GUIFramework/src/GUIFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ namespace gui_framework
return result;
}

const unordered_map<size_t, unique_ptr<utility::BaseComponentCreator>>& GUIFramework::getCreators() const
const unordered_map<size_t, smartPointerType<utility::BaseComponentCreator>>& GUIFramework::getCreators() const
{
return creators;
}
Expand Down
6 changes: 3 additions & 3 deletions GUIFramework/src/GUIFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace gui_framework
INITCOMMONCONTROLSEX comm;
std::unordered_map<std::string, HMODULE> modules;
std::unordered_map<std::string, std::string> modulesPaths;
std::unordered_map<size_t, std::unique_ptr<utility::BaseComponentCreator>> creators;
std::unordered_map<size_t, smartPointerType<utility::BaseComponentCreator>> creators;
#pragma region Ids
std::unordered_multimap<std::wstring, uint32_t> generatedIds;
std::queue<uint32_t> availableIds;
Expand Down Expand Up @@ -173,7 +173,7 @@ namespace gui_framework

/// @brief Get all current registered creators
/// @return creators
const std::unordered_map<size_t, std::unique_ptr<utility::BaseComponentCreator>>& getCreators() const;
const std::unordered_map<size_t, smartPointerType<utility::BaseComponentCreator>>& getCreators() const;

/// @brief Get settings from gui_framework.json
/// @return jsonSettings
Expand Down Expand Up @@ -211,6 +211,6 @@ namespace gui_framework
template<std::derived_from<BaseComponent> T, std::derived_from<utility::BaseComponentCreator> CreatorT, typename... Args>
void GUIFramework::addCreator(Args&&... args)
{
creators[typeid(T).hash_code()] = std::unique_ptr<CreatorT>(new CreatorT(std::forward<Args>(args)...));
creators[typeid(T).hash_code()] = smartPointerType<CreatorT>(new CreatorT(std::forward<Args>(args)...));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ namespace gui_framework
type(type),
data(move(data))
{

}

BaseLoadableHolder::imageData::imageData(const imageData& other) :
index(other.index),
type(other.type),
data(other.data)
{
const_cast<imageData&>(other).data.reset();
}

BaseLoadableHolder::imageData::imageData(imageData&& other) noexcept :
Expand All @@ -23,6 +31,17 @@ namespace gui_framework
other.data.reset();
}

BaseLoadableHolder::imageData& BaseLoadableHolder::imageData::operator = (const imageData& other)
{
index = other.index;
type = other.type;
data = other.data;

const_cast<imageData&>(other).data.reset();

return *this;
}

BaseLoadableHolder::imageData& BaseLoadableHolder::imageData::operator = (imageData&& other) noexcept
{
index = other.index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ namespace gui_framework

imageData(uint16_t index, imageType type, std::any&& data);

imageData(const imageData& other) = delete;
imageData(const imageData& other);

imageData(imageData&& other) noexcept;

imageData& operator = (const imageData& other) = delete;
imageData& operator = (const imageData& other);

imageData& operator = (imageData&& other) noexcept;

Expand Down

0 comments on commit 868dfc8

Please sign in to comment.