Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
stack.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#include "stack.h"
3
4#include <gtkmm/binlayout.h>
5#include "ui/containerize.h"
6
7namespace Inkscape::UI::Widget {
8
10{
11 set_name("Stack");
12 set_layout_manager(Gtk::BinLayout::create());
13 containerize(*this);
14}
15
16void Stack::add(Gtk::Widget &widget)
17{
18 widget.set_sensitive(false);
19 widget.set_parent(*this);
20}
21
22void Stack::remove(Gtk::Widget &widget)
23{
24 if (&widget == _active) {
25 _active = nullptr;
26 }
27 widget.unparent();
28}
29
30void Stack::setActive(Widget *widget)
31{
32 if (widget == _active) {
33 return;
34 }
35
36 if (_active) {
37 _active->set_sensitive(false);
38 }
39
40 _active = widget;
41
42 if (_active) {
43 _active->set_sensitive(true);
44 }
45
46 queue_draw();
47}
48
49void Stack::snapshot_vfunc(Glib::RefPtr<Gtk::Snapshot> const &snapshot)
50{
51 if (_active) {
52 snapshot_child(*_active, snapshot);
53 }
54}
55
56} // namespace Inkscape::UI::Widget
void remove(Gtk::Widget &widget)
Definition stack.cpp:22
void snapshot_vfunc(Glib::RefPtr< Gtk::Snapshot > const &snapshot) override
Definition stack.cpp:49
Gtk::Widget * _active
Definition stack.h:28
void setActive(Gtk::Widget *widget)
Definition stack.cpp:30
void add(Gtk::Widget &widget)
Definition stack.cpp:16
Custom widgets.
Definition desktop.h:126
void containerize(Gtk::Widget &widget)
Make a custom widget implement sensible memory management for its children.