Permalink
Browse files

Fixed bug #378. ScrolledWindow now hides and displays it's scrollbars…

… properly when it's own visibility is changed. And since I'm so pedantic, I also renamed g_label to m_label in Button.cpp since it's not a global anymore ;)
  • Loading branch information...
1 parent c7beecf commit 7d85531b54a7da3071ff9391088b568d1b6bd063 @binary1248 binary1248 committed Apr 20, 2012
Showing with 14 additions and 6 deletions.
  1. +4 −4 examples/Button.cpp
  2. +1 −0 include/SFGUI/ScrolledWindow.hpp
  3. +9 −2 src/SFGUI/ScrolledWindow.cpp
View
@@ -16,19 +16,19 @@ class ButtonExample {
sfg::SFGUI m_sfgui;
// Create the label pointer here to reach it from OnButtonClick().
- sfg::Label::Ptr g_label;
+ sfg::Label::Ptr m_label;
};
void ButtonExample::OnButtonClick() {
- g_label->SetText( "Hello SFGUI, pleased to meet you!" );
+ m_label->SetText( "Hello SFGUI, pleased to meet you!" );
}
void ButtonExample::Run() {
// Create SFML's window.
sf::RenderWindow render_window( sf::VideoMode( SCREEN_WIDTH, SCREEN_HEIGHT ), "Hello world!" );
// Create the label.
- g_label = sfg::Label::Create( "Hello world!" );
+ m_label = sfg::Label::Create( "Hello world!" );
// Create a simple button and connect the click signal.
sfg::Button::Ptr button( sfg::Button::Create( "Greet SFGUI!" ) );
@@ -37,7 +37,7 @@ void ButtonExample::Run() {
// Create a vertical box layouter with 5 pixels spacing and add the label
// and button to it.
sfg::Box::Ptr box( sfg::Box::Create( sfg::Box::VERTICAL, 5.0f ) );
- box->Pack( g_label );
+ box->Pack( m_label );
box->Pack( button, false );
// Create a window and add the box layouter to it. Also set the window's title.
@@ -139,6 +139,7 @@ class SFGUI_API ScrolledWindow : public Container {
void HandleSizeChange();
void HandleAdd( const Widget::Ptr& child );
+ void HandleVisibilityChange();
mutable sf::FloatRect m_content_allocation;
@@ -178,8 +178,8 @@ void ScrolledWindow::RecalculateAdjustments() const {
RecalculateContentAllocation();
- m_horizontal_scrollbar->Show( IsHorizontalScrollbarVisible() );
- m_vertical_scrollbar->Show( IsVerticalScrollbarVisible() );
+ m_horizontal_scrollbar->Show( IsDrawn() && IsHorizontalScrollbarVisible() );
+ m_vertical_scrollbar->Show( IsDrawn() && IsVerticalScrollbarVisible() );
}
void ScrolledWindow::RecalculateContentAllocation() const {
@@ -345,4 +345,11 @@ const std::string& ScrolledWindow::GetName() const {
return name;
}
+void ScrolledWindow::HandleVisibilityChange() {
+ Widget::HandleVisibilityChange();
+
+ m_horizontal_scrollbar->Show( IsDrawn() && IsHorizontalScrollbarVisible() );
+ m_vertical_scrollbar->Show( IsDrawn() && IsVerticalScrollbarVisible() );
+}
+
}

0 comments on commit 7d85531

Please sign in to comment.