summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
committerTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
commit9e023a3aa964a0d3fa1e31e46d33657367ba68aa (patch)
tree33f1392a340737e4eeefca6fd031f96c29befd2b /src/ui/widget
parentInstalling the pkgconfig file (diff)
parentAdding in shape-record.h (diff)
downloadinkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.tar.gz
inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.zip
Merge from trunk
(bzr r8254.1.53)
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/color-picker.cpp11
-rw-r--r--src/ui/widget/labelled.h2
-rw-r--r--src/ui/widget/page-sizer.cpp69
-rw-r--r--src/ui/widget/page-sizer.h26
-rw-r--r--src/ui/widget/point.cpp2
-rw-r--r--src/ui/widget/point.h2
-rw-r--r--src/ui/widget/registered-widget.cpp90
-rw-r--r--src/ui/widget/registered-widget.h25
-rw-r--r--src/ui/widget/selected-style.cpp14
9 files changed, 202 insertions, 39 deletions
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index d6ae50ae3..34cf1d5e3 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -116,12 +116,15 @@ ColorPicker::on_changed (guint32)
void
sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
{
- if (_in_use) return;
- else _in_use = true;
+ if (_in_use) {
+ return;
+ } else {
+ _in_use = true;
+ }
SPColor color;
- float alpha;
- csel->base->getColorAlpha(color, &alpha);
+ float alpha = 0;
+ csel->base->getColorAlpha(color, alpha);
guint32 rgba = color.toRGBA32( alpha );
ColorPicker *ptr = (ColorPicker *)(cp);
diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h
index 3685944a4..5670af0b6 100644
--- a/src/ui/widget/labelled.h
+++ b/src/ui/widget/labelled.h
@@ -39,6 +39,8 @@ public:
Gtk::Widget const *getWidget() const;
Gtk::Label const *getLabel() const;
+ void setLabelText(const Glib::ustring &str) { _label->set_text(str); };
+
protected:
Gtk::Widget *_widget;
Gtk::Label *_label;
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 68f26792a..e604a24ec 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -229,6 +229,11 @@ PageSizer::PageSizer(Registry & _wr)
_dimensionUnits( _("U_nits:"), "units", _wr ),
_dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ),
_dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ),
+ _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ),
+ _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr),
+ _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr),
+ _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr),
+
_widgetRegistry(&_wr)
{
//# Set up the Paper Size combo box
@@ -273,16 +278,11 @@ PageSizer::PageSizer(Registry & _wr)
// _paperSizeListSelection->select(iter);
- pack_start (_paperSizeListBox, true, true, 0);
- _paperSizeListLabel.set_label(_("P_age size:"));
- _paperSizeListLabel.set_use_underline();
- _paperSizeListBox.pack_start (_paperSizeListLabel, false, false, 0);
- _paperSizeListLabel.set_mnemonic_widget (_paperSizeList);
- _paperSizeListBox.pack_start (_paperSizeListScroller, true, true, 0);
+ pack_start (_paperSizeListScroller, true, true, 0);
//## Set up orientation radio buttons
pack_start (_orientationBox, false, false, 0);
- _orientationLabel.set_label(_("Page orientation:"));
+ _orientationLabel.set_label(_("Orientation:"));
_orientationBox.pack_start(_orientationLabel, false, false, 0);
_landscapeButton.set_use_underline();
_landscapeButton.set_label(_("_Landscape"));
@@ -299,19 +299,48 @@ PageSizer::PageSizer(Registry & _wr)
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
pack_start (_customFrame, false, false, 0);
- _customTable.resize(2, 2);
- _customTable.set_border_width (4);
- _customTable.set_row_spacings (4);
- _customTable.set_col_spacings (4);
- _customTable.attach(_dimensionWidth, 0,1,0,1);
- _customTable.attach(_dimensionUnits, 1,2,0,1);
- _customTable.attach(_dimensionHeight, 0,1,1,2);
- _customTable.attach(_fitPageButton, 1,2,1,2);
- _customFrame.add(_customTable);
-
+ _customFrame.add(_customDimTable);
+
+ _customDimTable.resize(3, 2);
+ _customDimTable.set_border_width(4);
+ _customDimTable.set_row_spacings(4);
+ _customDimTable.set_col_spacings(4);
+ _customDimTable.attach(_dimensionWidth, 0,1, 0,1);
+ _customDimTable.attach(_dimensionUnits, 1,2, 0,1);
+ _customDimTable.attach(_dimensionHeight, 0,1, 1,2);
+ _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3);
+
+ //## Set up fit page expander
+ _fitPageMarginExpander.set_label(_("Resi_ze page to content..."));
+ _fitPageMarginExpander.set_use_underline();
+ _fitPageMarginExpander.add(_marginTable);
+
+ //## Set up margin settings
+ _marginTable.resize(4, 2);
+ _marginTable.set_border_width(4);
+ _marginTable.set_row_spacings(4);
+ _marginTable.set_col_spacings(4);
+ _marginTable.attach(_fitPageButtonAlign, 0,2, 0,1);
+ _marginTable.attach(_marginTopAlign, 0,2, 1,2);
+ _marginTable.attach(_marginLeftAlign, 0,1, 2,3);
+ _marginTable.attach(_marginRightAlign, 1,2, 2,3);
+ _marginTable.attach(_marginBottomAlign, 0,2, 3,4);
+
+ _marginTopAlign.set(0.5, 0.5, 0.0, 1.0);
+ _marginTopAlign.add(_marginTop);
+ _marginLeftAlign.set(0.0, 0.5, 0.0, 1.0);
+ _marginLeftAlign.add(_marginLeft);
+ _marginRightAlign.set(1.0, 0.5, 0.0, 1.0);
+ _marginRightAlign.add(_marginRight);
+ _marginBottomAlign.set(0.5, 0.5, 0.0, 1.0);
+ _marginBottomAlign.add(_marginBottom);
+
+ _fitPageButtonAlign.set(0.5, 0.5, 0.0, 1.0);
+ _fitPageButtonAlign.add(_fitPageButton);
_fitPageButton.set_use_underline();
- _fitPageButton.set_label(_("_Fit page to selection"));
+ _fitPageButton.set_label(_("_Resize page to drawing or selection"));
_tips.set_tip(_fitPageButton, _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
+
}
@@ -343,7 +372,7 @@ PageSizer::init ()
/**
* Set document dimensions (if not called by Doc prop's update()) and
* set the PageSizer's widgets and text entries accordingly. If
- * 'chageList' is true, then adjust the paperSizeList to show the closest
+ * 'changeList' is true, then adjust the paperSizeList to show the closest
* standard page size.
*
* \param w, h given in px
@@ -454,7 +483,7 @@ PageSizer::find_paper_size (double w, double h) const
/**
- * Tell the desktop to change the page size
+ * Tell the desktop to fit the page size to the selection or drawing.
*/
void
PageSizer::fire_fit_canvas_to_selection_or_drawing()
diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h
index f970afe44..718eb95b5 100644
--- a/src/ui/widget/page-sizer.h
+++ b/src/ui/widget/page-sizer.h
@@ -183,24 +183,38 @@ protected:
Gtk::HBox _orientationBox;
Gtk::Label _orientationLabel;
Gtk::RadioButton _portraitButton;
- Gtk::RadioButton _landscapeButton;
+ Gtk::RadioButton _landscapeButton;
//callbacks
void on_portrait();
void on_landscape();
sigc::connection _portrait_connection;
- sigc::connection _landscape_connection;
+ sigc::connection _landscape_connection;
//### Custom size frame
Gtk::Frame _customFrame;
- Gtk::Table _customTable;
+ Gtk::Table _customDimTable;
RegisteredUnitMenu _dimensionUnits;
RegisteredScalarUnit _dimensionWidth;
- RegisteredScalarUnit _dimensionHeight;
- Gtk::Button _fitPageButton;
+ RegisteredScalarUnit _dimensionHeight;
+
+ //### Fit Page options
+ Gtk::Expander _fitPageMarginExpander;
+ Gtk::Table _marginTable;
+ Gtk::Alignment _marginTopAlign;
+ Gtk::Alignment _marginLeftAlign;
+ Gtk::Alignment _marginRightAlign;
+ Gtk::Alignment _marginBottomAlign;
+ RegisteredScalar _marginTop;
+ RegisteredScalar _marginLeft;
+ RegisteredScalar _marginRight;
+ RegisteredScalar _marginBottom;
+ Gtk::Alignment _fitPageButtonAlign;
+ Gtk::Button _fitPageButton;
+
//callback
void on_value_changed();
sigc::connection _changedw_connection;
- sigc::connection _changedh_connection;
+ sigc::connection _changedh_connection;
Registry *_widgetRegistry;
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
index 508a8d961..f27cfe8c6 100644
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
@@ -194,7 +194,7 @@ Point::setRange(double min, double max)
/** Sets the value of the spin button */
void
-Point::setValue(Geom::Point & p)
+Point::setValue(Geom::Point const & p)
{
xwidget.setValue(p[0]);
ywidget.setValue(p[1]);
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 57a46de76..94477d877 100644
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
@@ -64,7 +64,7 @@ public:
void setDigits(unsigned digits);
void setIncrements(double step, double page);
void setRange(double min, double max);
- void setValue(Geom::Point & p);
+ void setValue(Geom::Point const & p);
void update();
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 95ddec286..db31d08d3 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -587,6 +587,96 @@ RegisteredTransformedPoint::on_value_changed()
}
/*#########################################
+ * Registered TRANSFORMEDPOINT
+ */
+
+RegisteredVector::~RegisteredVector()
+{
+ _value_x_changed_connection.disconnect();
+ _value_y_changed_connection.disconnect();
+}
+
+RegisteredVector::RegisteredVector ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<Point> (label, tip),
+ _polar_coords(false)
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ setRange (-1e6, 1e6);
+ setDigits (2);
+ setIncrements(0.1, 1.0);
+ _value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+ _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p)
+{
+ if (!_polar_coords) {
+ Point::setValue(p);
+ } else {
+ Geom::Point polar;
+ polar[Geom::X] = atan2(p) *180/M_PI;
+ polar[Geom::Y] = p.length();
+ Point::setValue(polar);
+ }
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin)
+{
+ RegisteredVector::setValue(p);
+ _origin = origin;
+}
+
+/**
+ * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector.
+ * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length.
+ * After changing the coords type (polar/non-polar), the value has to be reset (setValue).
+ */
+void
+RegisteredVector::setPolarCoords(bool polar_coords)
+{
+ _polar_coords = polar_coords;
+ if (polar_coords) {
+ xwidget.setLabelText("Angle:");
+ ywidget.setLabelText("Distance:");
+ } else {
+ xwidget.setLabelText("X:");
+ ywidget.setLabelText("Y:");
+ }
+}
+
+void
+RegisteredVector::on_value_changed()
+{
+ if (setProgrammatically()) {
+ clearProgrammatically();
+ return;
+ }
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Geom::Point origin = _origin;
+ Geom::Point vector = getValue();
+ if (_polar_coords) {
+ vector = Geom::Point::polar(vector[Geom::X]*M_PI/180, vector[Geom::Y]);
+ }
+
+ Inkscape::SVGOStringStream os;
+ os << origin << " , " << vector;
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
+/*#########################################
* Registered RANDOM
*/
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index a5c61f68a..7aefbb90e 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -334,6 +334,31 @@ protected:
};
+class RegisteredVector : public RegisteredWidget<Point> {
+public:
+ virtual ~RegisteredVector();
+ RegisteredVector (const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
+
+ // redefine setValue, because transform must be applied
+ void setValue(Geom::Point const & p);
+ void setValue(Geom::Point const & p, Geom::Point const & origin);
+ void setPolarCoords(bool polar_coords = true);
+
+protected:
+ sigc::connection _value_x_changed_connection;
+ sigc::connection _value_y_changed_connection;
+ void on_value_changed();
+
+ Geom::Point _origin;
+ bool _polar_coords;
+};
+
+
class RegisteredRandom : public RegisteredWidget<Random> {
public:
virtual ~RegisteredRandom();
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index e7b0188d8..a8f9f9c60 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -103,7 +103,7 @@ static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop);
SelectedStyle::SelectedStyle(bool /*layout*/)
- :
+ :
current_stroke_width(0),
_desktop (NULL),
@@ -955,13 +955,13 @@ SelectedStyle::update()
_paintserver_id[i] += ")";
if (SP_IS_LINEARGRADIENT (server)) {
- SPGradient *vector = sp_gradient_get_vector(SP_GRADIENT(server), false);
+ SPGradient *vector = SP_GRADIENT(server)->getVector();
sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_l[i], vector);
place->add(_gradient_box_l[i]);
_tooltips.set_tip(*place, __lgradient[i]);
_mode[i] = SS_LGRADIENT;
} else if (SP_IS_RADIALGRADIENT (server)) {
- SPGradient *vector = sp_gradient_get_vector(SP_GRADIENT(server), false);
+ SPGradient *vector = SP_GRADIENT(server)->getVector();
sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_r[i], vector);
place->add(_gradient_box_r[i]);
_tooltips.set_tip(*place, __rgradient[i]);
@@ -1165,7 +1165,7 @@ RotateableSwatch::RotateableSwatch(SelectedStyle *parent, guint mode) :
undokey("ssrot1"),
cr(0),
cr_set(false)
-
+
{
}
@@ -1426,14 +1426,14 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
{
- if (Dialog::PanelDialogBase *panel_dialog =
+ if (Dialog::PanelDialogBase *panel_dialog =
dynamic_cast<Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("FillAndStroke"))) {
try {
- Dialog::FillAndStroke &fill_and_stroke =
+ Dialog::FillAndStroke &fill_and_stroke =
dynamic_cast<Dialog::FillAndStroke &>(panel_dialog->getPanel());
return &fill_and_stroke;
} catch (std::exception e) { }
- }
+ }
return 0;
}