diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-09-09 13:31:54 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-09-09 13:31:54 (GMT) |
commit | 77f39235cf3ad79c5ff7d2b0f4717660476f3cf4 (patch) | |
tree | 45cc07526285fc74af54f340782eb11a9d7bc55c /src/FbTk/MultLayers.cc | |
parent | 1657374940998176c7b63eb3296265fe6fbb5458 (diff) | |
download | fluxbox_paul-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.zip fluxbox_paul-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.tar.bz2 |
added FbTk::Util::clamp() and simplified related code
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 | ||