sp-color-icc-selector.cpp revision 17265630bbc582eda06b0dfc0ebdb8febc4362c5
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtksignal.h>
#include <gtk/gtklabel.h>
#include <gtk/gtktable.h>
#include <gtk/gtkspinbutton.h>
#include "../dialogs/dialog-events.h"
#include "sp-color-icc-selector.h"
#include "sp-color-scales.h"
#include "svg/svg-icc-color.h"
#include "document.h"
#include "inkscape.h"
#include "profile-manager.h"
#define noDEBUG_LCMS
#if ENABLE_LCMS
#include "color-profile-fns.h"
#include "color-profile.h"
//#define DEBUG_LCMS
#ifdef DEBUG_LCMS
#include "preferences.h"
#include <gtk/gtkmessagedialog.h>
#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
#ifdef DEBUG_LCMS
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
\
}\
if ( dumpD )\
{\
);\
dialog); \
}\
}
#endif // DEBUG_LCMS
static SPColorSelectorClass *parent_class;
#define XPAD 4
#define YPAD 1
{
if (!type) {
sizeof (SPColorICCSelectorClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (SPColorICCSelector),
0, /* n_preallocs */
0, /* value_table */
};
"SPColorICCSelector",
&info,
static_cast< GTypeFlags > (0) );
}
return type;
}
static void
{
}
: ColorSelector( csel ),
_fixupNeeded(0),
_fooCount(0),
_fooScales(0),
_fooAdj(0),
_fooSlider(0),
_fooBtn(0),
_fooLabel(0),
_fooMap(0),
_adj(0),
_sbtn(0),
_label(0),
_tt(0)
#if ENABLE_LCMS
,
_profileName(""),
_prof(),
#endif // ENABLE_LCMS
{
}
{
_adj = 0;
_sbtn = 0;
_label = 0;
}
{
{
}
}
/*
icSigRgbData
icSigCmykData
icSigCmyData
*/
#define SPACE_ID_RGB 0
#define SPACE_ID_CMY 1
#define SPACE_ID_CMYK 2
#if ENABLE_LCMS
static icUInt16Number* getScratch() {
// bytes per pixel * input channels * width
return scritch;
}
struct MapMap {
};
void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) {
//icSigLuvData
};
{"_X", "_Y", "_Z", "", "", ""},
{"_L", "_a", "_b", "", "", ""},
//
{"_Y", "C_b", "C_r", "", "", ""},
{"_Y", "_x", "y", "", "", ""},
{_("_R"), _("_G"), _("_B"), "", "", ""},
{_("_G"), "", "", "", "", ""},
{_("_H"), _("_S"), "_V", "", "", ""},
{_("_H"), _("_L"), _("_S"), "", "", ""},
{_("_C"), _("_M"), _("_Y"), _("_K"), "", ""},
{_("_C"), _("_M"), _("_Y"), "", "", ""},
};
{"X", "Y", "Z", "", "", ""},
{"L", "a", "b", "", "", ""},
//
{"Y", "Cb", "Cr", "", "", ""},
{"Y", "x", "y", "", "", ""},
{_("Red"), _("Green"), _("Blue"), "", "", ""},
{_("Gray"), "", "", "", "", ""},
{_("Hue"), _("Saturation"), "Value", "", "", ""},
{_("Hue"), _("Lightness"), _("Saturation"), "", "", ""},
{_("Cyan"), _("Magenta"), _("Yellow"), _("Black"), "", ""},
{_("Cyan"), _("Magenta"), _("Yellow"), "", "", ""},
};
{2, 1, 2, 1, 1, 1},
{100, 256, 256, 1, 1, 1},
//
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{360, 1, 1, 1, 1, 1},
{360, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
};
int index = 0;
index = i;
break;
}
}
}
#endif // ENABLE_LCMS
void ColorICCSelector::init()
{
GtkWidget *t;
_tt = gtk_tooltips_new();
gtk_widget_show (t);
#if ENABLE_LCMS
//guint partCount = _cmsChannelsOf( icSigRgbData );
#endif // ENABLE_LCMS
/* Create components */
row = 0;
//gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 );
#if ENABLE_LCMS
_profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this );
#else
gtk_widget_set_sensitive( _profileSel, false );
#endif // ENABLE_LCMS
row++;
_fooCount = 4;
/* Label */
#if ENABLE_LCMS
#else
#endif // ENABLE_LCMS
gtk_widget_show( _fooLabel[i] );
gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );
/* Adjustment */
/* Slider */
#if ENABLE_LCMS
#else
#endif // ENABLE_LCMS
gtk_widget_show( _fooSlider[i] );
gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD );
#if ENABLE_LCMS
#else
#endif // ENABLE_LCMS
gtk_widget_show( _fooBtn[i] );
gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD );
/* Signals */
gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel );
gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "grabbed", GTK_SIGNAL_FUNC( _sliderGrabbed ), _csel );
gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "released", GTK_SIGNAL_FUNC( _sliderReleased ), _csel );
gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "changed", GTK_SIGNAL_FUNC( _sliderChanged ), _csel );
row++;
}
/* Label */
/* Adjustment */
/* Slider */
gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD);
/* Spinbutton */
gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
/* Signals */
}
static void
{
}
static void
{
}
static void
{
}
sp_color_icc_selector_new (void)
{
return GTK_WIDGET (csel);
}
{
}
#if ENABLE_LCMS
{
gchar* name = (activeIndex != 0) ? gtk_combo_box_get_active_text( GTK_COMBO_BOX(self->_profileSel) ) : 0;
if ( name ) {
}
}
#endif // ENABLE_LCMS
#ifdef ENABLE_LCMS
{
bool dirty = false;
if ( name ) {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
} else {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
} else {
}
if ( newProf ) {
if ( trans ) {
255};
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
if ( retrans ) {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
}
}
dirty = true;
}
} else {
#ifdef DEBUG_LCMS
g_message("NUKE THE ICC");
#endif // DEBUG_LCMS
dirty = true;
_fixupHit( 0, this );
} else {
#ifdef DEBUG_LCMS
g_message("No icc to nuke");
#endif // DEBUG_LCMS
}
}
if ( dirty ) {
#ifdef DEBUG_LCMS
g_message("+----------------");
#endif // DEBUG_LCMS
//_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) );
#ifdef DEBUG_LCMS
g_message("+_________________");
#endif // DEBUG_LCMS
}
}
#endif // ENABLE_LCMS
{
#ifdef ENABLE_LCMS
gtk_combo_box_remove_text( combo, 0 );
}
gtk_combo_box_set_active( combo, 0 );
int index = 1;
while ( current ) {
}
index++;
}
#endif // ENABLE_LCMS
}
/* Helpers for setting color value */
void ColorICCSelector::_colorChanged()
{
// sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color );
#ifdef DEBUG_LCMS
g_message( "/^^^^^^^^^ %p::_colorChanged(%08x:%s)", this,
);
#endif // DEBUG_LCMS
#ifdef DEBUG_LCMS
g_message("FLIPPIES!!!! %p '%s'", _color.icc, (_color.icc ? _color.icc->colorProfile.c_str():"<null>"));
#endif // DEBUG_LCMS
#if ENABLE_LCMS
_fixupNeeded = 0;
for ( guint i = 0; i < _profChannelCount; i++ ) {
if ( _fooScales[i] == 256 ) {
} else {
}
}
}
if ( trans ) {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
}
}
#else
//(void)color;
#endif // ENABLE_LCMS
_updateSliders( -1 );
#ifdef DEBUG_LCMS
g_message( "\\_________ %p::_colorChanged()", this );
#endif // DEBUG_LCMS
}
#if ENABLE_LCMS
{
#ifdef DEBUG_LCMS
g_message( "/^^^^^^^^^ %p::_setProfile(%s)", this,
);
#endif // DEBUG_LCMS
bool profChanged = false;
// Need to clear out the prior one
profChanged = true;
_prof = 0;
_profChannelCount = 0;
profChanged = true;
}
gtk_widget_hide( _fooLabel[i] );
gtk_widget_hide( _fooSlider[i] );
gtk_widget_hide( _fooBtn[i] );
}
if ( profile ) {
if ( profChanged ) {
for ( guint i = 0; i < _profChannelCount; i++ ) {
/*
_fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) );
gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel );
sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] );
gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] );
gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_fooBtn[i]), digits );
*/
gtk_widget_show( _fooLabel[i] );
gtk_widget_show( _fooSlider[i] );
gtk_widget_show( _fooBtn[i] );
//gtk_adjustment_set_value( _fooAdj[i], 0.0 );
//gtk_adjustment_set_value( _fooAdj[i], val );
}
gtk_widget_hide( _fooLabel[i] );
gtk_widget_hide( _fooSlider[i] );
gtk_widget_hide( _fooBtn[i] );
}
}
} else {
// Give up for now on named colors
_prof = 0;
}
}
#ifdef DEBUG_LCMS
g_message( "\\_________ %p::_setProfile()", this );
#endif // DEBUG_LCMS
}
#endif // ENABLE_LCMS
{
#ifdef ENABLE_LCMS
{
for ( guint i = 0; i < _profChannelCount; i++ ) {
if ( _fooScales[i] == 256 ) {
} else {
}
}
}
for ( guint i = 0; i < _profChannelCount; i++ ) {
for ( guint j = 0; j < _profChannelCount; j++ ) {
}
icUInt16Number* p = scratch;
for ( guint x = 0; x < 1024; x++ ) {
for ( guint j = 0; j < _profChannelCount; j++ ) {
if ( j == i ) {
*p++ = x * 0x0ffff / 1024;
} else {
*p++ = filler[j];
}
}
}
if ( trans ) {
}
}
}
}
}
#else
(void)ignore;
#endif // ENABLE_LCMS
}
{
// // TODO check this. It looks questionable:
// // if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100
// if (adjustment->value > 0.0 && adjustment->value < 1.0) {
// gtk_adjustment_set_value( adjustment, floor ((adjustment->value) * adjustment->upper + 0.5) );
// }
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
if (iccSelector->_updating) {
return;
}
#ifdef DEBUG_LCMS
g_message("ALPHA");
#endif // DEBUG_LCMS
} else {
#if ENABLE_LCMS
match = i;
break;
}
}
if ( match >= 0 ) {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
for ( guint i = 0; i < 4; i++ ) {
}
if ( trans ) {
}
}
#ifdef DEBUG_LCMS
g_message(" ~~~~ FLIP");
#endif // DEBUG_LCMS
if ( iccSelector->_fooScales ) {
val -= 128;
}
}
}
}
#endif // ENABLE_LCMS
}
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
{
// ColorICCSelector* iccSelector = (ColorICCSelector*)(SP_COLOR_SELECTOR(cs)->base);
// if (!iccSelector->_dragging) {
// iccSelector->_dragging = TRUE;
// iccSelector->_grabbed();
// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging );
// }
}
{
// ColorICCSelector* iccSelector = (ColorICCSelector*)(SP_COLOR_SELECTOR(cs)->base);
// if (iccSelector->_dragging) {
// iccSelector->_dragging = FALSE;
// iccSelector->_released();
// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging );
// }
}
#ifdef DEBUG_LCMS
#else
#endif // DEBUG_LCMS
{
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
// ColorICCSelector* iccSelector = (ColorICCSelector*)(SP_COLOR_SELECTOR(cs)->base);
// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging );
}
/*
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:encoding=utf-8:textwidth=99 :