From f6ed8fc1f51e368bb76905d9f1d2d3735e70a644 Mon Sep 17 00:00:00 2001 From: that Date: Sat, 14 Feb 2015 20:23:16 +0100 Subject: gui: make resources type safe - add string, int, color and resource loading helpers - use typed resource classes, and some cleanup in loading code - remove abstract GetResource() to enforce type safe access - add height and width query methods to resources and use them - minor cleanup - simplify LoadPlacement Change-Id: I9b81785109a80b3806ad6b50cba4d893b87b0db1 --- gui/slidervalue.cpp | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'gui/slidervalue.cpp') diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index 7c38e329e..5be58dcf3 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -73,16 +73,8 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) child = node->first_node("font"); if (child) { - attr = child->first_attribute("resource"); - if (attr) - mFont = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("color"); - if (attr) - { - std::string color = attr->value(); - ConvertStrToColor(color, &mTextColor); - } + mFont = LoadAttrFont(child, "resource"); + mTextColor = LoadAttrColor(child, "color", mTextColor); } // Load the placement @@ -103,17 +95,9 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) child = node->first_node("resource"); if (child) { - attr = child->first_attribute("background"); - if(attr) - mBackgroundImage = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("handle"); - if(attr) - mHandleImage = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("handlehover"); - if(attr) - mHandleHoverImage = PageManager::FindResource(attr->value()); + mBackgroundImage = LoadAttrImage(child, "background"); + mHandleImage = LoadAttrImage(child, "handle"); + mHandleHoverImage = LoadAttrImage(child, "handlehover"); } child = node->first_node("data"); @@ -199,7 +183,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) } } - mFontHeight = gr_getMaxFontHeight(mFont ? mFont->GetResource() : NULL); + mFontHeight = mFont->GetHeight(); if(mShowCurr) { @@ -277,8 +261,8 @@ int GUISliderValue::SetRenderPos(int x, int y, int w, int h) if(mBackgroundImage && mBackgroundImage->GetResource()) { - mLineW = gr_get_width(mBackgroundImage->GetResource()); - mLineH = gr_get_height(mBackgroundImage->GetResource()); + mLineW = mBackgroundImage->GetWidth(); + mLineH = mBackgroundImage->GetHeight(); } else mLineW = mRenderW - (mLinePadding * 2); -- cgit v1.2.3