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"
37 /* === U S I N G =========================================================== */
40 //using namespace etl;
41 //using namespace synfig;
43 using studio::Adjust_Window;
45 /* === M A C R O S ========================================================= */
46 const double EPSILON = 1.0e-6;
48 /* === G L O B A L S ======================================================= */
50 /* === P R O C E D U R E S ================================================= */
52 /* === M E T H O D S ======================================================= */
54 /* === E N T R Y P O I N T ================================================= */
56 Adjust_Window::Adjust_Window(double value, double lower, double upper,
57 double stepinc, double pageinc, double pagesize,
59 : Adjustment(value,lower,upper,stepinc,pageinc,pagesize),
62 if(adj) set_child_adjustment(adj);
65 Adjust_Window::~Adjust_Window()
67 //connections should automatically be killed etc.
70 //child interface functions
71 Gtk::Adjustment *Adjust_Window::get_child_adjustment()
76 const Gtk::Adjustment *Adjust_Window::get_child_adjustment() const
81 void Adjust_Window::set_child_adjustment(Gtk::Adjustment *child)
83 childchanged.disconnect();
87 synfig::info("Adjust: connecting to child signals");
90 childchanged = child->signal_changed().connect(sigc::mem_fun(*this,&Adjust_Window::update_fromchild));
96 void Adjust_Window::on_changed()
101 void Adjust_Window::on_value_changed()
107 double Adjust_Window::get_sub_lower() const
112 double Adjust_Window::get_sub_upper() const
114 return get_value() + get_page_size();
117 //---- REFRESH FUNCTIONS -----
118 void Adjust_Window::update_child()
122 bool childchanged = false;
124 double v = get_value();
125 double ve = v + get_page_size();
127 //reset child's values if they need to be...
128 if(abs(v - adj_child->get_lower()) > EPSILON)
130 adj_child->set_lower(v);
134 if(abs(ve - adj_child->get_upper()) > EPSILON)
136 adj_child->set_upper(ve);
142 adj_child->changed();
147 void Adjust_Window::update_fromchild()
151 double b = adj_child->get_lower();
152 double dist = adj_child->get_upper() - b;
154 //reset our values if they need to be...
155 if(abs(get_value() - b) > EPSILON)
161 if(abs(get_page_size() - dist) > EPSILON)