1 /* === S Y N F I G ========================================================= */
2 /*! \file canvasoptions.cpp
3 ** \brief Template File
5 ** $Id: canvasoptions.cpp,v 1.1.1.1 2005/01/07 03:34:35 darco Exp $
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 "canvasview.h"
42 /* === U S I N G =========================================================== */
46 using namespace synfig;
47 using namespace studio;
49 /* === M A C R O S ========================================================= */
51 /* === G L O B A L S ======================================================= */
53 /* === P R O C E D U R E S ================================================= */
55 /* === M E T H O D S ======================================================= */
57 CanvasOptions::CanvasOptions(loose_handle<studio::CanvasView> canvas_view):
58 Gtk::Dialog(_("Canvas Options"),*canvas_view,false,true),
59 canvas_view_(canvas_view),
60 toggle_grid_snap(_("Grid Snap")),
61 toggle_grid_show(_("Grid Show")),
62 toggle_time_snap(_("Snap-To-Frame"))
64 vector_grid_size.set_canvas(canvas_view->get_canvas());
66 Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
68 toggle_grid_snap.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_snap_toggle));
69 toggle_grid_show.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_show_toggle));
71 Gtk::Table *grid_page=manage(new class Gtk::Table(2,2,false));
72 notebook->append_page(*grid_page,_("Grids"));
73 grid_page->attach(vector_grid_size, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
74 grid_page->attach(toggle_grid_snap, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
75 grid_page->attach(toggle_grid_show, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
77 Gtk::Table *time_page=manage(new class Gtk::Table(2,2,false));
78 notebook->append_page(*time_page,_("Time"));
79 time_page->attach(toggle_time_snap, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
81 Gtk::Table *unit_page=manage(new class Gtk::Table(2,2,false));
82 notebook->append_page(*unit_page,_("Units"));
83 unit_page->attach(*manage(new Gtk::Label(_("Not yet implemented"))), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
86 Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
88 add_action_widget(*ok_button,2);
89 ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_ok_pressed));
91 Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
93 add_action_widget(*apply_button,1);
94 apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_apply_pressed));
96 Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
97 cancel_button->show();
98 add_action_widget(*cancel_button,0);
99 cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_cancel_pressed));
101 //set_default_response(1);
104 get_vbox()->pack_start(*notebook);
105 notebook->show_all();
107 signal_show().connect(sigc::mem_fun(*this, &studio::CanvasOptions::refresh));
109 vector_grid_size.set_digits(5);
114 CanvasOptions::~CanvasOptions()
119 CanvasOptions::update_title()
121 set_title(_("Options")+String(" - ")+canvas_view_->get_canvas()->get_name());
125 CanvasOptions::refresh()
127 if(canvas_view_->work_area->grid_status())
128 toggle_grid_show.set_active(true);
130 toggle_grid_show.set_active(false);
132 if(canvas_view_->work_area->get_grid_snap())
133 toggle_grid_snap.set_active(true);
135 toggle_grid_snap.set_active(false);
137 vector_grid_size.set_value(canvas_view_->work_area->get_grid_size());
139 tooltips.set_tip(toggle_time_snap,_("Not yet implemented"));
140 toggle_time_snap.set_sensitive(false);
146 CanvasOptions::on_grid_snap_toggle()
151 CanvasOptions::on_grid_show_toggle()
156 CanvasOptions::on_apply_pressed()
158 if(toggle_grid_snap.get_active())
159 canvas_view_->work_area->enable_grid_snap();
161 canvas_view_->work_area->disable_grid_snap();
163 if(toggle_grid_show.get_active())
164 canvas_view_->work_area->enable_grid();
166 canvas_view_->work_area->disable_grid();
168 canvas_view_->work_area->set_grid_size(vector_grid_size.get_value());
172 CanvasOptions::on_ok_pressed()
179 CanvasOptions::on_cancel_pressed()