diff --git a/src/cpp/re/edit/AppContext.cpp b/src/cpp/re/edit/AppContext.cpp index d9f342e..aec2ad0 100644 --- a/src/cpp/re/edit/AppContext.cpp +++ b/src/cpp/re/edit/AppContext.cpp @@ -491,124 +491,6 @@ void AppContext::toggleRails() } } -//------------------------------------------------------------------------ -// AppContext::TextureItem -//------------------------------------------------------------------------ -void AppContext::TextureItem(Texture const *iTexture, - ImVec2 const &iPosition, - ImVec2 const &iSize, - int iFrameNumber, - ImU32 iBorderColor, - ImU32 iTextureColor) const -{ - iTexture->Item(iPosition, iSize, getZoom(), iFrameNumber, iBorderColor, iTextureColor); -} - -//------------------------------------------------------------------------ -// AppContext::drawTexture -//------------------------------------------------------------------------ -void AppContext::drawTexture(Texture const *iTexture, - ImVec2 const &iPosition, - int iFrameNumber, - ImU32 iBorderColor, - ImU32 iTextureColor) const -{ - iTexture->draw(iPosition, getZoom(), iFrameNumber, iBorderColor, iTextureColor); -} - -//------------------------------------------------------------------------ -// AppContext::drawRect -//------------------------------------------------------------------------ -void AppContext::drawRect(ImVec2 const &iPosition, ImVec2 const &iSize, ImU32 iColor) const -{ - auto const cp = ImGui::GetCursorScreenPos(); - ImVec2 pos(cp + iPosition * getZoom()); - auto drawList = ImGui::GetWindowDrawList(); - drawList->AddRect(pos, {pos.x + (iSize.x * getZoom()), pos.y + (iSize.y * getZoom())}, iColor); -} - -//------------------------------------------------------------------------ -// AppContext::RectFilledItem -//------------------------------------------------------------------------ -void AppContext::RectFilledItem(ImVec2 const &iPosition, - ImVec2 const &iSize, - ImU32 iColor, - float iRounding, - ImDrawFlags iFlags) const -{ - auto const cp = ImGui::GetCursorScreenPos() + iPosition * getZoom(); - - const ImRect rect{cp, cp + iSize * getZoom()}; - - ImGui::ItemSize(rect); - if(!ImGui::ItemAdd(rect, 0)) - return; - - ImGui::SetCursorScreenPos(cp); - auto drawList = ImGui::GetWindowDrawList(); - drawList->AddRectFilled(cp, {cp.x + (iSize.x * getZoom()), cp.y + (iSize.y * getZoom())}, iColor, iRounding, iFlags); -} - -//------------------------------------------------------------------------ -// AppContext::RectItem -//------------------------------------------------------------------------ -void AppContext::RectItem(ImVec2 const &iPosition, - ImVec2 const &iSize, - ImU32 iColor, - float iRounding, - ImDrawFlags iFlags) const -{ - auto const cp = ImGui::GetCursorScreenPos() + iPosition * getZoom(); - - const ImRect rect{cp, cp + iSize * getZoom()}; - - ImGui::ItemSize(rect); - if(!ImGui::ItemAdd(rect, 0)) - return; - - ImGui::SetCursorScreenPos(cp); - auto drawList = ImGui::GetWindowDrawList(); - drawList->AddRect(cp, {cp.x + (iSize.x * getZoom()), cp.y + (iSize.y * getZoom())}, iColor, iRounding, iFlags); -} - -//------------------------------------------------------------------------ -// AppContext::Dummy -//------------------------------------------------------------------------ -void AppContext::Dummy(ImVec2 const &iPosition, ImVec2 const &iSize) const -{ - auto const cp = ImGui::GetCursorScreenPos() + iPosition * getZoom(); - const ImRect rect{cp, cp + iSize * getZoom()}; - ImGui::SetCursorScreenPos(cp); - ImGui::ItemSize(rect); - ImGui::ItemAdd(rect, 0); -} - - -//------------------------------------------------------------------------ -// AppContext::drawRectFilled -//------------------------------------------------------------------------ -void AppContext::drawRectFilled(ImVec2 const &iPosition, - ImVec2 const &iSize, - ImU32 iColor, - float iRounding, - ImDrawFlags iFlags) const -{ - auto const cp = ImGui::GetCursorScreenPos(); - ImVec2 pos(cp + iPosition * getZoom()); - auto drawList = ImGui::GetWindowDrawList(); - drawList->AddRectFilled(pos, {pos.x + (iSize.x * getZoom()), pos.y + (iSize.y * getZoom())}, iColor, iRounding, iFlags); -} - -//------------------------------------------------------------------------ -// AppContext::drawLine -//------------------------------------------------------------------------ -void AppContext::drawLine(const ImVec2& iP1, const ImVec2& iP2, ImU32 iColor, float iThickness) const -{ - auto const cp = ImGui::GetCursorScreenPos(); - auto drawList = ImGui::GetWindowDrawList(); - drawList->AddLine(cp + iP1 * getZoom(), cp + iP2 * getZoom(), iColor, iThickness); -} - //------------------------------------------------------------------------ // AppContext::addUndoAction //------------------------------------------------------------------------ diff --git a/src/cpp/re/edit/AppContext.h b/src/cpp/re/edit/AppContext.h index b96dbba..6257219 100644 --- a/src/cpp/re/edit/AppContext.h +++ b/src/cpp/re/edit/AppContext.h @@ -151,26 +151,6 @@ class AppContext std::optional importTextureBlocking(); std::size_t importTexturesBlocking(); - void TextureItem(Texture const *iTexture, - ImVec2 const &iPosition = {0,0}, - ImVec2 const &iSize = {0,0}, - int iFrameNumber = 0, - ImU32 iBorderColor = ReGui::kTransparentColorU32, - ImU32 iTextureColor = ReGui::kWhiteColorU32) const; - - void drawTexture(Texture const *iTexture, - ImVec2 const &iPosition = {0,0}, - int iFrameNumber = 0, - ImU32 iBorderColor = ReGui::kTransparentColorU32, - ImU32 iTextureColor = ReGui::kWhiteColorU32) const; - - void drawRect(ImVec2 const &iPosition, ImVec2 const &iSize, ImU32 iColor) const; - void RectFilledItem(ImVec2 const &iPosition, ImVec2 const &iSize, ImU32 iColor, float iRounding = 0.0f, ImDrawFlags iFlags = 0) const; - void RectItem(ImVec2 const &iPosition, ImVec2 const &iSize, ImU32 iColor, float iRounding = 0.0f, ImDrawFlags iFlags = 0) const; - void drawRectFilled(ImVec2 const &iPosition, ImVec2 const &iSize, ImU32 iColor, float iRounding = 0.0f, ImDrawFlags iFlags = 0) const; - void drawLine(const ImVec2& iP1, const ImVec2& iP2, ImU32 iColor, float iThickness = 1.0f) const; - void Dummy(ImVec2 const &iPosition, ImVec2 const &iSize) const; - public: // Undo constexpr bool isUndoEnabled() const { return fUndoManager->isEnabled(); } constexpr void enableUndo() { fUndoManager->enable(); } diff --git a/src/cpp/re/edit/Application.cpp b/src/cpp/re/edit/Application.cpp index 82ca2ed..7bc8e85 100644 --- a/src/cpp/re/edit/Application.cpp +++ b/src/cpp/re/edit/Application.cpp @@ -809,7 +809,7 @@ void Application::renderLogoBox(float iPadding) ReGui::Box(logoModifier, [this, textSizeHeight, newVersion]() { auto logo = getLogo(); auto computedHeight = 2.0f * textSizeHeight + (ImGui::GetStyle().ItemSpacing.y); - logo->Item({}, {computedHeight, computedHeight}); + logo->Item({computedHeight, computedHeight}); ImGui::SameLine(); @@ -932,7 +932,7 @@ void Application::renderWelcome() ImGui::BeginGroup(); { ImGui::AlignTextToFramePadding(); - icon->Item({}, {buttonHeight, buttonHeight}, 1.0f, impl::getFrameNumberFromDeviceType(item.fType)); + icon->Item({buttonHeight, buttonHeight}, impl::getFrameNumberFromDeviceType(item.fType)); ImGui::SameLine(); if(ImGui::Button(fmt::printf("%s\n%s", item.fName, item.fPath).c_str())) loadProjectDeferred(fs::path(item.fPath)); diff --git a/src/cpp/re/edit/Texture.h b/src/cpp/re/edit/Texture.h index ace421b..d534c74 100644 --- a/src/cpp/re/edit/Texture.h +++ b/src/cpp/re/edit/Texture.h @@ -67,37 +67,16 @@ class Texture std::shared_ptr getFilmStrip() const { return fFilmStrip; } - inline void Item(ImVec2 const &iPosition, - ImVec2 const &iSize = {}, - float iZoom = 1.0f, + inline void Item(ImVec2 const &iSize = {}, int iFrameNumber = 0, ImU32 iBorderColor = ReGui::kTransparentColorU32, ImU32 iTextureColor = ReGui::kWhiteColorU32) const { - doDraw(true, iPosition, iSize, iZoom, iZoom, iFrameNumber, iBorderColor, iTextureColor); - } - - inline void draw(ImVec2 const &iPosition, - float iZoom, - int iFrameNumber, - ImU32 iBorderColor = ReGui::kTransparentColorU32, - ImU32 iTextureColor = ReGui::kWhiteColorU32) const - { - doDraw(false, iPosition, {}, iZoom, iZoom, iFrameNumber, iBorderColor, iTextureColor); - } - - inline void draw(ImVec2 const &iPosition, - float iPositionZoom, - float iTextureZoom, - int iFrameNumber, - ImU32 iBorderColor = ReGui::kTransparentColorU32, - ImU32 iTextureColor = ReGui::kWhiteColorU32) const - { - doDraw(false, iPosition, {}, iPositionZoom, iTextureZoom, iFrameNumber, iBorderColor, iTextureColor); + doDraw(true, ImGui::GetCursorScreenPos(), iSize, iFrameNumber, iBorderColor, iTextureColor); } inline void draw(ImVec2 const &iScreenPosition, - ImVec2 const &iSize, + ImVec2 const &iSize = {}, int iFrameNumber = 0, ImU32 iBorderColor = ReGui::kTransparentColorU32, ImU32 iTextureColor = ReGui::kWhiteColorU32) const @@ -111,15 +90,6 @@ class Texture friend class TextureManager; protected: - void doDraw(bool iAddItem, - ImVec2 const &iPosition, - ImVec2 const &iSize, - float iPositionZoom, - float iTextureZoom, - int iFrameNumber, - ImU32 iBorderColor, - ImU32 iTextureColor) const; - void doDraw(bool iAddItem, ImVec2 const &iScreenPosition, ImVec2 const &iSize, diff --git a/src/cpp/re/edit/TextureManager.cpp b/src/cpp/re/edit/TextureManager.cpp index 9ac4c47..45d3308 100644 --- a/src/cpp/re/edit/TextureManager.cpp +++ b/src/cpp/re/edit/TextureManager.cpp @@ -156,27 +156,6 @@ void TextureManager::overrideNumFrames(std::string const &iKey, int iNumFrames) getTexture(iKey)->fFilmStrip->overrideNumFrames(iNumFrames); } - -//------------------------------------------------------------------------ -// Texture::doDraw -//------------------------------------------------------------------------ -void Texture::doDraw(bool iAddItem, - ImVec2 const &iPosition, - ImVec2 const &iSize, - float iPositionZoom, - float iTextureZoom, - int iFrameNumber, - ImU32 iBorderColor, - ImU32 iTextureColor) const -{ - if(fData.empty()) - return; - auto const cp = ImGui::GetCursorScreenPos() + iPosition * iPositionZoom; - auto const size = ImVec2{(iSize.x == 0 ? frameWidth() : iSize.x) * iTextureZoom, - (iSize.y == 0 ? frameHeight() : iSize.y) * iTextureZoom}; - doDraw(iAddItem, cp, size, iFrameNumber, iBorderColor, iTextureColor); -} - //------------------------------------------------------------------------ // Texture::doDraw //------------------------------------------------------------------------ @@ -190,7 +169,9 @@ void Texture::doDraw(bool iAddItem, if(fData.empty()) return; - const ImRect rect{iScreenPosition, iScreenPosition + iSize}; + auto const size = ImVec2{iSize.x == 0 ? frameWidth() : iSize.x, iSize.y == 0 ? frameHeight() : iSize.y}; + + const ImRect rect{iScreenPosition, iScreenPosition + size}; // do we treat the texture as a ImGui item (clickable, etc...) if(iAddItem)