Skip to content

Commit

Permalink
[SUTK] Added close icon in tab button's close button
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Dec 12, 2024
1 parent 03be17b commit 3423538
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions sutk/include/sutk/NotebookView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace SUTK
DefaultButtonGraphic* m_graphic;
Button* m_closeButton;
ImageButtonGraphic* m_closeButtonGraphic;
static UIDriver::ImageReference s_closeIcon;
public:
TabView(UIDriver& driver, Container* parent) noexcept;
~TabView() noexcept;
Expand Down
5 changes: 5 additions & 0 deletions sutk/source/NotebookView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace SUTK
return m_tab->getIndex();
}

UIDriver::ImageReference TabView::s_closeIcon = UIDriver::InvalidImage;

TabView::TabView(UIDriver& driver, Container* parent) noexcept : Button(driver, parent, /* isCreateDefaultGraphic: */ true)
{
m_graphic = getGraphicAs<DefaultButtonGraphic>();
Expand All @@ -85,6 +87,9 @@ namespace SUTK
CLOSE_BUTTON_WIDTH, CLOSE_BUTTON_HEIGHT });
m_closeButton->getAnchorRect()->moveToRightMiddleOfParent();
m_closeButtonGraphic = driver.createContainer<ImageButtonGraphic>(m_closeButton);
if(!s_closeIcon)
s_closeIcon = driver.loadImage("svg_files/close-square-svgrepo-com.svg");
m_closeButtonGraphic->setImage(s_closeIcon);
}

TabView::~TabView() noexcept
Expand Down
11 changes: 9 additions & 2 deletions sutk/source/SGEGfxDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,17 +1014,22 @@ namespace SUTK
if(com::IsOdd(count))
{
minX = vertices[0].z;
maxX = minX;
minY = vertices[0].y;
maxY = minY;
i = 1;
}
else i = 0;
for(; i < count; i += 2)
{
// 3 Comparisons
auto minMax = com::GetMinMax(vertices[i].z, vertices[i + 1].z);
if(minX > minMax.first)
minX = minMax.first;
if(maxX < minMax.second)
maxX = minMax.second;

// 3 Comparisons
minMax = com::GetMinMax(vertices[i].y, vertices[i + 1].y);
if(minY > minMax.first)
minY = minMax.first;
Expand Down Expand Up @@ -1203,8 +1208,10 @@ namespace SUTK
if(geometry.isFillImageModified() || (meshData->isVectorImageApplied && isVertexDataModified))
{
UIDriver::ImageReference image = geometry.getFillImage();
SGE::Texture texture = getTexture(image, meshData);
material.set<SGE::Texture>("albedo", texture);
SGE::Texture texture = getTexture(image.getHandle(), meshData);
SGE::Texture prevTexture = material.get<SGE::Texture>("albedo");
if(prevTexture != texture)
material.set<SGE::Texture>("albedo", texture);
}

if(geometry.isVertexTexCoordArrayModified())
Expand Down
2 changes: 1 addition & 1 deletion sutk/source/SmallText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ namespace SUTK
}
void SmallText::setFont(UIDriver::FontReference font) noexcept
{
getGfxDriver().setTextFont(getGfxDriverObjectHandle(), font);
getGfxDriver().setTextFont(getGfxDriverObjectHandle(), font.getHandle());
redraw();
}
f32 SmallText::getBaselineHeight() noexcept
Expand Down
2 changes: 1 addition & 1 deletion sutk/source/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace SUTK

void Text::setFont(UIDriver::FontReference font) noexcept
{
getGfxDriver().setTextGroupFont(m_textGroup, font);
getGfxDriver().setTextGroupFont(m_textGroup, font.getHandle());
}

Vec2Df Text::getLocalPositionFromCursorPosition(const CursorPosition<LineCountType>& cursor) noexcept
Expand Down
6 changes: 3 additions & 3 deletions sutk/source/UIDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace SUTK

void UIDriver::unloadImage(ImageReference id) noexcept
{
getGfxDriver().unloadTexture(id);
getGfxDriver().unloadTexture(id.getHandle());
}

UIDriver::FontReference UIDriver::loadFont(std::string_view path) noexcept
Expand All @@ -176,13 +176,13 @@ namespace SUTK

void UIDriver::unloadFont(FontReference id) noexcept
{
getGfxDriver().unloadFont(id);
getGfxDriver().unloadFont(id.getHandle());
}

UIDriver::ImageAttributes UIDriver::getImageAttributes(ImageReference id) noexcept
{
TextureAttributes attr;
getGfxDriver().getTextureAttributes(id, attr);
getGfxDriver().getTextureAttributes(id.getHandle(), attr);
return attr;
}

Expand Down
24 changes: 24 additions & 0 deletions sutk/source/tests/LunaSVGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ namespace SUTK
size /= 1.2f;
renderRectContainer2->setSize(size);
}
else if((keycode == KeyCode::RightArrow) && ((event == KeyEvent::Press) || (event == KeyEvent::Repeat)))
{
auto pos = m_renderRectContainer->getPosition();
pos += Vec2Df::right() * 0.1f;
m_renderRectContainer->setPosition(pos);
}
else if((keycode == KeyCode::LeftArrow) && ((event == KeyEvent::Press) || (event == KeyEvent::Repeat)))
{
auto pos = m_renderRectContainer->getPosition();
pos += Vec2Df::left() * 0.1f;
m_renderRectContainer->setPosition(pos);
}
else if((keycode == KeyCode::UpArrow) && ((event == KeyEvent::Press) || (event == KeyEvent::Repeat)))
{
auto pos = m_renderRectContainer->getPosition();
pos += Vec2Df::up() * 0.5f;
m_renderRectContainer->setPosition(pos);
}
else if((keycode == KeyCode::DownArrow) && ((event == KeyEvent::Press) || (event == KeyEvent::Repeat)))
{
auto pos = m_renderRectContainer->getPosition();
pos += Vec2Df::down() * 0.5f;
m_renderRectContainer->setPosition(pos);
}
});
}

Expand Down

0 comments on commit 3423538

Please sign in to comment.