Added ScrollbarWidth property to renderers with Scrollbar property

0.8
Bruno Van de Velde 2018-05-14 22:56:09 +02:00
parent 280484f044
commit 3f4f1f657b
17 changed files with 280 additions and 135 deletions

View File

@ -150,6 +150,20 @@ namespace tgui
std::shared_ptr<RendererData> getScrollbar() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the wanted width scrollbar
/// @param scrollbarWidth Requested scrollbar width or 0 to use the default width (texture size if using textures)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setScrollbarWidth(float scrollbarWidth);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the wanted width scrollbar
/// @return Requested scrollbar width or 0 if no width was set (texture width or default value will be used)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getScrollbarWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};

View File

@ -312,6 +312,20 @@ namespace tgui
std::shared_ptr<RendererData> getScrollbar() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the wanted width scrollbar
/// @param scrollbarWidth Requested scrollbar width or 0 to use the default width (texture size if using textures)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setScrollbarWidth(float scrollbarWidth);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the wanted width scrollbar
/// @return Requested scrollbar width or 0 if no width was set (texture width or default value will be used)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getScrollbarWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};

View File

@ -58,6 +58,20 @@ namespace tgui
std::shared_ptr<RendererData> getScrollbar() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the wanted width scrollbar
/// @param scrollbarWidth Requested scrollbar width or 0 to use the default width (texture size if using textures)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setScrollbarWidth(float scrollbarWidth);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the wanted width scrollbar
/// @return Requested scrollbar width or 0 if no width was set (texture width or default value will be used)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getScrollbarWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};

View File

@ -240,6 +240,20 @@ namespace tgui
std::shared_ptr<RendererData> getScrollbar() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the wanted width scrollbar
/// @param scrollbarWidth Requested scrollbar width or 0 to use the default width (texture size if using textures)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setScrollbarWidth(float scrollbarWidth);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the wanted width scrollbar
/// @return Requested scrollbar width or 0 if no width was set (texture width or default value will be used)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getScrollbarWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};

View File

@ -199,6 +199,15 @@ namespace tgui
bool getAutoHide() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the default width of the scrollbar
/// @return Default scrollbar width
///
/// The default width is the value the scrollbar has on construction or the size of the texture once a texture is set.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getDefaultWidth();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget
///
@ -246,6 +255,13 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Updates the scrollbar after a size change
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void updateSize();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves a signal based on its name
///
@ -339,6 +355,8 @@ namespace tgui
// Did the mouse went down on one of the arrows?
bool m_mouseDownOnArrow = false;
bool m_sizeSet = false; // Has setSize been called?
FloatRect m_track;
FloatRect m_thumb;
FloatRect m_arrowUp;

View File

