1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_info.cpp
3 ** \brief Dock Info 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 "dock_info.h"
33 #include "canvasview.h"
36 #include <synfig/canvas.h>
37 #include <synfig/context.h>
39 #include <gtkmm/separator.h>
40 #include <gtkmm/invisible.h>
44 /* === U S I N G =========================================================== */
48 using namespace synfig;
50 /* === M A C R O S ========================================================= */
51 #define use_colorspace_gamma() App::use_colorspace_gamma
52 #define colorspace_gamma() (2.2f)
53 #define gamma_in(x) ((x>=0)?pow((float)x,1.0f/colorspace_gamma()):-pow((float)-x,1.0f/colorspace_gamma()))
54 #define gamma_out(x) ((x>=0)?pow((float)x,colorspace_gamma()):-pow((float)-x,colorspace_gamma()))
56 /* === G L O B A L S ======================================================= */
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 /* === E N T R Y P O I N T ================================================= */
64 void studio::Dock_Info::on_mouse_move()
66 Point pos = get_canvas_view()->work_area->get_cursor_pos();
68 Distance xv(pos[0],Distance::SYSTEM_UNITS);
69 xv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
71 Distance yv(pos[1],Distance::SYSTEM_UNITS);
72 yv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
74 //get the color and set the labels
76 x.set_text(xv.get_string(3));
77 y.set_text(yv.get_string(3));
79 Color c = get_canvas_view()->get_canvas()->get_context().get_color(pos);
80 float cr = c.get_r(),cg = c.get_g(), cb = c.get_b();
82 if(use_colorspace_gamma())
89 r.set_text(strprintf("%.1f%%",cr*100));
90 g.set_text(strprintf("%.1f%%",cg*100));
91 b.set_text(strprintf("%.1f%%",cb*100));
92 a.set_text(strprintf("%.1f%%",c.get_a()*100));
95 studio::Dock_Info::Dock_Info()
96 :Dock_CanvasSpecific("info",_("Info"),Gtk::StockID("synfig-info"))
98 set_use_scrolled(false);
100 Gtk::Table *table = manage(new Gtk::Table);
103 table->attach(*manage(new Gtk::Label(_("X: "))),0,1,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
104 table->attach(*manage(new Gtk::Label(_("Y: "))),0,1,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
107 table->attach(x,1,2,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
108 table->attach(y,1,2,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
111 table->attach(*manage(new Gtk::VSeparator),2,3,0,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
114 table->attach(*manage(new Gtk::Label(_("R: "))),3,4,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
115 table->attach(*manage(new Gtk::Label(_("G: "))),3,4,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
116 table->attach(*manage(new Gtk::Label(_("B: "))),3,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
117 table->attach(*manage(new Gtk::Label(_("A: "))),3,4,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
120 table->attach(r,4,5,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
121 table->attach(g,4,5,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
122 table->attach(b,4,5,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
123 table->attach(a,4,5,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
125 table->attach(*manage(new Gtk::Label),0,5,4,5);
132 studio::Dock_Info::~Dock_Info()
136 void studio::Dock_Info::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
138 mousecon.disconnect();
140 if(canvas_view && canvas_view->get_work_area())
142 mousecon = get_canvas_view()->work_area->signal_cursor_moved().connect(sigc::mem_fun(*this,&Dock_Info::on_mouse_move));