Skip to content

Commit fcbfe2c

Browse files
committed
Added RoundedBorderRadius property to EditBox and ComboBox renderers (fixes #260)
1 parent 5246926 commit fcbfe2c

File tree

16 files changed

+282
-129
lines changed

16 files changed

+282
-129
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
TGUI 1.11 (TBD)
2+
----------------
3+
4+
- Added RoundedBorderRadius property to EditBox and ComboBox renderers
5+
6+
17
TGUI 1.10 (14 June 2025)
28
-------------------------
39

gui-builder/include/WidgetProperties/ComboBoxProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct ComboBoxProperties : WidgetProperties
9595
pair.second["TextureArrowDisabled"] = {"Texture", tgui::Serializer::serialize(renderer->getTextureArrowDisabled())};
9696
pair.second["TextStyle"] = {"TextStyle", tgui::Serializer::serialize(renderer->getTextStyle())};
9797
pair.second["DefaultTextStyle"] = {"TextStyle", tgui::Serializer::serialize(renderer->getDefaultTextStyle())};
98+
pair.second["RoundedBorderRadius"] = {"Float", tgui::String::fromNumber(renderer->getRoundedBorderRadius())};
9899
return pair;
99100
}
100101

gui-builder/include/WidgetProperties/EditBoxProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ TGUI_IGNORE_DEPRECATED_WARNINGS_END
101101
pair.second["TextureFocused"] = {"Texture", tgui::Serializer::serialize(renderer->getTextureFocused())};
102102
pair.second["TextStyle"] = {"TextStyle", tgui::Serializer::serialize(renderer->getTextStyle())};
103103
pair.second["DefaultTextStyle"] = {"TextStyle", tgui::Serializer::serialize(renderer->getDefaultTextStyle())};
104+
pair.second["RoundedBorderRadius"] = {"Float", tgui::String::fromNumber(renderer->getRoundedBorderRadius())};
104105
return pair;
105106
}
106107
};

gui-builder/include/WidgetProperties/PanelProperties.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ struct PanelProperties : GroupProperties
3838
const auto renderer = panel->getSharedRenderer();
3939
pair.second["Borders"] = {"Outline", renderer->getBorders().toString()};
4040
pair.second["BackgroundColor"] = {"Color", tgui::Serializer::serialize(renderer->getBackgroundColor())};
41+
pair.second["BorderColor"] = {"Color", tgui::Serializer::serialize(renderer->getBorderColor())};
4142
pair.second["TextureBackground"] = {"Texture", tgui::Serializer::serialize(renderer->getTextureBackground())};
43+
pair.second["RoundedBorderRadius"] = {"Float", tgui::String::fromNumber(renderer->getRoundedBorderRadius())};
4244
return pair;
4345
}
4446
};

include/TGUI/Renderers/ComboBoxRenderer.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ TGUI_MODULE_EXPORT namespace tgui
345345
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
346346
TGUI_NODISCARD const Texture& getTextureArrowDisabled() const;
347347

348+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
349+
/// @brief Changes the radius for the rounded corners if you want to draw a rounded rectangle as background
350+
/// @param radius Radius of the corners
351+
///
352+
/// @warning This property is ignored when textures are used as background
353+
///
354+
/// @since TGUI 1.11
355+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
356+
void setRoundedBorderRadius(float radius);
357+
358+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
359+
/// @brief Returns the radius for the rounded corners if you want to draw a rounded rectangle as background
360+
/// @return Radius of the corners
361+
/// @since TGUI 1.11
362+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
363+
TGUI_NODISCARD float getRoundedBorderRadius() const;
364+
348365
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
349366
/// @brief Sets the renderer data of the list box
350367
///
@@ -356,6 +373,11 @@ TGUI_MODULE_EXPORT namespace tgui
356373
/// @brief Returns the renderer data of the list box
357374
///
358375
/// @return Data about how the list box looks
376+
///
377+
/// Example usage:
378+
/// @code
379+
/// tgui::ListBoxRenderer(comboBox->getRenderer()->getListBox()).setTextColor(tgui::Color::Red);
380+
/// @endcode
359381
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
360382
TGUI_NODISCARD std::shared_ptr<RendererData> getListBox() const;
361383

include/TGUI/Renderers/EditBoxRenderer.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,23 @@ TGUI_MODULE_EXPORT namespace tgui
412412
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
413413
TGUI_NODISCARD const Texture& getTextureFocused() const;
414414

415+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
416+
/// @brief Changes the radius for the rounded corners if you want to draw a rounded rectangle as background
417+
/// @param radius Radius of the corners
418+
///
419+
/// @warning This property is ignored when textures are used as background
420+
///
421+
/// @since TGUI 1.11
422+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
423+
void setRoundedBorderRadius(float radius);
424+
425+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
426+
/// @brief Returns the radius for the rounded corners if you want to draw a rounded rectangle as background
427+
/// @return Radius of the corners
428+
/// @since TGUI 1.11
429+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
430+
TGUI_NODISCARD float getRoundedBorderRadius() const;
431+
415432
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
416433
};
417434

include/TGUI/Widgets/ComboBox.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ TGUI_MODULE_EXPORT namespace tgui
656656
Color m_arrowBackgroundColorDisabledCached;
657657
Color m_textColorCached;
658658
Color m_textColorDisabledCached;
659+
float m_roundedBorderRadiusCached = 0;
659660

660661
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
661662
};

include/TGUI/Widgets/EditBox.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ TGUI_MODULE_EXPORT namespace tgui
627627
Color m_caretColorHoverCached;
628628
Color m_caretColorFocusedCached;
629629
Color m_selectedTextBackgroundColorCached;
630+
float m_roundedBorderRadiusCached = 0;
630631

631632
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
632633
private:

src/Renderers/ComboBoxRenderer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace tgui
5454
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ComboBoxRenderer, TextStyle, TextStyle::Regular)
5555
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ComboBoxRenderer, DefaultTextStyle, {})
5656

57+
TGUI_RENDERER_PROPERTY_NUMBER(ComboBoxRenderer, RoundedBorderRadius, 0)
58+
5759
TGUI_RENDERER_PROPERTY_RENDERER(ComboBoxRenderer, ListBox, "ListBox")
5860
}
5961

src/Renderers/EditBoxRenderer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ namespace tgui
5959

6060
TGUI_RENDERER_PROPERTY_TEXT_STYLE(EditBoxRenderer, TextStyle, TextStyle::Regular)
6161
TGUI_RENDERER_PROPERTY_TEXT_STYLE(EditBoxRenderer, DefaultTextStyle, TextStyle::Italic)
62+
63+
TGUI_RENDERER_PROPERTY_NUMBER(EditBoxRenderer, RoundedBorderRadius, 0)
6264
}
6365

6466
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)