color-scales.cpp revision d0b801d25e003fe9c93c36dba677de7905cc7842
/*
* bulia byak <buliabyak@users.sf.net>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include <gtkmm/adjustment.h>
#include "svg/svg-icc-color.h"
#include "ui/dialog-events.h"
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
#define CSC_CHANNEL_R (1 << 0)
#define CSC_CHANNEL_H (1 << 0)
#define CSC_CHANNEL_C (1 << 0)
#define CSC_CHANNELS_ALL 0
#define XPAD 4
#define YPAD 1
#define noDUMP_CHANGE_INFO 1
namespace Inkscape {
namespace UI {
namespace Widget {
static const gchar *sp_color_scales_hue_map();
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
, _rangeLimit(255.0)
{
for (gint i = 0; i < 5; i++) {
_l[i] = 0;
_a[i] = 0;
_s[i] = 0;
_b[i] = 0;
}
}
{
for (gint i = 0; i < 5; i++) {
_l[i] = 0;
_a[i] = 0;
_s[i] = 0;
_b[i] = 0;
}
}
{
gint i;
/* Create components */
/* Label */
gtk_widget_show(_l[i]);
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
#else
#endif
/* Adjustment */
/* Slider */
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
_s[i]->set_hexpand(true);
#else
gtk_table_attach(GTK_TABLE(t), _s[i]->gobj(), 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
#endif
/* Spinbutton */
gtk_widget_show(_b[i]);
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
#else
gtk_table_attach(GTK_TABLE(t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
#endif
/* Attach channel value to adjustment */
/* Signals */
}
//Prevent 5th bar from being shown by PanelDialog::show_all_children
/* Initial mode is none, so it works */
}
void ColorScales::_recalcColor()
{
gfloat c[5];
switch (_mode) {
case SP_COLOR_SCALES_MODE_RGB:
case SP_COLOR_SCALES_MODE_HSV:
_getRgbaFloatv(c);
alpha = c[3];
break;
case SP_COLOR_SCALES_MODE_CMYK: {
_getCmykaFloatv(c);
float rgb[3];
alpha = c[4];
break;
}
default:
break;
}
}
/* Helpers for setting color value */
{
gtk_adjustment_get_upper(const_cast<GtkAdjustment *>(a));
return val;
}
{
}
{
_rangeLimit = upper;
gtk_adjustment_changed(_a[i]);
}
}
void ColorScales::_onColorChanged()
{
if (!get_visible()) {
return;
}
#ifdef DUMP_CHANGE_INFO
#endif
switch (_mode) {
case SP_COLOR_SCALES_MODE_RGB:
sp_color_get_rgb_floatv(&color, c);
c[4] = 0.0;
break;
case SP_COLOR_SCALES_MODE_HSV:
c[4] = 0.0;
break;
break;
default:
break;
}
}
{
switch (_mode) {
case SP_COLOR_SCALES_MODE_RGB:
break;
case SP_COLOR_SCALES_MODE_HSV:
break;
sp_color_cmyk_to_rgb_floatv(rgba, getScaled(_a[0]), getScaled(_a[1]), getScaled(_a[2]), getScaled(_a[3]));
break;
default:
break;
}
}
{
switch (_mode) {
case SP_COLOR_SCALES_MODE_RGB:
break;
case SP_COLOR_SCALES_MODE_HSV:
break;
break;
default:
break;
}
}
{
gfloat c[4];
_getRgbaFloatv(c);
return rgba;
}
{
gfloat c[4];
return;
(_mode == SP_COLOR_SCALES_MODE_CMYK)) {
}
else {
}
switch (mode) {
case SP_COLOR_SCALES_MODE_RGB:
_setRangeLimit(255.0);
break;
case SP_COLOR_SCALES_MODE_HSV:
_setRangeLimit(255.0);
c[0] = 0.0;
break;
_setRangeLimit(100.0);
break;
default:
break;
}
}
{
}
void ColorScales::_sliderAnyGrabbed()
{
if (_updating) {
return;
}
if (!_dragging) {
}
}
void ColorScales::_sliderAnyReleased()
{
if (_updating) {
return;
}
if (_dragging) {
}
}
void ColorScales::_sliderAnyChanged()
{
if (_updating) {
return;
}
_recalcColor();
}
{
return;
}
scales->_recalcColor();
}
{
#ifdef SPCS_PREVIEW
#endif
switch (_mode) {
case SP_COLOR_SCALES_MODE_RGB:
/* Update red */
}
/* Update green */
}
/* Update blue */
}
if (channels != CSC_CHANNEL_A) {
/* Update alpha */
}
break;
case SP_COLOR_SCALES_MODE_HSV:
/* Hue is never updated */
/* Update saturation */
}
/* Update value */
}
if (channels != CSC_CHANNEL_A) {
/* Update alpha */
}
break;
/* Update C */
}
/* Update M */
}
/* Update Y */
}
/* Update K */
}
if (channels != CSC_CHANNEL_CMYKA) {
/* Update alpha */
}
break;
default:
break;
}
#ifdef SPCS_PREVIEW
#endif
}
static const gchar *sp_color_scales_hue_map(void)
{
if (!map) {
gchar *p;
gint h;
p = map;
for (h = 0; h < 1024; h++) {
*p++ = SP_COLOR_F_TO_U(rgb[0]);
*p++ = 255;
}
}
return map;
}
{
}
{
return w;
}
}
}
}
}