Skip to content

Commit af40a06

Browse files
committed
Added RoundedBorderRadius property to Tabs renderer (#263)
1 parent 0e78638 commit af40a06

File tree

19 files changed

+93
-46
lines changed

19 files changed

+93
-46
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TGUI 1.11 (TBD)
22
----------------
33

4-
- Added RoundedBorderRadius property to EditBox and ComboBox renderers
4+
- Added RoundedBorderRadius property to EditBox, ComboBox and Tabs renderers
55
- Added getLeftPlusRight and getTopPlusBottom functions to Outline class
66
- Added `TGUI_BUILD_CXX20_MODULE` option to CMake to build TGUI as a c++20 module
77

gui-builder/include/WidgetProperties/TabsProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct TabsProperties : WidgetProperties
100100
pair.second["TextureSelectedTabHover"] = {"Texture", tgui::Serializer::serialize(renderer->getTextureSelectedTabHover())};
101101
pair.second["TextureDisabledTab"] = {"Texture", tgui::Serializer::serialize(renderer->getTextureDisabledTab())};
102102
pair.second["DistanceToSide"] = {"Float", tgui::String::fromNumber(renderer->getDistanceToSide())};
103+
pair.second["RoundedBorderRadius"] = {"Float", tgui::String::fromNumber(renderer->getRoundedBorderRadius())};
103104
return pair;
104105
}
105106
};

include/TGUI/Renderers/TabsRenderer.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,23 @@ namespace tgui
329329
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
330330
TGUI_NODISCARD float getDistanceToSide() const;
331331

332+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
333+
/// @brief Changes the radius for the rounded corners if you want to draw a rounded rectangle as background for each tab
334+
/// @param radius Radius of the corners
335+
///
336+
/// @warning This property is ignored when textures are used as background
337+
///
338+
/// @since TGUI 1.11
339+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
340+
void setRoundedBorderRadius(float radius);
341+
342+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
343+
/// @brief Returns the radius for the rounded corners if you want to draw a rounded rectangle as background for each tab
344+
/// @return Radius of the corners
345+
/// @since TGUI 1.11
346+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
347+
TGUI_NODISCARD float getRoundedBorderRadius() const;
348+
332349
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
333350
};
334351

include/TGUI/Widgets/Tabs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ namespace tgui
464464
Color m_selectedTextColorCached;
465465
Color m_selectedTextColorHoverCached;
466466
float m_distanceToSideCached = 0;
467+
float m_roundedBorderRadiusCached = 0;
467468

468469
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
469470
};

src/Renderers/TabsRenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace tgui
5353
TGUI_RENDERER_PROPERTY_TEXTURE(TabsRenderer, TextureDisabledTab)
5454

5555
TGUI_RENDERER_PROPERTY_NUMBER(TabsRenderer, DistanceToSide, 0)
56+
TGUI_RENDERER_PROPERTY_NUMBER(TabsRenderer, RoundedBorderRadius, 0)
5657
}
5758

5859
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

src/Widgets/CheckBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ namespace tgui
241241
if (m_bordersCached != Borders{0})
242242
target.drawBorders(states, m_bordersCached, getSize(), Color::applyOpacity(getCurrentBorderColor(), m_opacityCached));
243243

244-
states.transform.translate({m_bordersCached.getLeft(), m_bordersCached.getTop()});
244+
states.transform.translate(m_bordersCached.getOffset());
245245
if (!m_checked && m_spriteUnchecked.isSet())
246246
{
247247
if (!m_enabled && m_spriteUncheckedDisabled.isSet())

src/Widgets/ChildWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ namespace tgui
14571457
else
14581458
target.drawBorders(states, m_bordersCached, getSize(), Color::applyOpacity(m_borderColorCached, m_opacityCached));
14591459

1460-
states.transform.translate({m_bordersCached.getLeft(), m_bordersCached.getTop()});
1460+
states.transform.translate(m_bordersCached.getOffset());
14611461
}
14621462

14631463
// Draw the title bar

src/Widgets/ComboBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ namespace tgui
10761076
{
10771077
target.drawRoundedRectangle(states, getSize(), Color::applyOpacity(backgroundColor, m_opacityCached),
10781078
m_roundedBorderRadiusCached, m_bordersCached, Color::applyOpacity(m_borderColorCached, m_opacityCached));
1079-
states.transform.translate({m_bordersCached.getLeft(), m_bordersCached.getTop()});
1079+
states.transform.translate(m_bordersCached.getOffset());
10801080
}
10811081
else
10821082
{

src/Widgets/EditBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ TGUI_IGNORE_DEPRECATED_WARNINGS_END
16121612
{
16131613
target.drawRoundedRectangle(states, getSize(), Color::applyOpacity(backgroundColor, m_opacityCached),
16141614
m_roundedBorderRadiusCached, m_bordersCached, Color::applyOpacity(borderColor, m_opacityCached));
1615-
states.transform.translate({m_bordersCached.getLeft(), m_bordersCached.getTop()});
1615+
states.transform.translate(m_bordersCached.getOffset());
16161616
}
16171617
else
16181618
{

src/Widgets/Label.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ namespace tgui
830830
if (m_bordersCached != Borders{0})
831831
{
832832
target.drawBorders(states, m_bordersCached, getSize(), Color::applyOpacity(m_borderColorCached, m_opacityCached));
833-
states.transform.translate({m_bordersCached.getLeft(), m_bordersCached.getTop()});
833+
states.transform.translate(m_bordersCached.getOffset());
834834
}
835835

836836
// Draw the background

0 commit comments

Comments
 (0)