]> git.tdb.fi Git - libs/gltk.git/commitdiff
Add a Stack arrangement
authorMikko Rasa <tdb@tdb.fi>
Sun, 16 Jun 2013 20:06:43 +0000 (23:06 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 16 Jun 2013 20:34:54 +0000 (23:34 +0300)
source/panel.cpp
source/stack.cpp [new file with mode: 0644]
source/stack.h [new file with mode: 0644]

index 930a68f980f96a065552f11942c1b14f519ac2db..f9ea0d4b830a45b690b3134c496f0c1e110c4928 100644 (file)
@@ -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<string, Widget *> &m):
        add("list",      &Loader::child<List>);
        add("panel",     &Loader::panel);
        add("row",       &Loader::arrangement<Row>);
+       add("stack",     &Loader::arrangement<Stack>);
        add("toggle",    &Loader::child<Toggle>);
        add("vslider",   &Loader::child<VSlider>);
 }
diff --git a/source/stack.cpp b/source/stack.cpp
new file mode 100644 (file)
index 0000000..b817a3b
--- /dev/null
@@ -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<Stack>(s)
+{ }
+
+} // namespace GLtk
+} // namespace Msp
diff --git a/source/stack.h b/source/stack.h
new file mode 100644 (file)
index 0000000..fa4a442
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef MSP_GLTK_STACK_H_
+#define MSP_GLTK_STACK_H_
+
+#include <msp/datafile/objectloader.h>
+#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<Stack>
+       {
+       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