Skip to content

Commit

Permalink
Removed restriction of needing image in order to use ImageCanvas, etc...
Browse files Browse the repository at this point in the history
Removed restriction of needing image in order to use ImageCanvas,
Added logic for deleting scrollbars if they got unset,
Fixed degree mode is not working properly
  • Loading branch information
Neko-Box-Coder committed Apr 20, 2023
1 parent 4cbbcb8 commit 595b030
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
12 changes: 8 additions & 4 deletions Include/ssGUI/GUIObjectClasses/CompositeClasses/ImageCanvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,23 @@ namespace ssGUI
virtual bool IsShowVerticalScrollbar() const;

//function: SetHorizontalScrollbar
//Sets the horizontal scrollbar object used by ImageCanvas
//Sets the horizontal scrollbar object used by ImageCanvas.
//Pass in nullptr for unsetting (and deleting) the horizontal scrollbar.
virtual void SetHorizontalScrollbar(ssGUI::Scrollbar* scrollbar);

//function: GetHorizontalScrollbar
//Gets the horizontal scrollbar object used by ImageCanvas
//Gets the horizontal scrollbar object used by ImageCanvas.
//Nullptr if horizontal scrollbar is unset.
virtual ssGUI::Scrollbar* GetHorizontalScrollbar() const;

//function: SetVerticalScrollbar
//Sets the vertical scrollbar object used by ImageCanvas
//Sets the vertical scrollbar object used by ImageCanvas.
//Pass in nullptr for unsetting (and deleting) the vertical scrollbar.
virtual void SetVerticalScrollbar(ssGUI::Scrollbar* scrollbar);

//function: GetVerticalScrollbar
//Gets the vertical scrollbar object used by ImageCanvas
//Gets the vertical scrollbar object used by ImageCanvas.
//Nullptr if vertical scrollbar is unset.
virtual ssGUI::Scrollbar* GetVerticalScrollbar() const;

//====================================================================
Expand Down
32 changes: 16 additions & 16 deletions Src/ssGUI/GUIObjectClasses/CompositeClasses/ImageCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,6 @@ namespace ssGUI
currentMousePos.x <= GetGlobalPosition().x + GetSize().x &&
currentMousePos.y <= GetGlobalPosition().y + GetSize().y;

if(GetImageData() == nullptr)
{
if(mouseWithinWidget)
inputStatus.MouseInputBlockedObject = this;

return;
}

if(!inputInterface->GetCurrentMouseButton(ssGUI::Enums::MouseButton::LEFT))
MousePressed = false;

Expand Down Expand Up @@ -554,14 +546,14 @@ namespace ssGUI

void ImageCanvas::SetViewportRotation(float rotation, bool radians)
{
constexpr float degreeConversion = (pi() / 180);
constexpr float degreeConversion = (180 / pi());
CurrentRotation = radians ? rotation : degreeConversion * rotation;
RedrawObject();
}

float ImageCanvas::GetViewportRotation(bool radians) const
{
constexpr float degreeConversion = (pi() / 180);
constexpr float degreeConversion = (180 / pi());
return radians ? CurrentRotation : degreeConversion * CurrentRotation;
}

Expand Down Expand Up @@ -598,9 +590,6 @@ namespace ssGUI

glm::vec2 ImageCanvas::GetUVFromGlobalPosition(glm::vec2 globalPos)
{
if(GetImageData() == nullptr)
return glm::vec2();

//Transform global position to local position
globalPos -= GetGlobalPosition();

Expand All @@ -622,9 +611,6 @@ namespace ssGUI

glm::vec2 ImageCanvas::GetGlobalPositionFromUV(glm::vec2 uv)
{
if(GetImageData() == nullptr)
return glm::vec2();

//Canvas Position
uv -= GetViewportCenterPosition();

Expand Down Expand Up @@ -753,7 +739,14 @@ namespace ssGUI
void ImageCanvas::SetHorizontalScrollbar(ssGUI::Scrollbar* scrollbar)
{
if(scrollbar == nullptr)
{
if(GetHorizontalScrollbar() != nullptr)
GetHorizontalScrollbar()->Delete();

SetShowHorizontalScrollbar(false);
HorizontalScrollbar = -1;
return;
}

HorizontalScrollbar = CurrentObjectsReferences.AddObjectReference(scrollbar);

Expand All @@ -770,7 +763,14 @@ namespace ssGUI
void ImageCanvas::SetVerticalScrollbar(ssGUI::Scrollbar* scrollbar)
{
if(scrollbar == nullptr)
{
if(GetVerticalScrollbar() != nullptr)
GetVerticalScrollbar()->Delete();

SetShowVerticalScrollbar(false);
VerticalScrollbar = -1;
return;
}

VerticalScrollbar = CurrentObjectsReferences.AddObjectReference(scrollbar);

Expand Down

0 comments on commit 595b030

Please sign in to comment.