summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Declara <declara91@gmail.com>2012-03-26 15:30:27 +0000
committerDenis Declara <declara91@gmail.com>2012-03-26 15:30:27 +0000
commit6b958fd1779e1882dbd91f714719cfae08752f67 (patch)
tree33bffa424686fdfc81c2aff6a6699d6787a5f70d /src
parenttrunk merge (diff)
downloadinkscape-6b958fd1779e1882dbd91f714719cfae08752f67.tar.gz
inkscape-6b958fd1779e1882dbd91f714719cfae08752f67.zip
Added anchor-selection widget, it doesn't do much at the moment, next step will be to wire everything together,
btw, you can see the widget in the 'rows and columns' panel (bzr r11073.1.3)
Diffstat (limited to 'src')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/tile.cpp1
-rw-r--r--src/ui/dialog/tile.h3
-rw-r--r--src/ui/widget/anchor-selector.cpp123
-rw-r--r--src/ui/widget/anchor-selector.h37
5 files changed, 166 insertions, 0 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 484edc6e2..e21c3795f 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -72,6 +72,7 @@ set(ui_SRC
# dialog/whiteboard-sharewithchat.cpp
# dialog/whiteboard-sharewithuser.cpp
+ widget/anchor-selector.cpp
widget/button.cpp
widget/color-picker.cpp
widget/color-preview.cpp
@@ -200,6 +201,7 @@ set(ui_SRC
view/view-widget.h
view/view.h
+ widget/anchor-selector.h
widget/attr-widget.h
widget/button.h
widget/color-picker.h
diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp
index 77dae056f..5ce41c716 100644
--- a/src/ui/dialog/tile.cpp
+++ b/src/ui/dialog/tile.cpp
@@ -796,6 +796,7 @@ TileDialog::TileDialog()
SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN);
TileBox.pack_start(SpinsHBox, false, false, MARGIN);
+ TileBox.pack_start(anchorSelector);
{
/*#### 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 f9e9d9842..f1493664d 100644
--- a/src/ui/dialog/tile.h
+++ b/src/ui/dialog/tile.h
@@ -20,6 +20,7 @@
#include <gtkmm/checkbutton.h>
#include <gtkmm/radiobutton.h>
+#include "ui/widget/anchor-selector.h"
#include "ui/widget/panel.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/scalar-unit.h"
@@ -78,6 +79,8 @@ private:
bool userHidden;
bool updating;
+ AnchorSelector anchorSelector;
+
Gtk::Notebook notebook;
Gtk::VBox TileBox;
diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp
new file mode 100644
index 000000000..f32346436
--- /dev/null
+++ b/src/ui/widget/anchor-selector.cpp
@@ -0,0 +1,123 @@
+/*
+ * anchor-selector.cpp
+ *
+ * Created on: Mar 22, 2012
+ * Author: denis
+ */
+
+#include <iostream>
+#include "widgets/icon.h"
+#include "ui/icon-names.h"
+#include "ui/widget/anchor-selector.h"
+
+void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) {
+ Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_LARGE_TOOLBAR));
+ buttonIcon->show();
+
+ button.set_relief(Gtk::RELIEF_NONE);
+ button.show();
+ button.add(*buttonIcon);
+ button.set_can_focus(false);
+}
+
+AnchorSelector::AnchorSelector()
+ : Gtk::Alignment(0.5, 0, 0, 0),
+ _container(3, 3, true)
+{
+ setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]);
+ setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]);
+ setupButton(INKSCAPE_ICON("boundingbox_top_right"), _buttons[2]);
+ setupButton(INKSCAPE_ICON("boundingbox_left"), _buttons[3]);
+ setupButton(INKSCAPE_ICON("boundingbox_center"), _buttons[4]);
+ setupButton(INKSCAPE_ICON("boundingbox_right"), _buttons[5]);
+ setupButton(INKSCAPE_ICON("boundingbox_bottom_left"), _buttons[6]);
+ 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) {
+ _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL);
+ }
+ _selection = 4;
+ _buttons[4].set_active();
+
+ this->add(_container);
+}
+
+AnchorSelector::~AnchorSelector()
+{
+ // TODO Auto-generated destructor stub
+}
+
+void AnchorSelector::btn_activated(int index)
+{
+ if(_buttons[index].get_active())
+ {
+ 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();
+ }
+ }
+}
+
+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
new file mode 100644
index 000000000..c852a1a5d
--- /dev/null
+++ b/src/ui/widget/anchor-selector.h
@@ -0,0 +1,37 @@
+/*
+ * anchor-selector.h
+ *
+ * Created on: Mar 22, 2012
+ * Author: denis
+ */
+
+#ifndef ANCHOR_SELECTOR_H_
+#define ANCHOR_SELECTOR_H_
+
+#include <gtkmm.h>
+
+class AnchorSelector : public Gtk::Alignment
+{
+private:
+ Gtk::ToggleButton _buttons[9];
+ int _selection;
+ Gtk::Table _container;
+
+ 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:
+ AnchorSelector();
+ virtual ~AnchorSelector();
+};
+
+#endif /* ANCHOR_SELECTOR_H_ */