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/dash-selector.h | 116 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/ui/widget/dash-selector.h (limited to 'src/ui/widget/dash-selector.h') diff --git a/src/ui/widget/dash-selector.h b/src/ui/widget/dash-selector.h new file mode 100644 index 0000000..f98bb50 --- /dev/null +++ b/src/ui/widget/dash-selector.h @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_SP_DASH_SELECTOR_NEW_H +#define SEEN_SP_DASH_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 "ui/widget/spinbutton.h" +#include +#include +#include + +#include + +#include "scrollprotected.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * Class that wraps a combobox and spinbutton for selecting dash patterns. + */ +class DashSelector : public Gtk::Box { +public: + DashSelector(); + ~DashSelector() override; + + /** + * Get and set methods for dashes + */ + void set_dash(const std::vector& dash, double offset); + + const std::vector& get_dash(double* offset) const; + + sigc::signal changed_signal; + + double get_offset(); + +private: + + /** + * Initialize dashes list from preferences + */ + static void init_dashes(); + + /** + * Fill a pixbuf with the dash pattern using standard cairo drawing + */ + Cairo::RefPtr sp_dash_to_pixbuf(const std::vector& pattern); + + /** + * Fill a pixbuf with text standard cairo drawing + */ + Cairo::RefPtr sp_text_to_pixbuf(const char* text); + + /** + * Callback for combobox image renderer + */ + void prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ); + + /** + * Callback for offset adjustment changing + */ + void offset_value_changed(); + + /** + * Callback for combobox selection changing + */ + void on_selection(); + + /** + * Combobox columns + */ + class DashColumns : public Gtk::TreeModel::ColumnRecord { + public: + Gtk::TreeModelColumn dash; + DashColumns() { + add(dash); + } + }; + DashColumns dash_columns; + Glib::RefPtr _dash_store; + ScrollProtected _dash_combo; + Gtk::CellRendererPixbuf _image_renderer; + Glib::RefPtr _offset; + Inkscape::UI::Widget::SpinButton *_sb; + static gchar const *const _prefs_path; + int _preview_width; + int _preview_height; + int _preview_lineheight; + std::vector* _pattern = nullptr; +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // SEEN_SP_DASH_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