/**
* @file
* A slider with colored background - implementation.
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
*
* This code is in public domain
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gtkmm/adjustment.h>
#if WITH_GTKMM_3_0
#include <gtkmm/stylecontext.h>
#else
#endif
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
#include "preferences.h"
static const guchar *sp_color_slider_render_gradient(gint x0, gint y0, gint width, gint height, gint c[], gint dc[],
static const guchar *sp_color_slider_render_map(gint x0, gint y0, gint width, gint height, guchar *map, gint start,
namespace Inkscape {
namespace UI {
namespace Widget {
#if GTK_CHECK_VERSION(3, 0, 0)
: _dragging(false)
#else
: _dragging(false)
, _adjustment(NULL)
#endif
, _value(0.0)
, _oldvalue(0.0)
, _mapsize(0)
{
_c0[0] = 0x00;
_cm[0] = 0xff;
_c0[0] = 0xff;
_b0 = 0x5f;
_b1 = 0xa0;
_bmask = 0x08;
}
{
if (_adjustment) {
#if GTK_CHECK_VERSION(3, 0, 0)
_adjustment.reset();
#else
_adjustment = NULL;
#endif
}
}
{
set_realized();
if (!_gdk_window) {
#if !GTK_CHECK_VERSION(3, 0, 0)
#endif
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
#if !GTK_CHECK_VERSION(3, 0, 0)
style_attach();
#endif
}
}
{
_gdk_window.reset();
}
{
if (get_realized()) {
allocation.get_height());
}
}
#if GTK_CHECK_VERSION(3, 0, 0)
{
}
void ColorSlider::get_preferred_width_for_height_vfunc(int /*height*/, int &minimum_width, int &natural_width) const
{
}
{
}
void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int &minimum_height, int &natural_height) const
{
}
#else
{
}
{
bool result = false;
if (get_is_drawable()) {
}
return result;
}
#endif
{
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
_dragging = true;
#if GTK_CHECK_VERSION(3, 0, 0)
gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)), _gdk_window->gobj(), GDK_OWNERSHIP_NONE, FALSE,
#else
#endif
}
return false;
}
{
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
_dragging = false;
}
}
return false;
}
{
if (_dragging) {
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
}
return false;
}
#if GTK_CHECK_VERSION(3, 0, 0)
{
#else
{
#endif
if (!adjustment) {
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
}
else {
}
if (_adjustment != adjustment) {
if (_adjustment) {
#if !GTK_CHECK_VERSION(3, 0, 0)
#endif
}
_adjustment->signal_value_changed().connect(sigc::mem_fun(this, &ColorSlider::_onAdjustmentValueChanged));
}
}
{
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
}
else {
}
}
}
{
// Remove any map, if set
_map = 0;
queue_draw();
}
{
queue_draw();
}
{
queue_draw();
}
{
gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false);
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
// Draw shadow
if (colorsOnTop) {
#if GTK_CHECK_VERSION(3, 0, 0)
#else
gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
#endif
}
/* Paintable part of color gradient area */
#if GTK_CHECK_VERSION(3, 0, 0)
;
#else
#endif
if (_map) {
/* Render map pixelstore */
gint s = 0;
const guchar *b =
sp_color_slider_render_map(0, 0, carea.get_width(), carea.get_height(), _map, s, d, _b0, _b1, _bmask);
}
}
else {
/* Render gradient */
// part 1: from c0 to cm
for (gint i = 0; i < 4; i++) {
c[i] = _c0[i] << 16;
}
const guchar *b = sp_color_slider_render_gradient(0, 0, wi, carea.get_height(), c, dc, _b0, _b1, _bmask);
/* Draw pixelstore 1 */
}
}
// part 2: from cm to c1
for (gint i = 0; i < 4; i++) {
c[i] = _cm[i] << 16;
}
const guchar *b = sp_color_slider_render_gradient(carea.get_width() / 2, 0, wi, carea.get_height(), c, dc,
/* Draw pixelstore 2 */
}
}
}
/* Draw shadow */
if (!colorsOnTop) {
#if GTK_CHECK_VERSION(3, 0, 0)
#else
gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
#endif
}
/* Draw arrow */
// Define top arrow
// Define bottom arrow
// Render both arrows
cr->stroke_preserve();
return false;
}
} // namespace Widget
} // namespace UI
} // namespace Inkscape
/* Colors are << 16 */
static const guchar *sp_color_slider_render_gradient(gint x0, gint y0, gint width, gint height, gint c[], gint dc[],
{
gint x, y;
guint r, g, b, a;
}
if (!buf) {
}
r = c[0];
g = c[1];
b = c[2];
a = c[3];
guchar *d;
cr = r >> 16;
cg = g >> 16;
cb = b >> 16;
ca = a >> 16;
d = dp;
/* Background value */
d += 3 * width;
}
r += dc[0];
g += dc[1];
b += dc[2];
a += dc[3];
dp += 3;
}
return buf;
}
/* Positions are << 16 */
static const guchar *sp_color_slider_render_map(gint x0, gint y0, gint width, gint height, guchar *map, gint start,
{
gint x, y;
}
if (!buf) {
}
/* Background value */
d += 3 * width;
}
dp += 3;
}
return buf;
}