selected-style.cpp revision 9f4c77cb139a797efd208a1dd78e010458786330
/**
* \brief Selected style indicator (fill, stroke, opacity)
*
* Author:
* buliabyak@gmail.com
*
* Copyright (C) 2005 author
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "selected-style.h"
#include "widgets/spw-utilities.h"
#include "ui/widget/color-preview.h"
#include "selection.h"
#include "desktop-handles.h"
#include "style.h"
#include "desktop-style.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
#include "sp-pattern.h"
#include "dialogs/object-properties.h"
#include "document.h"
#include "widgets/widget-sizes.h"
#include "widgets/spinbutton-events.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 };
static gchar* const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
static void
{
}
static void
{
}
static void
{
}
namespace Inkscape {
namespace UI {
namespace Widget {
typedef struct {
int item;
} DropTracker;
/* Drag and Drop */
typedef enum {
static GtkTargetEntry ui_drop_target_entries [] = {
{"application/x-color", 0, APP_X_COLOR}
};
#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
_fill_label (_("F:")),
_stroke_label (_("S:")),
_opacity_label (_("O:")),
_fill_place (),
_stroke_place (),
_fill_flag_place (),
_opacity_place (),
_stroke (),
_stroke_width (""),
_opacity_blocked (false),
_tooltips (),
_drop((void*[]){0,0}),
_dropEnabled((bool[]){false, false})
{
_fill_label.set_padding(0, 0);
_stroke_label.set_padding(0, 0);
_opacity_label.set_padding(0, 0);
_table.set_row_spacings (0);
__na[i] = (_("Nothing selected"));
_lgradient[i].show_all();
_rgradient[i].show_all();
// TRANSLATOR COMMENT: A means "Averaged"
__averaged[i] = (i == SS_FILL)? (_("Fill is averaged over selected objects")) : (_("Stroke is averaged over selected objects"));
// TRANSLATOR COMMENT: M means "Multiple"
__multiple[i] = (i == SS_FILL)? (_("Multiple selected objects have the same fill")) : (_("Multiple selected objects have the same stroke"));
_popup_edit[i].add(*(new Gtk::Label((i == SS_FILL)? _("Edit fill...") : _("Edit stroke..."), 0.0, 0.5)));
_popup_opaque[i].add(*(new Gtk::Label((i == SS_FILL)? _("Make fill opaque") : _("Make stroke opaque"), 0.0, 0.5)));
//TRANSLATORS COMMENT: unset is a verb here
_popup_unset[i].add(*(new Gtk::Label((i == SS_FILL)? _("Unset fill") : _("Unset stroke"), 0.0, 0.5)));
_popup_remove[i].add(*(new Gtk::Label((i == SS_FILL)? _("Remove fill") : _("Remove stroke"), 0.0, 0.5)));
_popup_copy[i].set_sensitive(false);
}
{
mi->signal_activate().connect(sigc::bind<int>(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i));
}
}
_fill_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click));
_stroke_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click));
_opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click));
_stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
_opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
_opacity_sb.set_sensitive (false);
"drag_data_received",
"drag_data_received",
}
{
delete selection_changed_connection;
delete selection_modified_connection;
delete subselection_changed_connection;
delete _color_preview[i];
}
}
void
{
this )
));
this )
));
this )
));
//_sw_unit = (SPUnit *) SP_DT_NAMEDVIEW(desktop)->doc_units;
}
{
case SS_FILL:
case SS_STROKE:
{
gchar c[64];
// Careful about endian issues.
sp_svg_write_color( c, 64,
0xff // can't have transparency in the color itself
//0x0ff & (data->data[3] >> 8),
));
}
}
break;
}
}
void SelectedStyle::on_fill_remove() {
sp_desktop_set_style (_desktop, css, true, false); // do not write to current, to preserve current color
}
void SelectedStyle::on_stroke_remove() {
sp_desktop_set_style (_desktop, css, true, false); // do not write to current, to preserve current color
}
void SelectedStyle::on_fill_unset() {
sp_desktop_set_style (_desktop, css, true, false); // do not write to current, to preserve current color
}
void SelectedStyle::on_stroke_unset() {
sp_desktop_set_style (_desktop, css, true, false); // do not write to current, to preserve current color
}
void SelectedStyle::on_fill_opaque() {
}
void SelectedStyle::on_stroke_opaque() {
}
void SelectedStyle::on_fill_lastused() {
gchar c[64];
}
void SelectedStyle::on_stroke_lastused() {
gchar c[64];
}
void SelectedStyle::on_fill_lastselected() {
gchar c[64];
}
void SelectedStyle::on_stroke_lastselected() {
gchar c[64];
}
void SelectedStyle::on_fill_invert() {
gchar c[64];
sp_svg_write_color (c, 64,
)
);
}
void SelectedStyle::on_stroke_invert() {
gchar c[64];
sp_svg_write_color (c, 64,
)
);
}
void SelectedStyle::on_fill_white() {
gchar c[64];
}
void SelectedStyle::on_stroke_white() {
gchar c[64];
}
void SelectedStyle::on_fill_black() {
gchar c[64];
}
void SelectedStyle::on_stroke_black() {
gchar c[64];
}
void SelectedStyle::on_fill_copy() {
gchar c[64];
text += c;
}
}
}
void SelectedStyle::on_stroke_copy() {
gchar c[64];
text += c;
}
}
}
void SelectedStyle::on_fill_paste() {
guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
return;
}
}
void SelectedStyle::on_stroke_paste() {
guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
return;
}
}
void SelectedStyle::on_fillstroke_swap() {
g_message("on_fillstroke_swap()");
case SS_NA:
case SS_MANY:
break;
case SS_NONE:
break;
case SS_UNSET:
break;
case SS_COLOR:
gchar c[64];
break;
case SS_LGRADIENT:
case SS_RGRADIENT:
case SS_PATTERN:
break;
}
case SS_NA:
case SS_MANY:
break;
case SS_NONE:
break;
case SS_UNSET:
break;
case SS_COLOR:
gchar c[64];
break;
case SS_LGRADIENT:
case SS_RGRADIENT:
case SS_PATTERN:
break;
}
}
void SelectedStyle::on_fill_edit() {
}
void SelectedStyle::on_stroke_edit() {
}
bool
{
} else {
}
}
return true;
}
bool
{
} else {
}
}
return true;
}
bool
{
//
}
return true;
}
bool
{
const char* opacity = _opacity_sb.get_value() < 0.5? "0.5" : (_opacity_sb.get_value() == 1? "0" : "1");
return true;
}
return false;
}
void SelectedStyle::on_popup_px() {
update();
}
void SelectedStyle::on_popup_pt() {
update();
}
void SelectedStyle::on_popup_mm() {
update();
}
void SelectedStyle::on_popup_preset(int i) {
gdouble w;
if (_sw_unit) {
} else {
w = _sw_presets[i];
}
os << w;
}
void
{
return;
// create temporary style
flag_place->remove();
_paintserver_id[i].clear();
_popup_copy[i].set_sensitive(false);
// query style from desktop. This returns a result flag and fills query with the style of subselection, if any, or selection
switch (result) {
case QUERY_STYLE_NOTHING:
if ( _dropEnabled[i] ) {
_dropEnabled[i] = false;
}
break;
case QUERY_STYLE_SINGLE:
if ( !_dropEnabled[i] ) {
_dropEnabled[i] = true;
}
if (i == SS_FILL) {
} else {
}
_lastselected[i] = _thisselected[i];
_color_preview[i]->show_all();
_popup_copy[i].set_sensitive(true);
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
if ( server ) {
_paintserver_id[i] += "url(#";
_paintserver_id[i] += ")";
if (SP_IS_LINEARGRADIENT (server)) {
_mode[i] = SS_LGRADIENT;
} else if (SP_IS_RADIALGRADIENT (server)) {
_mode[i] = SS_RGRADIENT;
} else if (SP_IS_PATTERN (server)) {
_mode[i] = SS_PATTERN;
}
} else {
}
}
if (result == QUERY_STYLE_MULTIPLE_AVERAGED) {
} else if (result == QUERY_STYLE_MULTIPLE_SAME) {
}
break;
break;
default:
break;
}
}
// Now query opacity
switch (result) {
case QUERY_STYLE_NOTHING:
_opacity_sb.set_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
_opacity_blocked = true;
_opacity_sb.set_sensitive(true);
_opacity_blocked = false;
break;
}
// Now query stroke_width
switch (result_sw) {
case QUERY_STYLE_NOTHING:
break;
case QUERY_STYLE_SINGLE:
{
double w;
if (_sw_unit) {
} else {
}
{
}
{
w,
_(" (averaged)") : "");
}
break;
}
default:
break;
}
}
for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); iter++) {
}
{
}
{
}
{
}
{
}
{
}
}
void SelectedStyle::on_opacity_changed () {
if (_opacity_blocked)
return;
_opacity_blocked = true;
_opacity_blocked = false;
}
} // namespace Widget
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :