GUIProgressBar::GUIProgressBar(const String& styleName, const GUIDimensions& dimensions) :GUIElementContainer(dimensions, styleName), mPercent(0) { mBar = GUITexture::create(getSubStyleName(getBarStyleType())); mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType())); mBackground->_setElementDepth(mBar->_getRenderElementDepthRange()); _registerChildElement(mBar); _registerChildElement(mBackground); }
void GUISlider::styleUpdated() { mBackground->setStyle(getSubStyleName(getBackgroundStyleType())); mFillBackground->setStyle(getSubStyleName(getFillStyleType())); mSliderHandle->setStyle(getSubStyleName(getHandleStyleType())); const GUIElementStyle* bgStyle = mBackground->_getStyle(); if(mHasFocus) mBackground->setTexture(bgStyle->focused.texture); else mBackground->setTexture(bgStyle->normal.texture); }
GUISlider::GUISlider(bool horizontal, const String& styleName, const GUIDimensions& dimensions) :GUIElementContainer(dimensions, styleName, GUIElementOption::AcceptsKeyFocus), mHorizontal(horizontal) { GUISliderHandleFlags flags = horizontal ? GUISliderHandleFlag::Horizontal : GUISliderHandleFlag::Vertical; flags |= GUISliderHandleFlag::JumpOnClick; mSliderHandle = GUISliderHandle::create(flags, getSubStyleName(getHandleStyleType())); mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType())); mFillBackground = GUITexture::create(getSubStyleName(getFillStyleType())); mBackground->_setElementDepth(mSliderHandle->_getRenderElementDepthRange() + mFillBackground->_getRenderElementDepthRange()); mFillBackground->_setElementDepth(mSliderHandle->_getRenderElementDepthRange()); _registerChildElement(mSliderHandle); _registerChildElement(mBackground); _registerChildElement(mFillBackground); mHandleMovedConn = mSliderHandle->onHandleMovedOrResized.connect(std::bind(&GUISlider::onHandleMoved, this, _1, _2)); }
void GUIProgressBar::styleUpdated() { mBar->setStyle(getSubStyleName(getBarStyleType())); mBackground->setStyle(getSubStyleName(getBackgroundStyleType())); }