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"
43 /* === U S I N G =========================================================== */
47 using namespace synfig;
48 using namespace studio;
50 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
58 CanvasOptions::CanvasOptions(loose_handle<studio::CanvasView> canvas_view):
59 Gtk::Dialog(_("Canvas Options"),*canvas_view,false,true),
60 canvas_view_(canvas_view),
61 toggle_grid_snap(_("_Snap to grid"), true),
62 toggle_grid_show(_("S_how grid"), true),
63 toggle_time_snap(_("Snap to _frame"), true)
65 vector_grid_size.set_canvas(canvas_view->get_canvas());
67 Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
68 dialogPadding->set_padding(12, 12, 12, 12);
70 Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
71 dialogPadding->add(*notebook);
73 toggle_grid_snap.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_snap_toggle));
74 toggle_grid_show.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_show_toggle));
76 Gtk::Alignment *gridPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
77 gridPadding->set_padding(12, 12, 12, 12);
78 notebook->append_page(*gridPadding, _("Grid"));
80 Gtk::VBox *gridBox = manage(new Gtk::VBox(false, 12));
81 gridPadding->add(*gridBox);
83 Gtk::Table *gridTable = manage(new Gtk::Table(3, 2, false));
84 gridTable->set_row_spacings(6);
85 gridTable->set_col_spacings(12);
86 gridBox->pack_start(*gridTable, false, false, 0);
88 Gtk::Label *gridSizeLabel = manage(new Gtk::Label(_("_Grid size"), true));
89 gridSizeLabel->set_alignment(0, 0.5);
90 gridSizeLabel->set_mnemonic_widget(vector_grid_size);
92 toggle_grid_show.set_alignment(0, 0.5);
93 toggle_grid_snap.set_alignment(0, 0.5);
95 gridTable->attach(*gridSizeLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
96 gridTable->attach(vector_grid_size, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
97 gridTable->attach(toggle_grid_show, 0, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
98 gridTable->attach(toggle_grid_snap, 0, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
100 Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
101 timePadding->set_padding(12, 12, 12, 12);
102 notebook->append_page(*timePadding, _("Time"));
104 Gtk::VBox *timeBox = manage(new Gtk::VBox(false, 12));
105 timePadding->add(*timeBox);
107 timeBox->pack_start(toggle_time_snap, false, false, 0);
109 Gtk::Alignment *unitPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
110 unitPadding->set_padding(12, 12, 12, 12);
111 notebook->append_page(*unitPadding, _("Units"));
112 unitPadding->add(*manage(new Gtk::Label(_("Not yet implemented!"))));
114 Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
116 add_action_widget(*ok_button,2);
117 ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_ok_pressed));
119 Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
120 apply_button->show();
121 add_action_widget(*apply_button,1);
122 apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_apply_pressed));
124 Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
125 cancel_button->show();
126 add_action_widget(*cancel_button,0);
127 cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_cancel_pressed));
129 //set_default_response(1);
132 get_vbox()->pack_start(*dialogPadding);
133 get_vbox()->show_all();
135 signal_show().connect(sigc::mem_fun(*this, &studio::CanvasOptions::refresh));
137 vector_grid_size.set_digits(5);
142 CanvasOptions::~CanvasOptions()
147 CanvasOptions::update_title()
149 set_title(_("Options")+String(" - ")+canvas_view_->get_canvas()->get_name());
153 CanvasOptions::refresh()
155 if(canvas_view_->work_area->grid_status())
156 toggle_grid_show.set_active(true);
158 toggle_grid_show.set_active(false);
160 if(canvas_view_->work_area->get_grid_snap())
161 toggle_grid_snap.set_active(true);
163 toggle_grid_snap.set_active(false);
165 vector_grid_size.set_value(canvas_view_->work_area->get_grid_size());
167 tooltips.set_tip(toggle_time_snap,_("Not yet implemented"));
168 toggle_time_snap.set_sensitive(false);
174 CanvasOptions::on_grid_snap_toggle()
179 CanvasOptions::on_grid_show_toggle()
184 CanvasOptions::on_apply_pressed()
186 if(toggle_grid_snap.get_active())
187 canvas_view_->work_area->enable_grid_snap();
189 canvas_view_->work_area->disable_grid_snap();
191 if(toggle_grid_show.get_active())
192 canvas_view_->work_area->enable_grid();
194 canvas_view_->work_area->disable_grid();
196 canvas_view_->work_area->set_grid_size(vector_grid_size.get_value());
200 CanvasOptions::on_ok_pressed()
207 CanvasOptions::on_cancel_pressed()