restructured layering a little so that a XLayerItem now contains several windows that are to remain equivalent in depth (e.g. tabs, or grouped windows) - (Simon)
rathnor rathnor
5 files changed,
103 insertions(+),
21 deletions(-)
M
src/FbTk/MultLayers.cc
→
src/FbTk/MultLayers.cc
@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MultLayers.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ +// $Id: MultLayers.cc,v 1.2 2003/01/29 21:42:52 rathnor Exp $ #include "MultLayers.hh" #include "XLayer.hh"@@ -51,9 +51,19 @@ return item;
} + void MultLayers::addToTop(XLayerItem &item, int layernum) { if (layernum < 0 || layernum >= m_numlayers) return; m_layers[layernum]->insert(item); +} + +void MultLayers::remove(XLayerItem &item) { + XLayer *curr_layer = item.getLayer(); + if (!curr_layer || curr_layer->getLayerNum() < 0 || curr_layer->getLayerNum() >= m_numlayers) { + // do nothing + return; + } + curr_layer->remove(item); } /* raise the item one level */
M
src/FbTk/MultLayers.hh
→
src/FbTk/MultLayers.hh
@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MultLayers.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $ +// $Id: MultLayers.hh,v 1.2 2003/01/29 21:42:53 rathnor Exp $ #ifndef FBTK_MULTLAYERS_HH #define FBTK_MULTLAYERS_HH@@ -38,9 +38,14 @@ MultLayers(int numlayers);
~MultLayers(); XLayerItem *getLowestItemAboveLayer(int layernum); void addToTop(XLayerItem &item, int layernum); + void remove(XLayerItem &item); + //void move(XLayerItem &item, int layernum); + + // raise/lower the item a whole layer, not just to top of current layer void raise(XLayerItem &item); void lower(XLayerItem &item); + //void moveToTop(XLayerItem &item); //void moveToBottom(XLayerItem &item);
M
src/FbTk/XLayer.cc
→
src/FbTk/XLayer.cc
@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayer.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ +// $Id: XLayer.cc,v 1.2 2003/01/29 21:42:53 rathnor Exp $ #include "XLayer.hh" #include "XLayerItem.hh"@@ -38,13 +38,24 @@ XLayer::~XLayer() {
} void XLayer::restack() { - int numWindows = size(); - Window *winlist = new Window[numWindows]; - typedef FbTk::Layer<XLayerItem> BaseClass; + int numWindows = 0; iterator it = itemList().begin(); iterator it_end = itemList().end(); for (size_t i=0; it != it_end; ++it, i++) { - winlist[i] = (*it)->window(); + numWindows += (*it)->numWindows(); + } + + // each LayerItem can contain several windows + it = itemList().begin(); + it_end = itemList().end(); + Window *winlist = new Window[numWindows]; + size_t j=0; + for (size_t i=0; it != it_end; ++it, i++) { + XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); + XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); + for (; wit != wit_end; ++wit, j++) { + winlist[j] = (*wit); + } } XRestackWindows(FbTk::App::instance()->display(), winlist, numWindows);@@ -54,16 +65,36 @@ }
void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { // little optimisation + Window *winlist; + size_t i, size, num = item->numWindows(); + if (!above) { // must need to go right to top - XRaiseWindow(FbTk::App::instance()->display(), item->window()); - return; + XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()); + if (num > 1) { + i = 0; + // stack relative to top one (just raised) + size = num; + winlist = new Window[size]; + } else { + return; + } + } else { + i=1; + // stack relative to one above + + size = num+1; + winlist = new Window[size]; + winlist[0] = above->getWindows().front(); } - Window * winlist = new Window[2]; - winlist[0] = above->window(); - winlist[1] = item->window(); + + XLayerItem::Windows::iterator it = item->getWindows().begin(); + XLayerItem::Windows::iterator it_end = item->getWindows().end(); + for (; it != it_end; ++it, i++) { + winlist[i] = (*it); + } - XRestackWindows(FbTk::App::instance()->display(), winlist, 2); + XRestackWindows(FbTk::App::instance()->display(), winlist, size); delete [] winlist; }
M
src/FbTk/XLayerItem.cc
→
src/FbTk/XLayerItem.cc
@@ -20,15 +20,17 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayerItem.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ +// $Id: XLayerItem.cc,v 1.2 2003/01/29 21:42:53 rathnor Exp $ #include "XLayerItem.hh" #include "XLayer.hh" using namespace FbTk; -XLayerItem::XLayerItem() : - m_layer(0), m_layeriterator(0) {} +XLayerItem::XLayerItem(Window win) : + m_layer(0), m_layeriterator(0) { + m_windows.push_front(win); +} /* XLayerItem::XLayerItem(XLayer &layer):@@ -60,3 +62,22 @@
void XLayerItem::stepDown() { m_layer->stepDown(*this); } + +void XLayerItem::addWindow(Window win) { + // I'd like to think we can trust ourselves that it won't be added twice... + // Otherwise we're always scanning through the list. + m_windows.push_back(win); +} + +void XLayerItem::removeWindow(Window win) { + // I'd like to think we can trust ourselves that it won't be added twice... + // Otherwise we're always scanning through the list. + + XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), win); + m_windows.erase(it); +} + +void XLayerItem::bringToTop(Window win) { + removeWindow(win); + addWindow(win); +}
M
src/FbTk/XLayerItem.hh
→
src/FbTk/XLayerItem.hh
@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayerItem.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $ +// $Id: XLayerItem.hh,v 1.2 2003/01/29 21:42:53 rathnor Exp $ #ifndef FBTK_XLAYERITEM_HH #define FBTK_XLAYERITEM_HH@@ -34,22 +34,37 @@ namespace FbTk {
class XLayerItem : public LayerItem { public: - XLayerItem(); + typedef std::list<Window> Windows; + + XLayerItem(Window win); ~XLayerItem(); void setLayer(XLayer &layer); XLayer *getLayer() const { return m_layer; } - void raise(); + void raise(); void lower(); void stepUp(); void stepDown(); XLayer::iterator getLayerIterator() const { return m_layeriterator; }; void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; }; - virtual Window window() const = 0; - virtual bool visible() const = 0 ; + + // not currently implemented + bool visible() { return true; } + + // an XLayerItem holds several windows that are equivalent in a layer + // (i.e. if one is raised, then they should all be). + void addWindow(Window win); + void removeWindow(Window win); + + // using this you can bring one window to the top (equivalent to add then remove) + void bringToTop(Window win); + + Windows &getWindows() { return m_windows; } + size_t numWindows() const { return m_windows.size(); } private: XLayer *m_layer; XLayer::iterator m_layeriterator; + Windows m_windows; }; };