osg-trunk
changeset 11106:fcf556c42e28
From Piotr Gwiazdowski, "Recently I've been having some trouble with osgWidget::StyleManager
(I'll omit osgWidget namespace from now on). It seems to me that there
are some inconsistency in the code. In Style there are multiple
applyStyle method overloads, applying style for different
widgets/windows built-in in osgWidget. Plus you can do overrides. It's
good so far.
The problem lies in StyleManager::_applyStyleToObject (which calls
_coearceAndApply, which calls _applySpecificStyle, which calls
Style::applyStyle). With current implementation Style::applyStyle
variants for Input, Window, Frame::Corner, Frame::Border,
Window::EmbeddedWindow are never called, because their classes' names
are omitted in methods' if/else if block, making it impossible to use
styles with most than half of built-in widget/window types.
My fix simply adds couple else if blocks, making each
Style::applyStyle variant callable. By the way, I think that next
update should add Style::applyStyle overload for Table class and add
proper className overloads for Input and Window."
(I'll omit osgWidget namespace from now on). It seems to me that there
are some inconsistency in the code. In Style there are multiple
applyStyle method overloads, applying style for different
widgets/windows built-in in osgWidget. Plus you can do overrides. It's
good so far.
The problem lies in StyleManager::_applyStyleToObject (which calls
_coearceAndApply, which calls _applySpecificStyle, which calls
Style::applyStyle). With current implementation Style::applyStyle
variants for Input, Window, Frame::Corner, Frame::Border,
Window::EmbeddedWindow are never called, because their classes' names
are omitted in methods' if/else if block, making it impossible to use
styles with most than half of built-in widget/window types.
My fix simply adds couple else if blocks, making each
Style::applyStyle variant callable. By the way, I think that next
update should add Style::applyStyle overload for Table class and add
proper className overloads for Input and Window."
| author | robert@16af8721-9629-0410-8352-f15c8da7e697 |
|---|---|
| date | Wed Mar 09 12:29:14 2011 +0000 (14 months ago) |
| parents | d8e42cc930ea |
| children | bca5f1a4a801 |
| files | src/osgWidget/StyleManager.cpp |
line diff
1.1 --- a/src/osgWidget/StyleManager.cpp Wed Mar 09 12:15:39 2011 +0000 1.2 +++ b/src/osgWidget/StyleManager.cpp Wed Mar 09 12:29:14 2011 +0000 1.3 @@ -362,6 +362,31 @@ 1.4 style, 1.5 c 1.6 ); 1.7 + else if(!std::string("Window").compare(c)) return _coerceAndApply<Window>( 1.8 + obj, 1.9 + style, 1.10 + c 1.11 + ); 1.12 + else if(!std::string("Input").compare(c)) return _coerceAndApply<Input>( 1.13 + obj, 1.14 + style, 1.15 + c 1.16 + ); 1.17 + else if(!std::string("Corner").compare(c)) return _coerceAndApply<Frame::Corner>( 1.18 + obj, 1.19 + style, 1.20 + c 1.21 + ); 1.22 + else if(!std::string("Border").compare(c)) return _coerceAndApply<Frame::Border>( 1.23 + obj, 1.24 + style, 1.25 + c 1.26 + ); 1.27 + else if(!std::string("EmbeddedWindow").compare(c)) return _coerceAndApply<Window::EmbeddedWindow>( 1.28 + obj, 1.29 + style, 1.30 + c 1.31 + ); 1.32 1.33 1.34 else warn()
