Inkscape
Vector Graphics Editor
color-slider.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later/*
5 * Authors:
6 * see git history
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * bulia byak <buliabyak@users.sf.net>
9 *
10 * Copyright (C) 2018 Authors
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SEEN_COLOR_SLIDER_H
15#define SEEN_COLOR_SLIDER_H
16
17#include <gtk/gtk.h> // GtkEventController*
18#include <glibmm/refptr.h>
19#include <gtkmm/drawingarea.h>
20#include <gtkmm/gesture.h> // Gtk::EventSequenceState
21#include <sigc++/signal.h>
22
23namespace Gtk {
24class Adjustment;
25class GestureClick;
26} // namespace Gtk
27
28namespace Inkscape::UI::Widget {
29
30/*
31 * A slider with colored background
32 */
33class ColorSlider : public Gtk::DrawingArea {
34public:
35 ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment);
36 ~ColorSlider() override;
37
38 void setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment);
40 void setMap(const guchar *map);
41 void setBackground(guint dark, guint light, guint size);
42
43 sigc::signal<void ()> signal_grabbed;
44 sigc::signal<void ()> signal_dragged;
45 sigc::signal<void ()> signal_released;
46 sigc::signal<void ()> signal_value_changed;
47
48private:
49 void draw_func(Cairo::RefPtr<Cairo::Context> const &cr, int width, int height);
50
51 Gtk::EventSequenceState on_click_pressed (Gtk::GestureClick const &click,
52 int n_press, double x, double y);
53 Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click,
54 int n_press, double x, double y);
55 void on_motion(GtkEventControllerMotion const *motion, double x, double y);
56
59
61
62 Glib::RefPtr<Gtk::Adjustment> _adjustment;
65
66 gfloat _value;
67 gfloat _oldvalue;
68 guchar _c0[4], _cm[4], _c1[4];
69 guchar _b0, _b1;
70 guchar _bmask;
71 guchar *_map;
72};
73
74} // namespace Inkscape::UI::Widget
75
76#endif // SEEN_COLOR_SLIDER_H
77
78/*
79 Local Variables:
80 mode:c++
81 c-file-style:"stroustrup"
82 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
83 indent-tabs-mode:nil
84 fill-column:99
85 End:
86*/
87// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
sigc::signal< void()> signal_released
Definition: color-slider.h:45
void setBackground(guint dark, guint light, guint size)
void on_motion(GtkEventControllerMotion const *motion, double x, double y)
Gtk::EventSequenceState on_click_pressed(Gtk::GestureClick const &click, int n_press, double x, double y)
sigc::connection _adjustment_changed_connection
Definition: color-slider.h:63
ColorSlider(Glib::RefPtr< Gtk::Adjustment > adjustment)
void setColors(guint32 start, guint32 mid, guint32 end)
void draw_func(Cairo::RefPtr< Cairo::Context > const &cr, int width, int height)
Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click, int n_press, double x, double y)
sigc::connection _adjustment_value_changed_connection
Definition: color-slider.h:64
sigc::signal< void()> signal_value_changed
Definition: color-slider.h:46
Glib::RefPtr< Gtk::Adjustment > _adjustment
Definition: color-slider.h:62
sigc::signal< void()> signal_dragged
Definition: color-slider.h:44
void setMap(const guchar *map)
void setAdjustment(Glib::RefPtr< Gtk::Adjustment > adjustment)
sigc::signal< void()> signal_grabbed
Definition: color-slider.h:43
unsigned int guint32
Definition: color.h:22
Geom::Point start
Geom::Point end
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127
static constexpr int height
int size
double width