summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-10-04 03:00:44 +0300
committerAndrei Karas <akaras@inbox.ru>2016-10-04 03:22:35 +0300
commit6c3f20764fcf9e3d03185c1e92e8a678499c744a (patch)
tree71c422338303142b68a59bba09a27370abbe0e0f
parenta23406a755012f6d938193e4cfc6244d2027646a (diff)
downloadmanaverse-6c3f20764fcf9e3d03185c1e92e8a678499c744a.tar.gz
manaverse-6c3f20764fcf9e3d03185c1e92e8a678499c744a.tar.bz2
manaverse-6c3f20764fcf9e3d03185c1e92e8a678499c744a.tar.xz
manaverse-6c3f20764fcf9e3d03185c1e92e8a678499c744a.zip
Move slidergrid enum into enums directory.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/gui/slidergrid.h85
-rw-r--r--src/gui/widgets/slider.cpp91
-rw-r--r--src/gui/widgets/slider.h14
5 files changed, 136 insertions, 56 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b60a9f195..93ae99f9e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1329,6 +1329,7 @@ SET(SRCS
enums/gui/progresscolorid.h
enums/gui/serverdialogdonwloadstatus.h
enums/gui/shoplistboxtype.h
+ enums/gui/slidergrid.h
enums/gui/themecolorid.h
enums/gui/updatedownloadstatus.h
enums/gui/usercolorid.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f6baeba7..33ec02db4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -130,6 +130,7 @@ SRC += events/actionevent.h \
enums/gui/progresscolorid.h \
enums/gui/serverdialogdonwloadstatus.h \
enums/gui/shoplistboxtype.h \
+ enums/gui/slidergrid.h \
enums/gui/themecolorid.h \
enums/gui/updatedownloadstatus.h \
enums/gui/usercolorid.h \
diff --git a/src/enums/gui/slidergrid.h b/src/enums/gui/slidergrid.h
new file mode 100644
index 000000000..d2617fa39
--- /dev/null
+++ b/src/enums/gui/slidergrid.h
@@ -0,0 +1,85 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* _______ __ __ __ ______ __ __ _______ __ __
+ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
+ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
+ * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
+ * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
+ * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
+ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
+ *
+ * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
+ *
+ *
+ * Per Larsson a.k.a finalman
+ * Olof Naessén a.k.a jansem/yakslem
+ *
+ * Visit: http://guichan.sourceforge.net
+ *
+ * License: (BSD)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Guichan nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ENUMS_GUI_SLIDERGRID_H
+#define ENUMS_GUI_SLIDERGRID_H
+
+namespace SliderGrid
+{
+ enum Type
+ {
+ HSTART = 0,
+ HMID,
+ HEND,
+ HGRIP,
+ VSTART,
+ VMID,
+ VEND,
+ VGRIP,
+ SLIDER_MAX
+ };
+} // SliderGrid
+
+#endif // ENUMS_GUI_SLIDERGRID_H
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index ee649947a..86089fb9a 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -166,8 +166,8 @@ void Slider::init()
mInstances++;
- if (buttons[0].grid[HGRIP])
- setMarkerLength(buttons[0].grid[HGRIP]->getWidth());
+ if (buttons[0].grid[SliderGrid::HGRIP])
+ setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth());
}
void Slider::updateAlpha()
@@ -180,7 +180,7 @@ void Slider::updateAlpha()
mAlpha = alpha;
for (int f = 0; f < 2; f ++)
{
- for (int d = 0; d < SLIDER_MAX; d ++)
+ for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++)
{
if (buttons[f].grid[d])
buttons[f].grid[d]->setAlpha(mAlpha);
@@ -192,8 +192,9 @@ void Slider::updateAlpha()
void Slider::draw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART]
- || !buttons[0].grid[HEND])
+ if (!buttons[0].grid[SliderGrid::HSTART] ||
+ !buttons[1].grid[SliderGrid::HSTART] ||
+ !buttons[0].grid[SliderGrid::HEND])
{
BLOCK_END("Slider::draw")
return;
@@ -201,8 +202,9 @@ void Slider::draw(Graphics *const graphics)
int w = getWidth();
const int h = getHeight();
- const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 :
- (h - buttons[0].grid[HSTART]->getHeight()) / 2;
+ const int y = mHasMouse ?
+ (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 :
+ (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2;
updateAlpha();
@@ -214,15 +216,16 @@ void Slider::draw(Graphics *const graphics)
if (!mHasMouse)
{
graphics->calcTileCollection(mVertexes,
- buttons[0].grid[HSTART], x, y);
+ buttons[0].grid[SliderGrid::HSTART],
+ x, y);
- const int width = buttons[0].grid[HSTART]->getWidth();
- w -= width + buttons[0].grid[HEND]->getWidth();
+ const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth();
+ w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[HMID])
+ if (buttons[0].grid[SliderGrid::HMID])
{
- const Image *const hMid = buttons[0].grid[HMID];
+ const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
hMid,
x, y,
@@ -231,10 +234,10 @@ void Slider::draw(Graphics *const graphics)
x += w;
graphics->calcTileCollection(mVertexes,
- buttons[0].grid[HEND],
+ buttons[0].grid[SliderGrid::HEND],
x, y);
- const Image *const img = buttons[0].grid[HGRIP];
+ const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
if (img)
{
graphics->calcTileCollection(mVertexes,
@@ -246,18 +249,18 @@ void Slider::draw(Graphics *const graphics)
else
{
graphics->calcTileCollection(mVertexes,
- buttons[1].grid[HSTART],
+ buttons[1].grid[SliderGrid::HSTART],
x, y);
- const int width = buttons[1].grid[HSTART]->getWidth();
+ const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[HEND])
- w -= buttons[1].grid[HEND]->getWidth();
+ if (buttons[1].grid[SliderGrid::HEND])
+ w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[HMID])
+ if (buttons[1].grid[SliderGrid::HMID])
{
- const Image *const hMid = buttons[1].grid[HMID];
+ const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
hMid,
x, y,
@@ -265,13 +268,13 @@ void Slider::draw(Graphics *const graphics)
}
x += w;
- if (buttons[1].grid[HEND])
+ if (buttons[1].grid[SliderGrid::HEND])
{
graphics->calcTileCollection(mVertexes,
- buttons[1].grid[HEND], x, y);
+ buttons[1].grid[SliderGrid::HEND], x, y);
}
- const Image *const img = buttons[1].grid[HGRIP];
+ const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
if (img)
{
graphics->calcTileCollection(mVertexes,
@@ -290,8 +293,9 @@ void Slider::draw(Graphics *const graphics)
void Slider::safeDraw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART]
- || !buttons[0].grid[HEND])
+ if (!buttons[0].grid[SliderGrid::HSTART] ||
+ !buttons[1].grid[SliderGrid::HSTART] ||
+ !buttons[0].grid[SliderGrid::HEND])
{
BLOCK_END("Slider::draw")
return;
@@ -300,28 +304,29 @@ void Slider::safeDraw(Graphics *const graphics)
int w = getWidth();
const int h = getHeight();
int x = 0;
- const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 :
- (h - buttons[0].grid[HSTART]->getHeight()) / 2;
+ const int y = mHasMouse ?
+ (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 :
+ (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2;
updateAlpha();
if (!mHasMouse)
{
- graphics->drawImage(buttons[0].grid[HSTART], x, y);
- const int width = buttons[0].grid[HSTART]->getWidth();
- w -= width + buttons[0].grid[HEND]->getWidth();
+ graphics->drawImage(buttons[0].grid[SliderGrid::HSTART], x, y);
+ const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth();
+ w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[HMID])
+ if (buttons[0].grid[SliderGrid::HMID])
{
- const Image *const hMid = buttons[0].grid[HMID];
+ const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- graphics->drawImage(buttons[0].grid[HEND], x, y);
+ graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y);
- const Image *const img = buttons[0].grid[HGRIP];
+ const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
if (img)
{
graphics->drawImage(img, getMarkerPosition(),
@@ -330,25 +335,25 @@ void Slider::safeDraw(Graphics *const graphics)
}
else
{
- graphics->drawImage(buttons[1].grid[HSTART], x, y);
+ graphics->drawImage(buttons[1].grid[SliderGrid::HSTART], x, y);
- const int width = buttons[1].grid[HSTART]->getWidth();
+ const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[HEND])
- w -= buttons[1].grid[HEND]->getWidth();
+ if (buttons[1].grid[SliderGrid::HEND])
+ w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[HMID])
+ if (buttons[1].grid[SliderGrid::HMID])
{
- const Image *const hMid = buttons[1].grid[HMID];
+ const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- if (buttons[1].grid[HEND])
- graphics->drawImage(buttons[1].grid[HEND], x, y);
+ if (buttons[1].grid[SliderGrid::HEND])
+ graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y);
- const Image *const img = buttons[1].grid[HGRIP];
+ const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
if (img)
{
graphics->drawImage(img, getMarkerPosition(),
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
index b70f3f000..450eddcac 100644
--- a/src/gui/widgets/slider.h
+++ b/src/gui/widgets/slider.h
@@ -67,6 +67,7 @@
#define GUI_WIDGETS_SLIDER_H
#include "enums/gui/orientation.h"
+#include "enums/gui/slidergrid.h"
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
@@ -261,19 +262,6 @@ class Slider final : public Widget,
double getStepLength() const
{ return mStepLength; }
- enum SLIDER_ENUM
- {
- HSTART = 0,
- HMID,
- HEND,
- HGRIP,
- VSTART,
- VMID,
- VEND,
- VGRIP,
- SLIDER_MAX
- };
-
private:
/**
* Used to initialize instances.