aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MultLayers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/MultLayers.cc')
-rw-r--r--src/FbTk/MultLayers.cc15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc
index a9135e3..6469a14 100644
--- a/src/FbTk/MultLayers.cc
+++ b/src/FbTk/MultLayers.cc
@@ -26,6 +26,8 @@
26#include "App.hh" 26#include "App.hh"
27#include "FbWindow.hh" 27#include "FbWindow.hh"
28 28
29#include "Util.hh"
30
29using namespace FbTk; 31using namespace FbTk;
30 32
31MultLayers::MultLayers(int numlayers) : 33MultLayers::MultLayers(int numlayers) :
@@ -56,11 +58,7 @@ XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
56} 58}
57 59
58void MultLayers::addToTop(XLayerItem &item, int layernum) { 60void MultLayers::addToTop(XLayerItem &item, int layernum) {
59 if (layernum < 0) 61 layernum = FbTk::Util::clamp(layernum, 0, static_cast<signed>(m_layers.size()) - 1);
60 layernum = 0;
61 else if (layernum >= static_cast<signed>(m_layers.size()))
62 layernum = m_layers.size()-1;
63
64 m_layers[layernum]->insert(item); 62 m_layers[layernum]->insert(item);
65 restack(); 63 restack();
66} 64}
@@ -108,12 +106,7 @@ void MultLayers::moveToLayer(XLayerItem &item, int layernum) {
108 if (curr_layer.getLayerNum() == layernum) 106 if (curr_layer.getLayerNum() == layernum)
109 return; 107 return;
110 108
111 // clamp layer number 109 layernum = FbTk::Util::clamp(layernum, 0, static_cast<signed>(m_layers.size()) - 1);
112 if (layernum < 0)
113 layernum = 0;
114 else if (layernum >= static_cast<signed>(m_layers.size()))
115 layernum = m_layers.size()-1;
116 // remove item from old layer and insert it into the
117 item.setLayer(*m_layers[layernum]); 110 item.setLayer(*m_layers[layernum]);
118} 111}
119 112