1 /* === S Y N F I G ========================================================= */
2 /*! \file canvasoptions.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "canvasoptions.h"
33 #include <gtkmm/frame.h>
34 #include <gtkmm/table.h>
35 #include <gtkmm/label.h>
36 #include <gtkmm/notebook.h>
37 #include <gtkmm/alignment.h>
38 #include "canvasview.h"
45 /* === U S I N G =========================================================== */
49 using namespace synfig;
50 using namespace studio;
52 /* === M A C R O S ========================================================= */
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 CanvasOptions::CanvasOptions(etl::loose_handle<CanvasView> canvas_view):
61 Gtk::Dialog(_("Canvas Options"),*canvas_view,false,true),
62 canvas_view_(canvas_view),
63 toggle_grid_snap(_("_Snap to grid"), true),
64 toggle_grid_show(_("S_how grid"), true),
65 toggle_time_snap(_("Snap to _frame"), true)
67 vector_grid_size.set_canvas(canvas_view->get_canvas());
69 Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
70 dialogPadding->set_padding(12, 12, 12, 12);
72 Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
73 dialogPadding->add(*notebook);
75 toggle_grid_snap.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_snap_toggle));
76 toggle_grid_show.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_show_toggle));
78 Gtk::Alignment *gridPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
79 gridPadding->set_padding(12, 12, 12, 12);
80 notebook->append_page(*gridPadding, _("Grid"));
82 Gtk::VBox *gridBox = manage(new Gtk::VBox(false, 12));
83 gridPadding->add(*gridBox);
85 Gtk::Table *gridTable = manage(new Gtk::Table(3, 2, false));
86 gridTable->set_row_spacings(6);
87 gridTable->set_col_spacings(12);
88 gridBox->pack_start(*gridTable, false, false, 0);
90 Gtk::Label *gridSizeLabel = manage(new Gtk::Label(_("_Grid size"), true));
91 gridSizeLabel->set_alignment(0, 0.5);
92 gridSizeLabel->set_mnemonic_widget(vector_grid_size);
94 toggle_grid_show.set_alignment(0, 0.5);
95 toggle_grid_snap.set_alignment(0, 0.5);
97 gridTable->attach(*gridSizeLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
98 gridTable->attach(vector_grid_size, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
99 gridTable->attach(toggle_grid_show, 0, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
100 gridTable->attach(toggle_grid_snap, 0, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
102 Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
103 timePadding->set_padding(12, 12, 12, 12);
104 notebook->append_page(*timePadding, _("Time"));
106 Gtk::VBox *timeBox = manage(new Gtk::VBox(false, 12));
107 timePadding->add(*timeBox);
109 timeBox->pack_start(toggle_time_snap, false, false, 0);
111 Gtk::Alignment *unitPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
112 unitPadding->set_padding(12, 12, 12, 12);
113 notebook->append_page(*unitPadding, _("Units"));
114 unitPadding->add(*manage(new Gtk::Label(_("Not yet implemented!"))));
116 Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
118 add_action_widget(*ok_button,2);
119 ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_ok_pressed));
121 Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
122 apply_button->show();
123 add_action_widget(*apply_button,1);
124 apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_apply_pressed));
126 Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
127 cancel_button->show();
128 add_action_widget(*cancel_button,0);
129 cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_cancel_pressed));
131 //set_default_response(1);
134 get_vbox()->pack_start(*dialogPadding);
135 get_vbox()->show_all();
137 signal_show().connect(sigc::mem_fun(*this, &studio::CanvasOptions::refresh));
139 vector_grid_size.set_digits(5);
144 CanvasOptions::~CanvasOptions()
149 CanvasOptions::update_title()
151 set_title(_("Options")+String(" - ")+canvas_view_->get_canvas()->get_name());
155 CanvasOptions::refresh()
157 if(canvas_view_->work_area->grid_status())
158 toggle_grid_show.set_active(true);
160 toggle_grid_show.set_active(false);
162 if(canvas_view_->work_area->get_grid_snap())
163 toggle_grid_snap.set_active(true);
165 toggle_grid_snap.set_active(false);
167 vector_grid_size.set_value(canvas_view_->work_area->get_grid_size());
169 tooltips.set_tip(toggle_time_snap,_("Not yet implemented"));
170 toggle_time_snap.set_sensitive(false);
176 CanvasOptions::on_grid_snap_toggle()
181 CanvasOptions::on_grid_show_toggle()
186 CanvasOptions::on_apply_pressed()
188 if(toggle_grid_snap.get_active())
189 canvas_view_->work_area->enable_grid_snap();
191 canvas_view_->work_area->disable_grid_snap();
193 if(toggle_grid_show.get_active())
194 canvas_view_->work_area->enable_grid();
196 canvas_view_->work_area->disable_grid();
198 canvas_view_->work_area->set_grid_size(vector_grid_size.get_value());
202 CanvasOptions::on_ok_pressed()
209 CanvasOptions::on_cancel_pressed()