1 /* === S Y N F I G ========================================================= */
2 /*! \file adjust_window.cpp
3 ** \brief Adjustment Window Implementation File
8 ** Copyright (c) 2004 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 "adjust_window.h"
39 /* === U S I N G =========================================================== */
42 //using namespace etl;
43 //using namespace synfig;
45 using studio::Adjust_Window;
47 /* === M A C R O S ========================================================= */
48 const double EPSILON = 1.0e-6;
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 /* === E N T R Y P O I N T ================================================= */
58 Adjust_Window::Adjust_Window(double value, double lower, double upper,
59 double stepinc, double pageinc, double pagesize,
61 : Adjustment(value,lower,upper,stepinc,pageinc,pagesize),
64 if(adj) set_child_adjustment(adj);
67 Adjust_Window::~Adjust_Window()
69 //connections should automatically be killed etc.
72 //child interface functions
73 Gtk::Adjustment *Adjust_Window::get_child_adjustment()
78 const Gtk::Adjustment *Adjust_Window::get_child_adjustment() const
83 void Adjust_Window::set_child_adjustment(Gtk::Adjustment *child)
85 childchanged.disconnect();
89 // synfig::info("Adjust: connecting to child signals");
93 childchanged = child->signal_changed().connect(sigc::mem_fun(*this,&Adjust_Window::update_fromchild));
99 void Adjust_Window::on_changed()
104 void Adjust_Window::on_value_changed()
110 double Adjust_Window::get_sub_lower() const
115 double Adjust_Window::get_sub_upper() const
117 return get_value() + get_page_size();
120 //---- REFRESH FUNCTIONS -----
121 void Adjust_Window::update_child()
125 bool childchanged = false;
127 double v = get_value();
128 double ve = v + get_page_size();
130 //reset child's values if they need to be...
131 if(abs(v - adj_child->get_lower()) > EPSILON)
133 adj_child->set_lower(v);
137 if(abs(ve - adj_child->get_upper()) > EPSILON)
139 adj_child->set_upper(ve);
145 adj_child->changed();
150 void Adjust_Window::update_fromchild()
154 double b = adj_child->get_lower();
155 double dist = adj_child->get_upper() - b;
157 //reset our values if they need to be...
158 if(abs(get_value() - b) > EPSILON)
164 if(abs(get_page_size() - dist) > EPSILON)