diff options
Diffstat (limited to 'src/FbTk/MultLayers.cc')
-rw-r--r-- | src/FbTk/MultLayers.cc | 15 |
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 | |||
29 | using namespace FbTk; | 31 | using namespace FbTk; |
30 | 32 | ||
31 | MultLayers::MultLayers(int numlayers) : | 33 | MultLayers::MultLayers(int numlayers) : |
@@ -56,11 +58,7 @@ XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) { | |||
56 | } | 58 | } |
57 | 59 | ||
58 | void MultLayers::addToTop(XLayerItem &item, int layernum) { | 60 | void 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 | ||