summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-16 13:48:26 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-16 13:48:26 +0300
commite8842e4eadd6d4927db7eb0cc886855f762bcc10 (patch)
tree5b11833a58647029477fd62ffbf53fff03c5ef6e /src/gui
parent92da223a6a15298cd1a14c105a801ab0577670e1 (diff)
downloadmv-e8842e4eadd6d4927db7eb0cc886855f762bcc10.tar.gz
mv-e8842e4eadd6d4927db7eb0cc886855f762bcc10.tar.bz2
mv-e8842e4eadd6d4927db7eb0cc886855f762bcc10.tar.xz
mv-e8842e4eadd6d4927db7eb0cc886855f762bcc10.zip
improve sliderlist.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/sliderlist.cpp20
-rw-r--r--src/gui/widgets/sliderlist.h8
2 files changed, 14 insertions, 14 deletions
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index c90be3629..ab12ef908 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -41,7 +41,7 @@ static const int sliderHeight = 30;
SliderList::SliderList(const Widget2 *const widget,
gcn::ListModel *const listModel,
gcn::ActionListener *const listener,
- std::string eventId) :
+ const std::string &eventId) :
Container(widget),
gcn::ActionListener(),
gcn::MouseListener(),
@@ -98,7 +98,6 @@ void SliderList::resize()
const int width = getWidth();
mButtons[0]->setWidth(buttonWidth);
-// mLabel->setPosition(buttonSpace, 0);
mLabel->setWidth(width - buttonSpace * 2);
mButtons[1]->setPosition(width - buttonSpace + 3, 0);
mButtons[1]->setWidth(buttonWidth);
@@ -108,10 +107,11 @@ void SliderList::resize()
void SliderList::draw(gcn::Graphics *graphics)
{
BLOCK_START("SliderList::draw")
- if (mOldWidth != getWidth())
+ const int width = mDimension.width;
+ if (mOldWidth != width)
{
resize();
- mOldWidth = getWidth();
+ mOldWidth = width;
}
Container::draw(graphics);
BLOCK_END("SliderList::draw")
@@ -127,9 +127,9 @@ void SliderList::updateLabel()
mLabel->setCaption(mListModel->getElementAt(mSelectedIndex));
mLabel->adjustSize();
- const int space = getWidth() - buttonSpace * 2;
+ const int space = mDimension.width - buttonSpace * 2;
const int labelWidth = mLabel->getWidth();
- int labelY = (getHeight() - mLabel->getHeight()) / 2;
+ int labelY = (mDimension.height - mLabel->getHeight()) / 2;
if (labelY < 0)
labelY = 0;
@@ -161,7 +161,7 @@ void SliderList::action(const gcn::ActionEvent &event)
distributeActionEvent();
}
-void SliderList::setSelectedString(std::string str)
+void SliderList::setSelectedString(const std::string &str)
{
if (!mListModel)
return;
@@ -179,12 +179,12 @@ void SliderList::setSelectedString(std::string str)
std::string SliderList::getSelectedString() const
{
if (!mListModel)
- return "";
+ return std::string();
return mListModel->getElementAt(mSelectedIndex);
}
-void SliderList::setSelected(int idx)
+void SliderList::setSelected(const int idx)
{
if (!mListModel)
return;
@@ -204,7 +204,7 @@ void SliderList::adjustSize()
updateLabel();
}
-int SliderList::getMaxLabelWidth()
+int SliderList::getMaxLabelWidth() const
{
if (!mListModel || !gui)
return 1;
diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h
index f9394b3d6..9209a4f55 100644
--- a/src/gui/widgets/sliderlist.h
+++ b/src/gui/widgets/sliderlist.h
@@ -40,7 +40,7 @@ class SliderList final : public Container,
SliderList(const Widget2 *const widget,
gcn::ListModel *const listModel = nullptr,
gcn::ActionListener *const listener = nullptr,
- std::string eventId = "");
+ const std::string &eventId = "");
A_DELETE_COPY(SliderList)
@@ -58,11 +58,11 @@ class SliderList final : public Container,
void action(const gcn::ActionEvent &event) override;
- void setSelectedString(std::string str);
+ void setSelectedString(const std::string &str);
std::string getSelectedString() const A_WARN_UNUSED;
- void setSelected(int idx);
+ void setSelected(const int idx);
void adjustSize();
@@ -72,7 +72,7 @@ class SliderList final : public Container,
protected:
void updateLabel();
- int getMaxLabelWidth() A_WARN_UNUSED;
+ int getMaxLabelWidth() const A_WARN_UNUSED;
Button *mButtons[2];
Label *mLabel;