@ -39,6 +39,7 @@ namespace tgui
TGUI_RENDERER_PROPERTY_TEXTURE(ChatBoxRenderer, TextureBackground)
TGUI_RENDERER_PROPERTY_RENDERER(ChatBoxRenderer, Scrollbar, "scrollbar")
TGUI_RENDERER_PROPERTY_NUMBER(ChatBoxRenderer, ScrollbarWidth, 0)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -49,6 +49,7 @@ namespace tgui
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ListBoxRenderer, SelectedTextStyle, {})
TGUI_RENDERER_PROPERTY_RENDERER(ListBoxRenderer, Scrollbar, "scrollbar")
TGUI_RENDERER_PROPERTY_NUMBER(ListBoxRenderer, ScrollbarWidth, 0)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -31,6 +31,7 @@
namespace tgui
{
TGUI_RENDERER_PROPERTY_RENDERER(ScrollablePanelRenderer, Scrollbar, "scrollbar")
TGUI_RENDERER_PROPERTY_NUMBER(ScrollablePanelRenderer, ScrollbarWidth, 0)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -45,6 +45,7 @@ namespace tgui
TGUI_RENDERER_PROPERTY_NUMBER(TextBoxRenderer, CaretWidth, 1)
TGUI_RENDERER_PROPERTY_RENDERER(TextBoxRenderer, Scrollbar, "scrollbar")
TGUI_RENDERER_PROPERTY_NUMBER(TextBoxRenderer, ScrollbarWidth, 0)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -432,6 +432,12 @@ namespace tgui
{
m_scroll->setRenderer(getSharedRenderer()->getScrollbar());
}
else if (property == "scrollbarwidth")
{
const float width = getSharedRenderer()->getScrollbarWidth() ? getSharedRenderer()->getScrollbarWidth() : m_scroll->getDefaultWidth();
m_scroll->setSize({width, m_scroll->getSize().y});
setSize(m_size);
}
else if (property == "bordercolor")
{
m_borderColorCached = getSharedRenderer()->getBorderColor();

View File

@ -717,6 +717,12 @@ namespace tgui
{
m_scroll->setRenderer(getSharedRenderer()->getScrollbar());
}
else if (property == "scrollbarwidth")
{
const float width = getSharedRenderer()->getScrollbarWidth() ? getSharedRenderer()->getScrollbarWidth() : m_scroll->getDefaultWidth();
m_scroll->setSize({width, m_scroll->getSize().y});
setSize(m_size);
}
else if (property == "bordercolor")
{
m_borderColorCached = getSharedRenderer()->getBorderColor();

View File

@ -527,6 +527,13 @@ namespace tgui
m_verticalScrollbar->setRenderer(getSharedRenderer()->getScrollbar());
m_horizontalScrollbar->setRenderer(getSharedRenderer()->getScrollbar());
}
else if (property == "scrollbarwidth")
{
const float width = getSharedRenderer()->getScrollbarWidth() ? getSharedRenderer()->getScrollbarWidth() : m_verticalScrollbar->getDefaultWidth();
m_verticalScrollbar->setSize({width, m_verticalScrollbar->getSize().y});
m_horizontalScrollbar->setSize({m_horizontalScrollbar->getSize().x, width});
updateScrollbars();
}
else
Panel::rendererChanged(property);
}

View File

@ -41,7 +41,8 @@ namespace tgui
m_renderer = aurora::makeCopied<ScrollbarRenderer>();
setRenderer(Theme::getDefault()->getRendererNoThrow(m_type));
setSize(16, 160);
setSize(getDefaultWidth(), 160);
m_sizeSet = false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -95,133 +96,8 @@ namespace tgui
{
Widget::setSize(size);
if (getSize().x <= getSize().y)
m_verticalScroll = true;
else
m_verticalScroll = false;
bool textured = false;
if (m_spriteTrack.isSet() && m_spriteThumb.isSet() && m_spriteArrowUp.isSet() && m_spriteArrowDown.isSet())
textured = true;
if (m_verticalScroll)
{
m_arrowUp.width = getSize().x;
m_arrowDown.width = getSize().x;
if (textured)
{
m_arrowUp.height = getSize().x * m_spriteArrowUp.getTexture().getImageSize().x / m_spriteArrowUp.getTexture().getImageSize().y;
m_arrowDown.height = getSize().x * m_spriteArrowDown.getTexture().getImageSize().x / m_spriteArrowDown.getTexture().getImageSize().y;
}
else
{
m_arrowUp.height = m_arrowUp.width;
m_arrowDown.height = m_arrowUp.width;
}
m_track.width = getSize().x;
m_track.height = std::max(0.f, getSize().y - m_arrowUp.height - m_arrowDown.height);
m_thumb.width = getSize().x;
if (m_maximum > m_viewportSize)
m_thumb.height = m_track.height * m_viewportSize / m_maximum;
else
m_thumb.height = m_track.height;
}
else // The scrollbar lies horizontally
{
m_arrowUp.height = getSize().y;
m_arrowDown.height = getSize().y;
if (textured)
{
m_arrowUp.width = getSize().y * m_spriteArrowUp.getTexture().getImageSize().x / m_spriteArrowUp.getTexture().getImageSize().y;
m_arrowDown.width = getSize().y * m_spriteArrowDown.getTexture().getImageSize().x / m_spriteArrowDown.getTexture().getImageSize().y;
}
else
{
m_arrowUp.width = m_arrowUp.height;
m_arrowDown.width = m_arrowUp.height;
}
m_track.width = std::max(0.f, getSize().x - m_arrowUp.height - m_arrowDown.height);
m_track.height = getSize().y;
m_thumb.height = getSize().y;
if (m_maximum > m_viewportSize)
m_thumb.width = m_track.width * m_viewportSize / m_maximum;
else
m_thumb.width = m_track.width;
}
if (textured)
{
m_spriteArrowUp.setSize({m_arrowUp.width, m_arrowUp.height});
m_spriteArrowUpHover.setSize({m_arrowUp.width, m_arrowUp.height});
m_spriteArrowDown.setSize({m_arrowDown.width, m_arrowDown.height});
m_spriteArrowDownHover.setSize({m_arrowDown.width, m_arrowDown.height});
if (m_verticalScroll == m_verticalImage)
{
m_spriteTrack.setSize({m_track.width, m_track.height});
m_spriteTrackHover.setSize({m_track.width, m_track.height});
m_spriteThumb.setSize({m_thumb.width, m_thumb.height});
m_spriteThumbHover.setSize({m_thumb.width, m_thumb.height});
m_spriteTrack.setRotation(0);
m_spriteTrackHover.setRotation(0);
m_spriteThumb.setRotation(0);
m_spriteThumbHover.setRotation(0);
}
else
{
m_spriteTrack.setSize({m_track.height, m_track.width});
m_spriteTrackHover.setSize({m_track.height, m_track.width});
m_spriteThumb.setSize({m_thumb.height, m_thumb.width});
m_spriteThumbHover.setSize({m_thumb.height, m_thumb.width});
m_spriteTrack.setRotation(-90);
m_spriteTrackHover.setRotation(-90);
m_spriteThumb.setRotation(-90);
m_spriteThumbHover.setRotation(-90);
}
// Set the rotation or the arrows now that the size has been set
if (m_verticalScroll)
{
m_spriteArrowUp.setRotation(0);
m_spriteArrowUpHover.setRotation(0);
m_spriteArrowDown.setRotation(0);
m_spriteArrowDownHover.setRotation(0);
}
else
{
m_spriteArrowUp.setRotation(-90);
m_spriteArrowUpHover.setRotation(-90);
m_spriteArrowDown.setRotation(-90);
m_spriteArrowDownHover.setRotation(-90);
}
}
// Recalculate the position of the track, thumb and arrows
if (m_verticalScroll)
{
m_arrowDown.left = 0;
m_arrowDown.top = getSize().y - m_arrowDown.height;
m_track.left = 0;
m_track.top = m_arrowUp.height;
}
else
{
m_arrowDown.left = getSize().x - m_arrowDown.width;
m_arrowDown.top = 0;
m_track.left = m_arrowUp.width;
m_track.top = 0;
}
updateThumbPosition();
m_sizeSet = true;
updateSize();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -241,7 +117,7 @@ namespace tgui
setValue(m_maximum - m_viewportSize);
// Recalculate the size and position of the thumb image
setSize(m_size);
updateSize();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -268,7 +144,7 @@ namespace tgui
onValueChange.emit(this, m_value);
// Recalculate the size and position of the thumb image
setSize(m_size);
updateSize();
}
}
@ -293,7 +169,7 @@ namespace tgui
setValue(m_maximum - m_viewportSize);
// Recalculate the size and position of the thumb image
setSize(m_size);
updateSize();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -333,6 +209,16 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float Scrollbar::getDefaultWidth()
{
if (m_spriteTrack.isSet())
return m_spriteTrack.getTexture().getImageSize().x;
else
return 16;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Scrollbar::mouseOnWidget(Vector2f pos) const
{
// Don't make any calculations when no scrollbar is needed
@ -689,6 +575,140 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Scrollbar::updateSize()
{
if (getSize().x <= getSize().y)
m_verticalScroll = true;
else
m_verticalScroll = false;
bool textured = false;
if (m_spriteTrack.isSet() && m_spriteThumb.isSet() && m_spriteArrowUp.isSet() && m_spriteArrowDown.isSet())
textured = true;
if (m_verticalScroll)
{
m_arrowUp.width = getSize().x;
m_arrowDown.width = getSize().x;
if (textured)
{
m_arrowUp.height = getSize().x * m_spriteArrowUp.getTexture().getImageSize().x / m_spriteArrowUp.getTexture().getImageSize().y;
m_arrowDown.height = getSize().x * m_spriteArrowDown.getTexture().getImageSize().x / m_spriteArrowDown.getTexture().getImageSize().y;
}
else
{
m_arrowUp.height = m_arrowUp.width;
m_arrowDown.height = m_arrowUp.width;
}
m_track.width = getSize().x;
m_track.height = std::max(0.f, getSize().y - m_arrowUp.height - m_arrowDown.height);
m_thumb.width = getSize().x;
if (m_maximum > m_viewportSize)
m_thumb.height = m_track.height * m_viewportSize / m_maximum;
else
m_thumb.height = m_track.height;
}
else // The scrollbar lies horizontally
{
m_arrowUp.height = getSize().y;
m_arrowDown.height = getSize().y;
if (textured)
{
m_arrowUp.width = getSize().y * m_spriteArrowUp.getTexture().getImageSize().x / m_spriteArrowUp.getTexture().getImageSize().y;
m_arrowDown.width = getSize().y * m_spriteArrowDown.getTexture().getImageSize().x / m_spriteArrowDown.getTexture().getImageSize().y;
}
else
{
m_arrowUp.width = m_arrowUp.height;
m_arrowDown.width = m_arrowUp.height;
}
m_track.width = std::max(0.f, getSize().x - m_arrowUp.height - m_arrowDown.height);
m_track.height = getSize().y;
m_thumb.height = getSize().y;
if (m_maximum > m_viewportSize)
m_thumb.width = m_track.width * m_viewportSize / m_maximum;
else
m_thumb.width = m_track.width;
}
if (textured)
{
m_spriteArrowUp.setSize({m_arrowUp.width, m_arrowUp.height});
m_spriteArrowUpHover.setSize({m_arrowUp.width, m_arrowUp.height});
m_spriteArrowDown.setSize({m_arrowDown.width, m_arrowDown.height});
m_spriteArrowDownHover.setSize({m_arrowDown.width, m_arrowDown.height});
if (m_verticalScroll == m_verticalImage)
{
m_spriteTrack.setSize({m_track.width, m_track.height});
m_spriteTrackHover.setSize({m_track.width, m_track.height});
m_spriteThumb.setSize({m_thumb.width, m_thumb.height});
m_spriteThumbHover.setSize({m_thumb.width, m_thumb.height});
m_spriteTrack.setRotation(0);
m_spriteTrackHover.setRotation(0);
m_spriteThumb.setRotation(0);
m_spriteThumbHover.setRotation(0);
}
else
{
m_spriteTrack.setSize({m_track.height, m_track.width});
m_spriteTrackHover.setSize({m_track.height, m_track.width});
m_spriteThumb.setSize({m_thumb.height, m_thumb.width});
m_spriteThumbHover.setSize({m_thumb.height, m_thumb.width});
m_spriteTrack.setRotation(-90);
m_spriteTrackHover.setRotation(-90);
m_spriteThumb.setRotation(-90);
m_spriteThumbHover.setRotation(-90);
}
// Set the rotation or the arrows now that the size has been set
if (m_verticalScroll)
{
m_spriteArrowUp.setRotation(0);
m_spriteArrowUpHover.setRotation(0);
m_spriteArrowDown.setRotation(0);
m_spriteArrowDownHover.setRotation(0);
}
else
{
m_spriteArrowUp.setRotation(-90);
m_spriteArrowUpHover.setRotation(-90);
m_spriteArrowDown.setRotation(-90);
m_spriteArrowDownHover.setRotation(-90);
}
}
// Recalculate the position of the track, thumb and arrows
if (m_verticalScroll)
{
m_arrowDown.left = 0;
m_arrowDown.top = getSize().y - m_arrowDown.height;
m_track.left = 0;
m_track.top = m_arrowUp.height;
}
else
{
m_arrowDown.left = getSize().x - m_arrowDown.width;
m_arrowDown.top = 0;
m_track.left = m_arrowUp.width;
m_track.top = 0;
}
updateThumbPosition();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Signal& Scrollbar::getSignal(std::string signalName)
{
if (signalName == toLower(onValueChange.getName()))
@ -704,7 +724,17 @@ namespace tgui
if (property == "texturetrack")
{
m_spriteTrack.setTexture(getSharedRenderer()->getTextureTrack());
setSize(m_size);
if (m_sizeSet)
updateSize();
else
{
if (m_verticalScroll)
setSize({getDefaultWidth(), getSize().y});
else
setSize({getSize().x, getDefaultWidth()});
m_sizeSet = false;
}
}
else if (property == "texturetrackhover")
{
@ -713,7 +743,7 @@ namespace tgui
else if (property == "texturethumb")
{
m_spriteThumb.setTexture(getSharedRenderer()->getTextureThumb());
setSize(m_size);
updateSize();
}
else if (property == "texturethumbhover")
{
@ -722,7 +752,7 @@ namespace tgui
else if (property == "texturearrowup")
{
m_spriteArrowUp.setTexture(getSharedRenderer()->getTextureArrowUp());
setSize(m_size);
updateSize();
}
else if (property == "texturearrowuphover")
{
@ -731,7 +761,7 @@ namespace tgui
else if (property == "texturearrowdown")
{
m_spriteArrowDown.setTexture(getSharedRenderer()->getTextureArrowDown());
setSize(m_size);
updateSize();
}
else if (property == "texturearrowdownhover")
{

View File

@ -1491,6 +1491,12 @@ namespace tgui
{
m_verticalScroll->setRenderer(getSharedRenderer()->getScrollbar());
}
else if (property == "scrollbarwidth")
{
const float width = getSharedRenderer()->getScrollbarWidth() ? getSharedRenderer()->getScrollbarWidth() : m_verticalScroll->getDefaultWidth();
m_verticalScroll->setSize({width, m_verticalScroll->getSize().y});
setSize(m_size);
}
else if (property == "backgroundcolor")
{
m_backgroundColorCached = getSharedRenderer()->getBackgroundColor();

View File

@ -187,6 +187,7 @@ TEST_CASE("[ChatBox]")
REQUIRE_NOTHROW(renderer->setProperty("Borders", "(1, 2, 3, 4)"));
REQUIRE_NOTHROW(renderer->setProperty("Padding", "(5, 6, 7, 8)"));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", "{ TrackColor = Red; ThumbColor = Blue; }"));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", "15"));
}
SECTION("set object property")
@ -196,6 +197,7 @@ TEST_CASE("[ChatBox]")
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", 15));
}
SECTION("functions")
@ -205,12 +207,14 @@ TEST_CASE("[ChatBox]")
renderer->setBorders({1, 2, 3, 4});
renderer->setPadding({5, 6, 7, 8});
renderer->setScrollbar(scrollbarRenderer.getData());
renderer->setScrollbarWidth(15);
}
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
REQUIRE(renderer->getProperty("BorderColor").getColor() == sf::Color(40, 50, 60));
REQUIRE(renderer->getProperty("Borders").getOutline() == tgui::Borders(1, 2, 3, 4));
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Borders(5, 6, 7, 8));
REQUIRE(renderer->getProperty("ScrollbarWidth").getNumber() == 15);
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 2);
REQUIRE(renderer->getScrollbar()->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);

View File

@ -184,6 +184,7 @@ TEST_CASE("[ScrollablePanel]")
REQUIRE_NOTHROW(renderer->setProperty("Borders", "(1, 2, 3, 4)"));
REQUIRE_NOTHROW(renderer->setProperty("Padding", "(5, 6, 7, 8)"));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", "{ TrackColor = Red; ThumbColor = Blue; }"));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", "15"));
}
SECTION("set object property")
@ -193,6 +194,7 @@ TEST_CASE("[ScrollablePanel]")
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Padding{5, 6, 7, 8}));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", 15));
}
SECTION("functions")
@ -202,12 +204,14 @@ TEST_CASE("[ScrollablePanel]")
renderer->setBorders({1, 2, 3, 4});
renderer->setPadding({5, 6, 7, 8});
renderer->setScrollbar(scrollbarRenderer.getData());
renderer->setScrollbarWidth(15);
}
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
REQUIRE(renderer->getProperty("BorderColor").getColor() == sf::Color(40, 50, 60));
REQUIRE(renderer->getProperty("Borders").getOutline() == tgui::Borders(1, 2, 3, 4));
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Padding(5, 6, 7, 8));
REQUIRE(renderer->getProperty("ScrollbarWidth").getNumber() == 15);
REQUIRE(renderer->getBackgroundColor() == sf::Color(10, 20, 30));
REQUIRE(renderer->getBorderColor() == sf::Color(40, 50, 60));

