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/widget/marker-combo-box.h | 175 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 src/ui/widget/marker-combo-box.h (limited to 'src/ui/widget/marker-combo-box.h') diff --git a/src/ui/widget/marker-combo-box.h b/src/ui/widget/marker-combo-box.h new file mode 100644 index 0000000..46391a4 --- /dev/null +++ b/src/ui/widget/marker-combo-box.h @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_SP_MARKER_SELECTOR_NEW_H +#define SEEN_SP_MARKER_SELECTOR_NEW_H + +/* Authors: + * Lauris Kaplinski + * Maximilian Albert (gtkmm-ification) + * + * Copyright (C) 2002 Lauris Kaplinski + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "document.h" +#include "inkscape.h" +#include "scrollprotected.h" +#include "display/drawing.h" +#include "ui/operation-blocker.h" + +class SPMarker; + +namespace Gtk { + +class Container; +class Adjustment; +} + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * ComboBox-like class for selecting stroke markers. + */ +class MarkerComboBox : public Gtk::Bin { + using parent_type = Gtk::Bin; + +public: + MarkerComboBox(Glib::ustring id, int loc); + ~MarkerComboBox() override; + + void setDocument(SPDocument *); + + sigc::signal changed_signal; + sigc::signal edit_signal; + + void set_current(SPObject *marker); + std::string get_active_marker_uri(); + bool in_update() { return _update.pending(); }; + const char* get_id() { return _combo_id.c_str(); }; + int get_loc() { return _loc; }; + + sigc::signal signal_changed() { return _signal_changed; } + +private: + struct MarkerItem : Glib::Object { + Cairo::RefPtr pix; + SPDocument* source = nullptr; + std::string id; + std::string label; + bool stock = false; + bool history = false; + bool separator = false; + int width = 0; + int height = 0; + + bool operator == (const MarkerItem& item) const; + }; + + SPMarker* get_current() const; + Glib::ustring _current_marker_id; + // SPMarker* _current_marker = nullptr; + sigc::signal _signal_changed; + Glib::RefPtr _builder; + Gtk::FlowBox& _marker_list; + Gtk::Label& _marker_name; + Glib::RefPtr> _marker_store; + std::vector> _stock_items; + std::vector> _history_items; + std::map> _widgets_to_markers; + Gtk::Image& _preview; + bool _preview_no_alloc = true; + Gtk::Button& _link_scale; + Gtk::SpinButton& _angle_btn; + Gtk::MenuButton& _menu_btn; + Gtk::SpinButton& _scale_x; + Gtk::SpinButton& _scale_y; + Gtk::CheckButton& _scale_with_stroke; + Gtk::SpinButton& _offset_x; + Gtk::SpinButton& _offset_y; + Gtk::Widget& _input_grid; + Gtk::RadioButton& _orient_auto_rev; + Gtk::RadioButton& _orient_auto; + Gtk::RadioButton& _orient_angle; + Gtk::Button& _orient_flip_horz; + Gtk::Image& _current_img; + Gtk::Button& _edit_marker; + bool _scale_linked = true; + guint32 _background_color; + guint32 _foreground_color; + Glib::ustring _combo_id; + int _loc; + OperationBlocker _update; + SPDocument *_document = nullptr; + std::unique_ptr _sandbox; + Gtk::CellRendererPixbuf _image_renderer; + + class MarkerColumns : public Gtk::TreeModel::ColumnRecord { + public: + Gtk::TreeModelColumn label; + Gtk::TreeModelColumn marker; // ustring doesn't work here on windows due to unicode + Gtk::TreeModelColumn stock; + Gtk::TreeModelColumn> pixbuf; + Gtk::TreeModelColumn history; + Gtk::TreeModelColumn separator; + + MarkerColumns() { + add(label); add(stock); add(marker); add(history); add(separator); add(pixbuf); + } + }; + MarkerColumns marker_columns; + + void update_ui(SPMarker* marker, bool select); + void update_widgets_from_marker(SPMarker* marker); + void update_store(); + Glib::RefPtr add_separator(bool filler); + void update_scale_link(); + Glib::RefPtr get_active(); + Glib::RefPtr find_marker_item(SPMarker* marker); + void on_style_updated() override; + void update_preview(Glib::RefPtr marker_item); + void update_menu_btn(Glib::RefPtr marker_item); + void set_active(Glib::RefPtr item); + void init_combo(); + void set_history(Gtk::TreeModel::Row match_row); + void marker_list_from_doc(SPDocument* source, bool history); + std::vector get_marker_list(SPDocument* source); + void add_markers (std::vector const& marker_list, SPDocument *source, gboolean history); + void remove_markers (gboolean history); + std::unique_ptr ink_markers_preview_doc(const Glib::ustring& group_id); + Cairo::RefPtr create_marker_image(Geom::IntPoint pixel_size, gchar const *mname, + SPDocument *source, Inkscape::Drawing &drawing, unsigned /*visionkey*/, bool checkerboard, bool no_clip, double scale); + void refresh_after_markers_modified(); + sigc::connection modified_connection; +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape +#endif // SEEN_SP_MARKER_SELECTOR_NEW_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