From: Mikko Rasa Date: Sun, 16 Jun 2013 20:06:43 +0000 (+0300) Subject: Add a Stack arrangement X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d34a75fa019d37c4ea748e93c276a6f24b941b1c;p=libs%2Fgltk.git Add a Stack arrangement --- diff --git a/source/panel.cpp b/source/panel.cpp index 930a68f..f9ea0d4 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -13,6 +13,7 @@ #include "panel.h" #include "part.h" #include "row.h" +#include "stack.h" #include "toggle.h" #include "vslider.h" @@ -100,6 +101,7 @@ Panel::Loader::Loader(Panel &p, map &m): add("list", &Loader::child); add("panel", &Loader::panel); add("row", &Loader::arrangement); + add("stack", &Loader::arrangement); add("toggle", &Loader::child); add("vslider", &Loader::child); } diff --git a/source/stack.cpp b/source/stack.cpp new file mode 100644 index 0000000..b817a3b --- /dev/null +++ b/source/stack.cpp @@ -0,0 +1,28 @@ +#include "stack.h" + +namespace Msp { +namespace GLtk { + +Stack::Stack(Layout &l): + Arrangement(l) +{ } + +void Stack::process_widget(Widget &wdg, Side side, bool aligned) +{ + if(edges[side].aligned && aligned) + add_constraint(wdg, get_align_constraint(side), side); + edges[side].add(wdg, aligned); +} + +void Stack::finish_widget(Widget &wdg) +{ + layout.set_ghost(wdg, true); +} + + +Stack::Loader::Loader(Stack &s): + DataFile::ObjectLoader(s) +{ } + +} // namespace GLtk +} // namespace Msp diff --git a/source/stack.h b/source/stack.h new file mode 100644 index 0000000..fa4a442 --- /dev/null +++ b/source/stack.h @@ -0,0 +1,34 @@ +#ifndef MSP_GLTK_STACK_H_ +#define MSP_GLTK_STACK_H_ + +#include +#include "arrangement.h" + +namespace Msp { +namespace GLtk { + +/** +Arranges widgets on top of one another. This can be useful in implementing a +tabbed view where only one tab is visible at a time. +*/ +class Stack: public Arrangement +{ +public: + class Loader: public DataFile::ObjectLoader + { + public: + Loader(Stack &); + }; + + Stack(Layout &); + +private: + virtual void process_widget(Widget &, Side, bool); + virtual void finish_widget(Widget &); + virtual void finish_slot() { } +}; + +} // namespace GLtk +} // namespace Msp + +#endif