From 5244fc32447d2649a52a06dc84d96da94e9fd715 Mon Sep 17 00:00:00 2001 From: rathnor Date: Wed, 29 Jan 2003 21:42:53 +0000 Subject: 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) --- src/FbTk/MultLayers.cc | 12 +++++++++++- src/FbTk/MultLayers.hh | 7 ++++++- src/FbTk/XLayer.cc | 53 +++++++++++++++++++++++++++++++++++++++----------- src/FbTk/XLayerItem.cc | 27 ++++++++++++++++++++++--- src/FbTk/XLayerItem.hh | 25 +++++++++++++++++++----- 5 files changed, 103 insertions(+), 21 deletions(-) diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc index a7a2e60..fbe8bfe 100644 --- a/src/FbTk/MultLayers.cc +++ b/src/FbTk/MultLayers.cc @@ -20,7 +20,7 @@ // 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,11 +51,21 @@ XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) { } + 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 */ void MultLayers::raise(XLayerItem &item) { // get the layer it is in diff --git a/src/FbTk/MultLayers.hh b/src/FbTk/MultLayers.hh index bb9f134..99d765d 100644 --- a/src/FbTk/MultLayers.hh +++ b/src/FbTk/MultLayers.hh @@ -20,7 +20,7 @@ // 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 @@ public: ~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); diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc index 786cefe..8307805 100644 --- a/src/FbTk/XLayer.cc +++ b/src/FbTk/XLayer.cc @@ -20,7 +20,7 @@ // 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 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::restack() { 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(); - XRestackWindows(FbTk::App::instance()->display(), winlist, 2); + 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, size); delete [] winlist; } diff --git a/src/FbTk/XLayerItem.cc b/src/FbTk/XLayerItem.cc index 1c44638..31940a1 100644 --- a/src/FbTk/XLayerItem.cc +++ b/src/FbTk/XLayerItem.cc @@ -20,15 +20,17 @@ // 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::stepUp() { 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); +} diff --git a/src/FbTk/XLayerItem.hh b/src/FbTk/XLayerItem.hh index e61b596..2fd37e6 100644 --- a/src/FbTk/XLayerItem.hh +++ b/src/FbTk/XLayerItem.hh @@ -20,7 +20,7 @@ // 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 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; }; }; -- cgit v0.11.2