sp-color-icc-selector.cpp revision 827fbd361779d76f0dff3dff3962b8486426ea01
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gradient-vector.h"
#include <math.h>
#include <map>
#include <set>
#include <vector>
#include "../dialogs/dialog-events.h"
#include "sp-color-icc-selector.h"
#include "sp-color-scales.h"
#include "ui/widget/color-slider.h"
#include "svg/svg-icc-color.h"
#include "colorspace.h"
#include "document.h"
#include "inkscape.h"
#include "profile-manager.h"
#define noDEBUG_LCMS
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#include "color-profile.h"
#include "cms-system.h"
#include "color-profile-cms-fns.h"
#ifdef DEBUG_LCMS
#include "preferences.h"
#endif // DEBUG_LCMS
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#ifdef DEBUG_LCMS
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
\
}\
if ( dumpD )\
{\
);\
dialog); \
}\
}
#endif // DEBUG_LCMS
/**
* Class containing the parts for a single color component's UI presence.
*/
class ComponentUI
{
public:
ComponentUI() :
_component(),
_adj(0),
_slider(0),
_btn(0),
_label(0),
_map(0)
{
}
_adj(0),
_slider(0),
_btn(0),
_label(0),
_map(0)
{
}
};
/**
* Class that implements the internals of the selector.
*/
class ColorICCSelectorImpl
{
public:
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
};
static SPColorSelectorClass *parent_class;
#define XPAD 4
#define YPAD 1
namespace
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/**
* Internal variable to track all known colorspaces.
*/
#endif
/**
* Simple helper to allow bitwise or on GtkAttachOptions.
*/
{
}
/**
*/
bool hexpand = false,
bool centered = false,
{
#if GTK_CHECK_VERSION(3,0,0)
if (hexpand) {
}
if (centered) {
}
#else
GtkAttachOptions xoptions = centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL;
gtk_table_attach( GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, ypadding );
#endif
}
} // namespace
{
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;
}
{
}
: ColorSelector( csel ),
{
}
{
if (_impl)
{
delete _impl;
_impl = 0;
}
}
{
{
}
}
/*
icSigRgbData
icSigCmykData
icSigCmyData
*/
#define SPACE_ID_RGB 0
#define SPACE_ID_CMY 1
#define SPACE_ID_CMYK 2
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
static cmsUInt16Number* getScratch() {
// bytes per pixel * input channels * width
return scritch;
}
name(),
tip(),
scale(1)
{
}
{
}
{
{
//cmsSigLuvData
for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it)
{
}
}
{
}
return target;
}
{
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
_fixupNeeded(0),
_fixupBtn(0),
_profileSel(0),
_compUI(),
_adj(0),
_slider(0),
_sbtn(0),
_label(0)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
,
_profileName(),
_prof(0),
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
}
{
_adj = 0;
_sbtn = 0;
_label = 0;
}
void ColorICCSelector::init()
{
_impl = new ColorICCSelectorImpl(this);
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *t = gtk_grid_new();
#else
#endif
gtk_widget_show (t);
// Create components
row = 0;
g_signal_connect( G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit), (gpointer)_impl );
//gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 );
// Combobox and store with 2 columns : label (0) and full name (1)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
_impl->_profChangedID = g_signal_connect( G_OBJECT(_impl->_profileSel), "changed", G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl );
#else
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
row++;
// populate the data for colorspaces and channels:
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) {
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
} else {
}
#else
#endif
// Adjustment
_impl->_compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) );
// Slider
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" );
#else
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" );
#else
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
// Signals
g_signal_connect( G_OBJECT( _impl->_compUI[i]._adj ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel );
g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "grabbed", G_CALLBACK( ColorICCSelectorImpl::_sliderGrabbed ), _csel );
g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "released", G_CALLBACK( ColorICCSelectorImpl::_sliderReleased ), _csel );
g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "changed", G_CALLBACK( ColorICCSelectorImpl::_sliderChanged ), _csel );
row++;
}
// Label
// Adjustment
// Slider
// Spinbutton
// Signals
g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _csel);
g_signal_connect(G_OBJECT(_impl->_slider), "grabbed", G_CALLBACK(ColorICCSelectorImpl::_sliderGrabbed), _csel);
g_signal_connect(G_OBJECT(_impl->_slider), "released", G_CALLBACK(ColorICCSelectorImpl::_sliderReleased), _csel);
g_signal_connect(G_OBJECT(_impl->_slider), "changed", G_CALLBACK(ColorICCSelectorImpl::_sliderChanged), _csel);
}
{
}
}
static void
{
}
{
}
sp_color_icc_selector_new (void)
{
return GTK_WIDGET (csel);
}
{
}
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
if ( name ) {
}
}
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
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
#if HAVE_LIBLCMS1
#endif
std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(newProf->getColorSpace()));
#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( _compUI[0]._adj, SP_COLOR_ICC_SELECTOR(_csel) );
#ifdef DEBUG_LCMS
g_message("+_________________");
#endif // DEBUG_LCMS
}
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
gtk_combo_box_set_active( combo, 0 );
int index = 1;
while ( current ) {
}
index++;
}
}
#else
{
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
// 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 defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
_impl->_fixupNeeded = 0;
} else {
}
}
}
if ( trans ) {
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
}
}
}
#else
//(void)color;
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#ifdef DEBUG_LCMS
g_message( "\\_________ %p::_colorChanged()", this );
#endif // DEBUG_LCMS
}
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
#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;
}
}
if ( profile ) {
#if HAVE_LIBLCMS1
#endif
if ( profChanged ) {
std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace()));
{
}
for ( guint i = 0; i < _profChannelCount; i++ ) {
gtk_label_set_text_with_mnemonic( GTK_LABEL(_compUI[i]._label), (i < things.size()) ? things[i].name.c_str() : "");
gtk_widget_set_tooltip_text( _compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" );
/*
_compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) );
g_signal_connect( G_OBJECT( _compUI[i]._adj ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel );
sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._adj );
gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_compUI[i]._btn), _compUI[i]._adj );
gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_compUI[i]._btn), digits );
*/
//gtk_adjustment_set_value( _compUI[i]._adj, 0.0 );
//gtk_adjustment_set_value( _compUI[i]._adj, val );
}
}
}
} else {
// Give up for now on named colors
_prof = 0;
}
}
#ifdef DEBUG_LCMS
g_message( "\\_________ %p::_setProfile()", this );
#endif // DEBUG_LCMS
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
for ( guint i = 0; i < _profChannelCount; i++ ) {
} else {
}
}
}
if ( _prof ) {
if ( _prof->getTransfToSRGB8() ) {
for ( guint i = 0; i < _profChannelCount; i++ ) {
for ( guint j = 0; j < _profChannelCount; j++ ) {
}
cmsUInt16Number* 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 // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
}
{
// // 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
return;
}
#ifdef DEBUG_LCMS
g_message("ALPHA");
#endif // DEBUG_LCMS
} else {
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
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
val -= 128;
}
}
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
}
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
void ColorICCSelectorImpl::_sliderGrabbed( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ )
{
// ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base);
// if (!iccSelector->_dragging) {
// iccSelector->_dragging = TRUE;
// iccSelector->_grabbed();
// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_impl->_adj ), iccSelector->_dragging );
// }
}
void ColorICCSelectorImpl::_sliderReleased( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ )
{
// ColorICCSelector* iccSelector = dynamic_cast<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
void ColorICCSelectorImpl::_sliderChanged( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ )
#endif // DEBUG_LCMS
{
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
// ColorICCSelector* iccSelector = dynamic_cast<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:fileencoding=utf-8:textwidth=99 :