summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Declara <declara91@gmail.com>2012-03-28 15:44:47 +0000
committerDenis Declara <declara91@gmail.com>2012-03-28 15:44:47 +0000
commit3f7eff8696693c9b946fe47c2831c8706bffb68d (patch)
tree94f7255413c865ddbe05341d138cc16c2bd489d0 /src
parentTrunk merge (diff)
downloadinkscape-3f7eff8696693c9b946fe47c2831c8706bffb68d.tar.gz
inkscape-3f7eff8696693c9b946fe47c2831c8706bffb68d.zip
Integrated the newly created Anchor-Selection-Widget with the existing "Rows and Columns" panel.
Code still needs documentation and cleenup however. (bzr r11073.1.5)
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/tile.cpp56
-rw-r--r--src/ui/dialog/tile.h25
-rw-r--r--src/ui/widget/anchor-selector.cpp82
-rw-r--r--src/ui/widget/anchor-selector.h19
4 files changed, 47 insertions, 135 deletions
diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp
index 5ce41c716..4a5e9785f 100644
--- a/src/ui/dialog/tile.cpp
+++ b/src/ui/dialog/tile.cpp
@@ -517,39 +517,15 @@ void TileDialog::Spacing_button_changed()
}
/**
- * changed Radio button in Vertical Align group.
+ * changed Anchor selection widget.
*/
-void TileDialog::VertAlign_changed()
+void TileDialog::Align_changed()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (VertTopRadioButton.get_active()) {
- VertAlign = 0;
- prefs->setInt("/dialogs/gridtiler/VertAlign", 0);
- } else if (VertCentreRadioButton.get_active()){
- VertAlign = 1;
- prefs->setInt("/dialogs/gridtiler/VertAlign", 1);
- } else if (VertBotRadioButton.get_active()){
- VertAlign = 2;
- prefs->setInt("/dialogs/gridtiler/VertAlign", 2);
- }
-}
-
-/**
- * changed Radio button in Vertical Align group.
- */
-void TileDialog::HorizAlign_changed()
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (HorizLeftRadioButton.get_active()) {
- HorizAlign = 0;
- prefs->setInt("/dialogs/gridtiler/HorizAlign", 0);
- } else if (HorizCentreRadioButton.get_active()){
- HorizAlign = 1;
- prefs->setInt("/dialogs/gridtiler/HorizAlign", 1);
- } else if (HorizRightRadioButton.get_active()){
- HorizAlign = 2;
- prefs->setInt("/dialogs/gridtiler/HorizAlign", 2);
- }
+ VertAlign = AlignmentSelector.getVerticalAlignment();
+ prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign);
+ HorizAlign = AlignmentSelector.getHorizontalAlignment();
+ prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign);
}
/**
@@ -685,8 +661,8 @@ TileDialog::TileDialog()
RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it"));
RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_RowSize_checkbutton_changed));
- {
- /*#### Radio buttons to control vertical alignment ####*/
+/* {
+ /*#### Radio buttons to control vertical alignment ####*//*
VertAlignLabel.set_label(_("Align:"));
VertAlignHBox.pack_start(VertAlignLabel, false, false, MARGIN);
@@ -715,7 +691,7 @@ TileDialog::TileDialog()
}
VertAlignHBox.pack_start(VertAlignVBox, false, false, MARGIN);
NoOfRowsBox.pack_start(VertAlignHBox, false, false, MARGIN);
- }
+ }*/
SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN);
@@ -757,8 +733,8 @@ TileDialog::TileDialog()
ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_ColSize_checkbutton_changed));
- {
- /*#### Radio buttons to control horizontal alignment ####*/
+ /*{
+ /*#### Radio buttons to control horizontal alignment ####*//*
HorizAlignLabel.set_label(_("Align:"));
HorizAlignVBox.pack_start(HorizAlignLabel, false, false, MARGIN);
@@ -791,12 +767,18 @@ TileDialog::TileDialog()
}
HorizAlignVBox.pack_start(HorizAlignHBox, false, false, MARGIN);
NoOfColsBox.pack_start(HorizAlignVBox, false, false, MARGIN);
- }
+ }*/
SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN);
TileBox.pack_start(SpinsHBox, false, false, MARGIN);
- TileBox.pack_start(anchorSelector);
+
+
+ // Anchor selection widget
+ AlignLabel.set_label("Alignment:");
+ AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &TileDialog::Align_changed));
+ TileBox.pack_start(AlignLabel, false, false, MARGIN);
+ TileBox.pack_start(AlignmentSelector, true, false, MARGIN);
{
/*#### Radio buttons to control spacing manually or to fit selection bbox ####*/
diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h
index f1493664d..b3bf390b6 100644
--- a/src/ui/dialog/tile.h
+++ b/src/ui/dialog/tile.h
@@ -67,8 +67,7 @@ public:
void on_rowSize_spinbutton_changed();
void on_colSize_spinbutton_changed();
void Spacing_button_changed();
- void VertAlign_changed();
- void HorizAlign_changed();
+ void Align_changed();
static TileDialog& getInstance() { return *new TileDialog(); }
@@ -79,8 +78,6 @@ private:
bool userHidden;
bool updating;
- AnchorSelector anchorSelector;
-
Gtk::Notebook notebook;
Gtk::VBox TileBox;
@@ -112,24 +109,10 @@ private:
bool AutoColSize;
Gtk::CheckButton ColumnWidthButton;
- // Vertical align
- Gtk::Label VertAlignLabel;
- Gtk::HBox VertAlignHBox;
- Gtk::VBox VertAlignVBox;
- Gtk::RadioButtonGroup VertAlignGroup;
- Gtk::RadioButton VertCentreRadioButton;
- Gtk::RadioButton VertTopRadioButton;
- Gtk::RadioButton VertBotRadioButton;
+ // Alignment
+ Gtk::Label AlignLabel;
+ AnchorSelector AlignmentSelector;
double VertAlign;
-
- // Horizontal align
- Gtk::Label HorizAlignLabel;
- Gtk::VBox HorizAlignVBox;
- Gtk::HBox HorizAlignHBox;
- Gtk::RadioButtonGroup HorizAlignGroup;
- Gtk::RadioButton HorizCentreRadioButton;
- Gtk::RadioButton HorizLeftRadioButton;
- Gtk::RadioButton HorizRightRadioButton;
double HorizAlign;
Inkscape::UI::Widget::ScalarUnit XPadding;
diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp
index f32346436..aa173e0a0 100644
--- a/src/ui/widget/anchor-selector.cpp
+++ b/src/ui/widget/anchor-selector.cpp
@@ -3,6 +3,8 @@
*
* Created on: Mar 22, 2012
* Author: denis
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#include <iostream>
@@ -34,17 +36,9 @@ AnchorSelector::AnchorSelector()
setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]);
setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]);
- _buttons[0].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tl_activated));
- _buttons[1].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_t_activated));
- _buttons[2].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tr_activated));
- _buttons[3].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_l_activated));
- _buttons[4].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_c_activated));
- _buttons[5].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_r_activated));
- _buttons[6].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_bl_activated));
- _buttons[7].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_b_activated));
- _buttons[8].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_br_activated));
-
for(int i = 0; i < 9; ++i) {
+ _buttons[i].signal_clicked().connect(
+ sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i));
_container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL);
}
_selection = 4;
@@ -60,64 +54,16 @@ AnchorSelector::~AnchorSelector()
void AnchorSelector::btn_activated(int index)
{
- if(_buttons[index].get_active())
+
+ if(_selection == index && _buttons[index].get_active() == false)
{
- std::cout << "btn_activated(" << index << ", old=" << _selection << ");" << std::endl;
- if(index != _selection)
- {
- _buttons[_selection].set_active(false);
- _buttons[index].set_active();
- _selection = index;
- } else {
- _buttons[index].set_active();
- }
+ _buttons[index].set_active(true);
+ }
+ else if(_selection != index && _buttons[index].get_active())
+ {
+ int old_selection = _selection;
+ _selection = index;
+ _buttons[old_selection].set_active(false);
+ _selectionChanged.emit();
}
}
-
-void AnchorSelector::btn_tl_activated()
-{
- btn_activated(0);
-}
-
-void AnchorSelector::btn_t_activated()
-{
- btn_activated(1);
-}
-
-void AnchorSelector::btn_tr_activated()
-{
- btn_activated(2);
-}
-
-void AnchorSelector::btn_l_activated()
-{
- btn_activated(3);
-}
-
-void AnchorSelector::btn_c_activated()
-{
- btn_activated(4);
-}
-
-void AnchorSelector::btn_r_activated()
-{
- btn_activated(5);
-}
-
-void AnchorSelector::btn_bl_activated()
-{
- btn_activated(6);
-}
-
-void AnchorSelector::btn_b_activated()
-{
- btn_activated(7);
-}
-
-void AnchorSelector::btn_br_activated()
-{
- btn_activated(8);
-}
-
-
-
diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h
index c852a1a5d..ad20bf063 100644
--- a/src/ui/widget/anchor-selector.h
+++ b/src/ui/widget/anchor-selector.h
@@ -3,6 +3,8 @@
*
* Created on: Mar 22, 2012
* Author: denis
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifndef ANCHOR_SELECTOR_H_
@@ -17,19 +19,18 @@ private:
int _selection;
Gtk::Table _container;
+ sigc::signal<void> _selectionChanged;
+
void setupButton(const Glib::ustring &icon, Gtk::ToggleButton &button);
void btn_activated(int index);
- void btn_tl_activated();
- void btn_t_activated();
- void btn_tr_activated();
- void btn_l_activated();
- void btn_c_activated();
- void btn_r_activated();
- void btn_bl_activated();
- void btn_b_activated();
- void btn_br_activated();
public:
+
+ int getHorizontalAlignment() { return _selection % 3; }
+ int getVerticalAlignment() { return _selection / 3; }
+
+ sigc::signal<void> &on_selectionChanged() { return _selectionChanged; }
+
AnchorSelector();
virtual ~AnchorSelector();
};