View File

@ -398,6 +398,7 @@ TEST_CASE("[TextBox]")
REQUIRE_NOTHROW(renderer->setProperty("Padding", "(5, 6, 7, 8)"));
REQUIRE_NOTHROW(renderer->setProperty("CaretWidth", "2"));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", "{ TrackColor = Red; ThumbColor = Blue; }"));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", "15"));
}
SECTION("set object property")
@ -412,6 +413,7 @@ TEST_CASE("[TextBox]")
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
REQUIRE_NOTHROW(renderer->setProperty("CaretWidth", 2));
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
REQUIRE_NOTHROW(renderer->setProperty("ScrollbarWidth", 15));
}
SECTION("functions")
@ -426,6 +428,7 @@ TEST_CASE("[TextBox]")
renderer->setPadding({5, 6, 7, 8});
renderer->setCaretWidth(2);
renderer->setScrollbar(scrollbarRenderer.getData());
renderer->setScrollbarWidth(15);
}
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
@ -437,6 +440,7 @@ TEST_CASE("[TextBox]")
REQUIRE(renderer->getProperty("Borders").getOutline() == tgui::Borders(1, 2, 3, 4));
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Borders(5, 6, 7, 8));
REQUIRE(renderer->getProperty("CaretWidth").getNumber() == 2);
REQUIRE(renderer->getProperty("ScrollbarWidth").getNumber() == 15);
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 2);
REQUIRE(renderer->getScrollbar()->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);