#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include <gtkmm/adjustment.h>
#include <map>
#include <set>
#include <vector>
#include "ui/dialog-events.h"
#include "ui/widget/color-icc-selector.h"
#include "ui/widget/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"
#include "widgets/gradient-vector.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;
{ \
if (dump) { \
g_message(__VA_ARGS__); \
} \
if (dumpD) { \
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, \
} \
}
#endif // DEBUG_LCMS
namespace {
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/**
* Internal variable to track all known colorspaces.
*/
#endif
/**
* Simple helper to allow bitwise or on GtkAttachOptions.
*/
{
}
/**
*/
void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height,
{
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
if (hexpand) {
}
if (centered) {
}
#else
gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding,
ypadding);
#endif
}
} // namespace
/*
icSigRgbData
icSigCmykData
icSigCmyData
*/
#define SPACE_ID_RGB 0
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
// 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)
namespace Inkscape {
namespace UI {
namespace Widget {
/**
* Class containing the parts for a single color component's UI presence.
*/
class ComponentUI {
public:
: _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:
void _sliderGrabbed();
void _sliderReleased();
void _sliderChanged();
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
};
{
init();
// color.signal_dragged.connect(sigc::mem_fun(this, &ColorICCSelector::_colorChanged));
}
{
if (_impl) {
delete _impl;
_impl = 0;
}
}
, _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)
, _profChannelCount(0)
, _profChangedID(0)
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
}
{
_adj = 0;
_sbtn = 0;
_label = 0;
}
{
// Create components
row = 0;
g_signal_connect(G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit),
// Combobox and store with 2 columns : label (0) and full name (1)
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
#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
#if GTK_CHECK_VERSION(3,0,0)
#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)
#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
_impl->_compUI[i]._slider->signal_grabbed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderGrabbed));
row++;
}
// Label
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// Adjustment
// Slider
_impl->_slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5),
// Spinbutton
// Signals
g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged),
_impl);
_impl->_slider->signal_grabbed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderGrabbed));
_impl->_slider->signal_released.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderReleased));
_impl->_slider->signal_value_changed.connect(sigc::mem_fun(_impl, &ColorICCSelectorImpl::_sliderChanged));
gtk_widget_show(t);
}
{
}
#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
#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)
{
}
index++;
}
}
#else
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
#if GTK_CHECK_VERSION(3, 0, 0)
#else
#endif
}
// Helpers for setting color value
{
// sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color );
#ifdef DEBUG_LCMS
g_message("/^^^^^^^^^ %p::_colorChanged(%08x:%s)", this, _impl->_color.color().toRGBA32(_impl->_color.alpha()),
#endif // DEBUG_LCMS
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
_impl->_profilesChanged((_impl->_color.color().icc) ? _impl->_color.color().icc->colorProfile : std::string(""));
#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, ((profile) ? profile->colorProfile.c_str() : "<null>"));
#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) {
}
for (guint i = 0; i < _profChannelCount; i++) {
/*
_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)
}
// iccSelector->_updateInternals( newColor, scaled, iccSelector->_impl->_dragging );
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
}
{
// 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 );
// }
}
{
// 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()
#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 );
}
{
return w;
}
Glib::ustring ColorICCSelectorFactory::modeName() const { return gettext(ColorICCSelector::MODE_NAME); }
}
}
}
/*
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 :