index 3c996f665bc6ccf31a8d90b99a8b6c1c32f6ec1e..520d7f40402ddac306e3ceca4a3341ad2754a3d9 100644 (file)
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
+#include "ui/dialog/panel-dialog.h"
#include "xml/repr.h"
#include "document.h"
#include "widgets/widget-sizes.h"
#include "xml/repr.h"
#include "document.h"
#include "widgets/widget-sizes.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 *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
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 *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
ss_selection_changed (Inkscape::Selection *, gpointer data)
{
Inkscape::UI::Widget::SelectedStyle *ss = (Inkscape::UI::Widget::SelectedStyle *) data;
ss_selection_changed (Inkscape::Selection *, gpointer data)
{
Inkscape::UI::Widget::SelectedStyle *ss = (Inkscape::UI::Widget::SelectedStyle *) data;
}
static void
}
static void
-ss_selection_modified (Inkscape::Selection *selection, guint flags, gpointer data)
+ss_selection_modified( Inkscape::Selection *selection, guint /*flags*/, gpointer data )
{
ss_selection_changed (selection, data);
}
static void
{
ss_selection_changed (selection, data);
}
static void
-ss_subselection_changed (gpointer dragger, gpointer data)
+ss_subselection_changed( gpointer /*dragger*/, gpointer data )
{
ss_selection_changed (NULL, data);
}
{
ss_selection_changed (NULL, data);
}
#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
+/* convenience function */
+static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop);
+
+SelectedStyle::SelectedStyle(bool /*layout*/)
+ :
+ current_stroke_width(0),
-SelectedStyle::SelectedStyle(bool layout)
- : _desktop (NULL),
+ _desktop (NULL),
_table(2, 6),
_fill_label (_("Fill:")),
_table(2, 6),
_fill_label (_("Fill:")),
_opacity_sb (0.02, 0),
_stroke (),
_opacity_sb (0.02, 0),
_stroke (),
+ _stroke_width_place(),
_stroke_width (""),
_opacity_blocked (false),
_stroke_width (""),
_opacity_blocked (false),
__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)));
__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_edit[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_edit[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_edit : &SelectedStyle::on_stroke_edit ));
_popup_lastused[i].add(*(new Gtk::Label(_("Last set color"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_edit : &SelectedStyle::on_stroke_edit ));
_popup_lastused[i].add(*(new Gtk::Label(_("Last set color"), 0.0, 0.5)));
- _popup_lastused[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_lastused[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_lastused : &SelectedStyle::on_stroke_lastused ));
_popup_lastselected[i].add(*(new Gtk::Label(_("Last selected color"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_lastused : &SelectedStyle::on_stroke_lastused ));
_popup_lastselected[i].add(*(new Gtk::Label(_("Last selected color"), 0.0, 0.5)));
- _popup_lastselected[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_lastselected[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_lastselected : &SelectedStyle::on_stroke_lastselected ));
_popup_invert[i].add(*(new Gtk::Label(_("Invert"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_lastselected : &SelectedStyle::on_stroke_lastselected ));
_popup_invert[i].add(*(new Gtk::Label(_("Invert"), 0.0, 0.5)));
- _popup_invert[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_invert[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_invert : &SelectedStyle::on_stroke_invert ));
_popup_white[i].add(*(new Gtk::Label(_("White"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_invert : &SelectedStyle::on_stroke_invert ));
_popup_white[i].add(*(new Gtk::Label(_("White"), 0.0, 0.5)));
- _popup_white[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_white[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_white : &SelectedStyle::on_stroke_white ));
_popup_black[i].add(*(new Gtk::Label(_("Black"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_white : &SelectedStyle::on_stroke_white ));
_popup_black[i].add(*(new Gtk::Label(_("Black"), 0.0, 0.5)));
- _popup_black[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_black[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_black : &SelectedStyle::on_stroke_black ));
_popup_copy[i].add(*(new Gtk::Label(_("Copy color"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_black : &SelectedStyle::on_stroke_black ));
_popup_copy[i].add(*(new Gtk::Label(_("Copy color"), 0.0, 0.5)));
- _popup_copy[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_copy[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_copy : &SelectedStyle::on_stroke_copy ));
_popup_paste[i].add(*(new Gtk::Label(_("Paste color"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_copy : &SelectedStyle::on_stroke_copy ));
_popup_paste[i].add(*(new Gtk::Label(_("Paste color"), 0.0, 0.5)));
- _popup_paste[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_paste[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_paste : &SelectedStyle::on_stroke_paste ));
_popup_swap[i].add(*(new Gtk::Label(_("Swap fill and stroke"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_paste : &SelectedStyle::on_stroke_paste ));
_popup_swap[i].add(*(new Gtk::Label(_("Swap fill and stroke"), 0.0, 0.5)));
- _popup_swap[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_swap[i].signal_activate().connect(sigc::mem_fun(*this,
&SelectedStyle::on_fillstroke_swap));
_popup_opaque[i].add(*(new Gtk::Label((i == SS_FILL)? _("Make fill opaque") : _("Make stroke opaque"), 0.0, 0.5)));
&SelectedStyle::on_fillstroke_swap));
_popup_opaque[i].add(*(new Gtk::Label((i == SS_FILL)? _("Make fill opaque") : _("Make stroke opaque"), 0.0, 0.5)));
- _popup_opaque[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_opaque[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_opaque : &SelectedStyle::on_stroke_opaque ));
//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)));
(i == SS_FILL)? &SelectedStyle::on_fill_opaque : &SelectedStyle::on_stroke_opaque ));
//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_unset[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_unset[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_unset : &SelectedStyle::on_stroke_unset ));
_popup_remove[i].add(*(new Gtk::Label((i == SS_FILL)? _("Remove fill") : _("Remove stroke"), 0.0, 0.5)));
(i == SS_FILL)? &SelectedStyle::on_fill_unset : &SelectedStyle::on_stroke_unset ));
_popup_remove[i].add(*(new Gtk::Label((i == SS_FILL)? _("Remove fill") : _("Remove stroke"), 0.0, 0.5)));
- _popup_remove[i].signal_activate().connect(sigc::mem_fun(*this,
+ _popup_remove[i].signal_activate().connect(sigc::mem_fun(*this,
(i == SS_FILL)? &SelectedStyle::on_fill_remove : &SelectedStyle::on_stroke_remove ));
_popup[i].attach(_popup_edit[i], 0,1, 0,1);
(i == SS_FILL)? &SelectedStyle::on_fill_remove : &SelectedStyle::on_stroke_remove ));
_popup[i].attach(_popup_edit[i], 0,1, 0,1);
_popup_copy[i].set_sensitive(false);
_popup[i].attach(_popup_paste[i], 0,1, 11,12);
_popup[i].attach(_popup_swap[i], 0,1, 12,13);
_popup_copy[i].set_sensitive(false);
_popup[i].attach(_popup_paste[i], 0,1, 11,12);
_popup[i].attach(_popup_swap[i], 0,1, 12,13);
- _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 13,14);
+ _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 13,14);
_popup[i].attach(_popup_opaque[i], 0,1, 14,15);
_popup[i].attach(_popup_unset[i], 0,1, 15,16);
_popup[i].attach(_popup_remove[i], 0,1, 16,17);
_popup[i].attach(_popup_opaque[i], 0,1, 14,15);
_popup[i].attach(_popup_unset[i], 0,1, 15,16);
_popup[i].attach(_popup_remove[i], 0,1, 16,17);
_fill_place.parent = this;
_stroke_place.parent = this;
_fill_place.parent = this;
_stroke_place.parent = this;
+ _stroke_width_place.parent = this;
}
SelectedStyle::~SelectedStyle()
}
SelectedStyle::~SelectedStyle()
for (int i = SS_FILL; i <= SS_STROKE; i++) {
delete _color_preview[i];
for (int i = SS_FILL; i <= SS_STROKE; i++) {
delete _color_preview[i];
- // FIXME: do we need this? the destroy methods are not exported
+ // FIXME: do we need this? the destroy methods are not exported
//sp_gradient_image_destroy(GTK_OBJECT(_gradient_preview_l[i]));
//sp_gradient_image_destroy(GTK_OBJECT(_gradient_preview_r[i]));
}
//sp_gradient_image_destroy(GTK_OBJECT(_gradient_preview_l[i]));
//sp_gradient_image_destroy(GTK_OBJECT(_gradient_preview_r[i]));
}
//_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units;
}
//_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units;
}
-void SelectedStyle::dragDataReceived( GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x, gint y,
+void SelectedStyle::dragDataReceived( GtkWidget */*widget*/,
+ GdkDragContext */*drag_context*/,
+ gint /*x*/, gint /*y*/,
GtkSelectionData *data,
GtkSelectionData *data,
- guint info,
- guint event_time,
+ guint /*info*/,
+ guint /*event_time*/,
gpointer user_data )
{
DropTracker* tracker = (DropTracker*)user_data;
gpointer user_data )
{
DropTracker* tracker = (DropTracker*)user_data;
sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c );
sp_desktop_set_style( tracker->parent->_desktop, css );
sp_repr_css_attr_unref( css );
sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c );
sp_desktop_set_style( tracker->parent->_desktop, css );
sp_repr_css_attr_unref( css );
- sp_document_done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE,
+ sp_document_done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE,
_("Drop color"));
}
}
_("Drop color"));
}
}
void SelectedStyle::on_fill_remove() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "fill", "none");
void SelectedStyle::on_fill_remove() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "fill", "none");
- sp_desktop_set_style (_desktop, css, true, true);
+ sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Remove fill"));
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Remove fill"));
void SelectedStyle::on_stroke_remove() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "stroke", "none");
void SelectedStyle::on_stroke_remove() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "stroke", "none");
- sp_desktop_set_style (_desktop, css, true, true);
+ sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Remove stroke"));
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Remove stroke"));
void SelectedStyle::on_fill_unset() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_unset_property (css, "fill");
void SelectedStyle::on_fill_unset() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_unset_property (css, "fill");
- sp_desktop_set_style (_desktop, css, true, true);
+ sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Unset fill"));
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Unset fill"));
sp_repr_css_set_property (css, "fill", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "fill", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last set color to fill"));
}
_("Apply last set color to fill"));
}
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last set color to stroke"));
}
_("Apply last set color to stroke"));
}
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last selected color to stroke"));
}
_("Apply last selected color to stroke"));
}
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Invert stroke"));
sp_repr_css_attr_unref (css);
sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Invert stroke"));
-}
+}
void SelectedStyle::on_fill_white() {
SPCSSAttr *css = sp_repr_css_attr_new ();
void SelectedStyle::on_fill_white() {
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "stroke-opacity", "1");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "stroke-opacity", "1");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("White stroke"));
}
_("White stroke"));
}
sp_repr_css_set_property (css, "fill-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "fill-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Black fill"));
}
_("Black fill"));
}
sp_repr_css_set_property (css, "stroke-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "stroke-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Black stroke"));
}
_("Black stroke"));
}
sp_repr_css_set_property (css, "fill", text.c_str());
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "fill", text.c_str());
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Paste fill"));
}
}
_("Paste fill"));
}
}
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
_("Swap fill and stroke"));
}
void SelectedStyle::on_fill_edit() {
_("Swap fill and stroke"));
}
void SelectedStyle::on_fill_edit() {
- if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
- _desktop->_dlg_mgr->getDialog("FillAndStroke")))
- dialog->showPageFill();
+ if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+ fs->showPageFill();
}
void SelectedStyle::on_stroke_edit() {
}
void SelectedStyle::on_stroke_edit() {
- if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
- _desktop->_dlg_mgr->getDialog("FillAndStroke")))
- dialog->showPageStrokePaint();
+ if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+ fs->showPageStrokePaint();
}
}
-bool
+bool
SelectedStyle::on_fill_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
SelectedStyle::on_fill_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
- if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
- _desktop->_dlg_mgr->getDialog("FillAndStroke")))
- dialog->showPageFill();
+ if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+ fs->showPageFill();
} else if (event->button == 3) { // right-click, popup menu
_popup[SS_FILL].popup(event->button, event->time);
} else if (event->button == 3) { // right-click, popup menu
_popup[SS_FILL].popup(event->button, event->time);
return true;
}
return true;
}
-bool
+bool
SelectedStyle::on_stroke_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
SelectedStyle::on_stroke_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
- if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
- _desktop->_dlg_mgr->getDialog("FillAndStroke")))
- dialog->showPageStrokePaint();
+ if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+ fs->showPageStrokePaint();
} else if (event->button == 3) { // right-click, popup menu
_popup[SS_STROKE].popup(event->button, event->time);
} else if (event->button == 2) { // middle click, toggle none/lastcolor
} else if (event->button == 3) { // right-click, popup menu
_popup[SS_STROKE].popup(event->button, event->time);
} else if (event->button == 2) { // middle click, toggle none/lastcolor
return true;
}
return true;
}
-bool
+bool
SelectedStyle::on_sw_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
SelectedStyle::on_sw_click(GdkEventButton *event)
{
if (event->button == 1) { // click, open fill&stroke
- if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
- _desktop->_dlg_mgr->getDialog("FillAndStroke")))
- dialog->showPageStrokeStyle();
+ if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+ fs->showPageStrokeStyle();
} else if (event->button == 3) { // right-click, popup menu
_popup_sw.popup(event->button, event->time);
} else if (event->button == 2) { // middle click, toggle none/lastwidth?
} else if (event->button == 3) { // right-click, popup menu
_popup_sw.popup(event->button, event->time);
} else if (event->button == 2) { // middle click, toggle none/lastwidth?
return true;
}
return true;
}
-bool
+bool
SelectedStyle::on_opacity_click(GdkEventButton *event)
{
if (event->button == 2) { // middle click
SelectedStyle::on_opacity_click(GdkEventButton *event)
{
if (event->button == 2) { // middle click
_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
_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
- int result = sp_desktop_query_style (_desktop, query,
+ int result = sp_desktop_query_style (_desktop, query,
(i == SS_FILL)? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
switch (result) {
case QUERY_STYLE_NOTHING:
(i == SS_FILL)? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
switch (result) {
case QUERY_STYLE_NOTHING:
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
- case QUERY_STYLE_MULTIPLE_SAME:
+ case QUERY_STYLE_MULTIPLE_SAME:
if ( !_dropEnabled[i] ) {
gtk_drag_dest_set( GTK_WIDGET( (i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()),
GTK_DEST_DEFAULT_ALL,
if ( !_dropEnabled[i] ) {
gtk_drag_dest_set( GTK_WIDGET( (i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()),
GTK_DEST_DEFAULT_ALL,
switch (result_sw) {
case QUERY_STYLE_NOTHING:
_stroke_width.set_markup("");
switch (result_sw) {
case QUERY_STYLE_NOTHING:
_stroke_width.set_markup("");
+ current_stroke_width = 0;
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
- case QUERY_STYLE_MULTIPLE_SAME:
+ case QUERY_STYLE_MULTIPLE_SAME:
{
double w;
if (_sw_unit) {
{
double w;
if (_sw_unit) {
} else {
w = query->stroke_width.computed;
}
} else {
w = query->stroke_width.computed;
}
+ current_stroke_width = w;
+
{
gchar *str = g_strdup_printf(" %.3g", w);
_stroke_width.set_markup(str);
g_free (str);
}
{
{
gchar *str = g_strdup_printf(" %.3g", w);
_stroke_width.set_markup(str);
g_free (str);
}
{
- gchar *str = g_strdup_printf(_("Stroke width: %.5g%s%s"),
- w,
- _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px",
+ gchar *str = g_strdup_printf(_("Stroke width: %.5g%s%s"),
+ w,
+ _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px",
(result_sw == QUERY_STYLE_MULTIPLE_AVERAGED)?
_(" (averaged)") : "");
_tooltips.set_tip(_stroke_width_place, str);
(result_sw == QUERY_STYLE_MULTIPLE_AVERAGED)?
_(" (averaged)") : "");
_tooltips.set_tip(_stroke_width_place, str);
_opacity_blocked = false;
}
_opacity_blocked = false;
}
+/* ============================================= RotateableSwatch */
+
RotateableSwatch::RotateableSwatch(guint mode) {
fillstroke = mode;
startcolor_set = false;
RotateableSwatch::RotateableSwatch(guint mode) {
fillstroke = mode;
startcolor_set = false;
@@ -1183,9 +1191,9 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
} else { // hue
double old = hsl[0];
hsl[0] += by/2;
} else { // hue
double old = hsl[0];
hsl[0] += by/2;
- while (hsl[0] < 0)
+ while (hsl[0] < 0)
hsl[0] += 1;
hsl[0] += 1;
- while (hsl[0] > 1)
+ while (hsl[0] > 1)
hsl[0] -= 1;
diff = hsl[0] - old;
}
hsl[0] -= 1;
diff = hsl[0] - old;
}
@@ -1206,7 +1214,7 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
SPCSSAttr *css = sp_repr_css_attr_new ();
if (fillstroke == SS_FILL)
sp_repr_css_set_property (css, "fill", c);
SPCSSAttr *css = sp_repr_css_attr_new ();
if (fillstroke == SS_FILL)
sp_repr_css_set_property (css, "fill", c);
- else
+ else
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (parent->getDesktop(), css);
sp_repr_css_attr_unref (css);
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (parent->getDesktop(), css);
sp_repr_css_attr_unref (css);
@@ -1215,10 +1223,10 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
void
RotateableSwatch::do_motion(double by, guint modifier) {
void
RotateableSwatch::do_motion(double by, guint modifier) {
- if (parent->_mode[fillstroke] != SS_COLOR)
+ if (parent->_mode[fillstroke] != SS_COLOR)
return;
return;
- if (!cr_set) {
+ if (!cr_set && modifier != 3) {
GtkWidget *w = GTK_WIDGET(gobj());
GdkBitmap *bitmap = NULL;
GtkWidget *w = GTK_WIDGET(gobj());
GdkBitmap *bitmap = NULL;
}
float hsl[3];
}
float hsl[3];
- double diff = color_adjust(hsl, by, cc, modifier);
+ double diff = 0;
+ if (modifier != 3) {
+ diff = color_adjust(hsl, by, cc, modifier);
+ }
- if (modifier == 2) { // saturation
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
- SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
+ if (modifier == 3) { // Alt, do nothing
+
+ } else if (modifier == 2) { // saturation
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation")));
double ch = hsl[1];
double ch = hsl[1];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); without modifiers to adjust hue, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 1) { // lightness
} else if (modifier == 1) { // lightness
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
- SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness"));
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness")));
double ch = hsl[2];
double ch = hsl[2];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); without modifiers to adjust hue, with <b>Shift</b> to adjust saturation"), ch - diff, ch, diff);
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
} else { // hue
} else { // hue
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
- SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue"));
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue")));
double ch = hsl[0];
double ch = hsl[0];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
}
}
void
RotateableSwatch::do_release(double by, guint modifier) {
}
}
void
RotateableSwatch::do_release(double by, guint modifier) {
- if (parent->_mode[fillstroke] != SS_COLOR)
+ if (parent->_mode[fillstroke] != SS_COLOR)
return;
float hsl[3];
return;
float hsl[3];
- color_adjust(hsl, by, startcolor, modifier);
+ if (modifier != 3) {
+ color_adjust(hsl, by, startcolor, modifier);
+ }
if (cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
if (cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
cr_set = false;
}
cr_set = false;
}
- if (modifier == 2) { // saturation
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ if (modifier == 3) { // Alt, do nothing
+ } else if (modifier == 2) { // saturation
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
} else if (modifier == 1) { // lightness
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
} else if (modifier == 1) { // lightness
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness"));
} else { // hue
SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness"));
} else { // hue
- sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue"));
}
SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue"));
}
startcolor_set = false;
}
startcolor_set = false;
}
+/* ============================================= RotateableStrokeWidth */
+
+RotateableStrokeWidth::RotateableStrokeWidth() {
+ undokey = "swrot1";
+ startvalue_set = false;
+ cr = NULL;
+ cr_set = false;
+}
+
+RotateableStrokeWidth::~RotateableStrokeWidth() {
+}
+
+double
+RotateableStrokeWidth::value_adjust(double current, double by, guint modifier, bool final)
+{
+ double newval;
+ // by is -1..1
+ if (by < 0) {
+ // map negative 0..-1 to current..0
+ newval = current * (1 + by);
+ } else {
+ // map positive 0..1 to current..4*current
+ newval = current * (1 + by) * (1 + by);
+ }
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ if (final && newval < 1e-6) {
+ // if dragged into zero and this is the final adjust on mouse release, delete stroke;
+ // if it's not final, leave it a chance to increase again (which is not possible with "none")
+ sp_repr_css_set_property (css, "stroke", "none");
+ } else {
+ Inkscape::CSSOStringStream os;
+ os << newval;
+ sp_repr_css_set_property (css, "stroke-width", os.str().c_str());
+ }
+
+ sp_desktop_set_style (parent->getDesktop(), css);
+ sp_repr_css_attr_unref (css);
+ return newval - current;
+}
+
+void
+RotateableStrokeWidth::do_motion(double by, guint modifier) {
+
+ // if this is the first motion after a mouse grab, remember the current width
+ if (!startvalue_set) {
+ startvalue = parent->current_stroke_width;
+ // if it's 0, adjusting (which uses multiplication) will not be able to change it, so we
+ // cheat and provide a non-zero value
+ if (startvalue == 0)
+ startvalue = 1;
+ startvalue_set = true;
+ }
+
+ if (modifier == 3) { // Alt, do nothing
+ } else {
+ double diff = value_adjust(startvalue, by, modifier, false);
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width")));
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff);
+ }
+}
+
+void
+RotateableStrokeWidth::do_release(double by, guint modifier) {
+
+ if (modifier == 3) { // do nothing
+
+ } else {
+ value_adjust(startvalue, by, modifier, true);
+ startvalue_set = false;
+ sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width")));
+ }
+
+ if (!strcmp(undokey, "swrot1")) {
+ undokey = "swrot2";
+ } else {
+ undokey = "swrot1";
+ }
+ parent->getDesktop()->event_context->_message_context->clear();
+}
+
+
+Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
+{
+ if (Dialog::PanelDialogBase *panel_dialog =
+ dynamic_cast<Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("FillAndStroke"))) {
+ try {
+ Dialog::FillAndStroke &fill_and_stroke =
+ dynamic_cast<Dialog::FillAndStroke &>(panel_dialog->getPanel());
+ return &fill_and_stroke;
+ } catch (std::exception e) { }
+ }
+
+ return 0;
+}
} // namespace Widget
} // namespace UI
} // namespace Inkscape
} // namespace Widget
} // namespace UI
} // namespace Inkscape
-/*
+/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
Local Variables:
mode:c++
c-file-style:"stroustrup"