Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
dialog-base.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
13#ifndef INK_DIALOG_BASE_H
14#define INK_DIALOG_BASE_H
15
16#include <gtkmm/box.h>
17
19
20namespace Gtk {
21class EventControllerKey;
22class ScrolledWindow;
23} // namespace Gtk
24
25class SPDesktop;
26
27namespace Inkscape::UI::Dialog {
28
39class DialogBase : public Gtk::Box
40{
41 using parent_type = Gtk::Box;
42
43public:
44 DialogBase(char const *prefs_path = nullptr, Glib::ustring dialog_type = {});
45 DialogBase(DialogBase const &) = delete;
46 DialogBase &operator=(DialogBase const &) = delete;
47 ~DialogBase() override;
48
55 virtual void update() {}
56
57 // Public for future use, say if the desktop is smartly set when docking dialogs.
58 void setDesktop(SPDesktop *new_desktop);
59
60 void on_map() override;
61
62 Glib::ustring const &get_name () const { return _name ; }
63 Glib::ustring const &getPrefsPath() const { return _prefs_path ; }
64 Glib::ustring const &get_type () const { return _dialog_type; }
65 const Glib::ustring& get_icon() const { return _icon_name; }
66
67 void blink();
68 // find focusable widget to grab focus
69 virtual void focus_dialog();
70 // return focus back to canvas
71 void defocus_dialog();
72 bool getShowing() { return _showing; }
73 // fix children scrolled windows to send outer scroll when his own reach limits
74 void fix_inner_scroll(Gtk::ScrolledWindow &scrollwin);
75
76 // Too many dialogs have unprotected calls to ask for this data
77 SPDesktop *getDesktop() const { return desktop; }
78
79protected:
80 InkscapeApplication *getApp() const { return _app; }
81 SPDocument *getDocument() const { return document; }
82 Selection *getSelection() const { return selection; }
83 friend class DialogNotebook;
84 void setShowing(bool showing);
85 Glib::ustring _name; // Gtk widget name (must be set!)
86 Glib::ustring const _prefs_path; // Stores characteristic path for loading/saving the dialog position.
87 Glib::ustring const _dialog_type; // Type of dialog (we could just use _pref_path?).
88
89private:
90 bool blink_off(); // timer callback
91 bool on_key_pressed(Gtk::EventControllerKey const &controller,
92 unsigned keyval, unsigned keycode, Gdk::ModifierType state);
93 // return if dialog is on visible tab
94 bool _showing = true;
95 void unsetDesktop();
96 void desktopDestroyed(SPDesktop* old_desktop);
97 void setDocument(SPDocument *new_document);
102 virtual void desktopReplaced() {}
103 virtual void documentReplaced() {}
105 virtual void selectionModified(Inkscape::Selection *selection, guint flags) {};
106
107 sigc::connection _desktop_destroyed;
108 sigc::connection _doc_replaced;
109 sigc::connection _select_changed;
110 sigc::connection _select_modified;
111
115
116 InkscapeApplication *_app; // Used for state management
117 SPDesktop *desktop = nullptr;
120 Glib::ustring _icon_name;
121};
122
123} // namespace Inkscape::UI::Dialog
124
125#endif // INK_DIALOG_BASE_H
126
127/*
128 Local Variables:
129 mode:c++
130 c-file-style:"stroustrup"
131 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
132 indent-tabs-mode:nil
133 fill-column:99
134 End:
135*/
136// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
DialogBase is the base class for the dialog system.
Definition dialog-base.h:40
void setShowing(bool showing)
function called from notebook dialog that performs an update of the dialog and sets the dialog showin...
DialogBase & operator=(DialogBase const &)=delete
Selection * getSelection() const
Definition dialog-base.h:82
void setDesktop(SPDesktop *new_desktop)
Called when the desktop might have changed for this dialog.
void blink()
Highlight notebook where dialog already exists.
virtual void selectionChanged(Inkscape::Selection *selection)
bool blink_off()
Callback to reset the dialog highlight.
void unsetDesktop()
Called to destruct desktops, must not call virtuals.
InkscapeApplication * _app
virtual void update()
The update() method is essential to Gtk state management.
Definition dialog-base.h:55
void setDocument(SPDocument *new_document)
Called when the document might have changed, called from setDesktop too.
bool on_key_pressed(Gtk::EventControllerKey const &controller, unsigned keyval, unsigned keycode, Gdk::ModifierType state)
Glib::ustring const & get_type() const
Definition dialog-base.h:64
DialogBase(DialogBase const &)=delete
void desktopDestroyed(SPDesktop *old_desktop)
virtual void selectionModified(Inkscape::Selection *selection, guint flags)
SPDocument * getDocument() const
Definition dialog-base.h:81
virtual void desktopReplaced()
Called when the desktop has certainly changed.
Glib::ustring const _prefs_path
Definition dialog-base.h:86
void fix_inner_scroll(Gtk::ScrolledWindow &scrollwin)
sigc::connection _desktop_destroyed
const Glib::ustring & get_icon() const
Definition dialog-base.h:65
Glib::ustring const & get_name() const
Definition dialog-base.h:62
InkscapeApplication * getApp() const
Definition dialog-base.h:80
Glib::ustring const & getPrefsPath() const
Definition dialog-base.h:63
SPDesktop * getDesktop() const
Definition dialog-base.h:77
Glib::ustring const _dialog_type
Definition dialog-base.h:87
A widget that wraps a Gtk::Notebook with dialogs as pages.
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
Definition desktop.h:50
Dialog code.
Definition desktop.h:117
static Glib::ustring const prefs_path