From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/ui/dialog/layer-properties.h | 158 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 src/ui/dialog/layer-properties.h (limited to 'src/ui/dialog/layer-properties.h') diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h new file mode 100644 index 0000000..6ebbc07 --- /dev/null +++ b/src/ui/dialog/layer-properties.h @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * @brief Dialog for renaming layers + */ +/* Author: + * Bryce W. Harrington + * + * Copyright (C) 2004 Bryce Harrington + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_DIALOG_LAYER_PROPERTIES_H +#define INKSCAPE_DIALOG_LAYER_PROPERTIES_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "layer-manager.h" + +class SPDesktop; + +namespace Inkscape { +namespace UI { +namespace Dialogs { + +/* FIXME: split the LayerPropertiesDialog class into three separate dialogs */ +enum class LayerPropertiesDialogType +{ + NONE, + CREATE, + MOVE, + RENAME +}; + +class LayerPropertiesDialog : public Gtk::Dialog { +public: + LayerPropertiesDialog(LayerPropertiesDialogType type); + ~LayerPropertiesDialog() override; + LayerPropertiesDialog(LayerPropertiesDialog const &) = delete; // no copy + LayerPropertiesDialog &operator=(LayerPropertiesDialog const &) = delete; // no assign + + Glib::ustring getName() const { return "LayerPropertiesDialog"; } + + static void showRename(SPDesktop *desktop, SPObject *layer) { + _showDialog(LayerPropertiesDialogType::RENAME, desktop, layer); + } + static void showCreate(SPDesktop *desktop, SPObject *layer) { + _showDialog(LayerPropertiesDialogType::CREATE, desktop, layer); + } + static void showMove(SPDesktop *desktop, SPObject *layer) { + _showDialog(LayerPropertiesDialogType::MOVE, desktop, layer); + } + +private: + LayerPropertiesDialogType _type = LayerPropertiesDialogType::NONE; + SPDesktop *_desktop = nullptr; + SPObject *_layer = nullptr; + + class PositionDropdownColumns : public Gtk::TreeModel::ColumnRecord { + public: + Gtk::TreeModelColumn position; + Gtk::TreeModelColumn name; + + PositionDropdownColumns() { + add(position); add(name); + } + }; + + Gtk::Label _layer_name_label; + Gtk::Entry _layer_name_entry; + Gtk::Label _layer_position_label; + Gtk::ComboBox _layer_position_combo; + Gtk::Grid _layout_table; + + bool _position_visible = false; + + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + + ModelColumns() + { + add(_colObject); + add(_colVisible); + add(_colLocked); + add(_colLabel); + } + ~ModelColumns() override = default; + + Gtk::TreeModelColumn _colObject; + Gtk::TreeModelColumn _colLabel; + Gtk::TreeModelColumn _colVisible; + Gtk::TreeModelColumn _colLocked; + }; + + Gtk::TreeView _tree; + ModelColumns* _model; + Glib::RefPtr _store; + Gtk::ScrolledWindow _scroller; + + + PositionDropdownColumns _dropdown_columns; + Gtk::CellRendererText _label_renderer; + Glib::RefPtr _dropdown_list; + + Gtk::Button _close_button; + Gtk::Button _apply_button; + + sigc::connection _destroy_connection; + + void _setDesktop(SPDesktop *desktop) { _desktop = desktop; }; + void _setLayer(SPObject *layer); + + static void _showDialog(LayerPropertiesDialogType type, SPDesktop *desktop, SPObject *layer); + void _apply(); + void _close(); + + void _setup_position_controls(); + void _setup_layers_controls(); + void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row); + + void _addLayer(SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level); + SPObject* _selectedLayer(); + bool _handleKeyEvent(GdkEventKey *event); + void _handleButtonEvent(GdkEventButton* event); + + void _doCreate(); + void _doMove(); + void _doRename(); + void _setup(); +}; + +} // namespace +} // namespace +} // namespace + + +#endif //INKSCAPE_DIALOG_LAYER_PROPERTIES_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3