1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_info.cpp
3 ** \brief Dock Info File
5 ** $Id: dock_info.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "dock_info.h"
32 #include "canvasview.h"
35 #include <synfig/canvas.h>
36 #include <synfig/context.h>
38 #include <gtkmm/separator.h>
39 #include <gtkmm/invisible.h>
43 /* === U S I N G =========================================================== */
47 using namespace synfig;
49 /* === M A C R O S ========================================================= */
50 #define use_colorspace_gamma() App::use_colorspace_gamma
51 #define colorspace_gamma() (2.2f)
52 #define gamma_in(x) ((x>=0)?pow((float)x,1.0f/colorspace_gamma()):-pow((float)-x,1.0f/colorspace_gamma()))
53 #define gamma_out(x) ((x>=0)?pow((float)x,colorspace_gamma()):-pow((float)-x,colorspace_gamma()))
55 /* === G L O B A L S ======================================================= */
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
61 /* === E N T R Y P O I N T ================================================= */
63 void studio::Dock_Info::on_mouse_move()
65 Point pos = get_canvas_view()->work_area->get_cursor_pos();
67 Distance xv(pos[0],Distance::SYSTEM_UNITS);
68 xv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
70 Distance yv(pos[1],Distance::SYSTEM_UNITS);
71 yv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
73 //get the color and set the labels
75 x.set_text(xv.get_string(3));
76 y.set_text(yv.get_string(3));
78 Color c = get_canvas_view()->get_canvas()->get_context().get_color(pos);
79 float cr = c.get_r(),cg = c.get_g(), cb = c.get_b();
81 if(use_colorspace_gamma())
88 r.set_text(strprintf("%.1f%%",cr*100));
89 g.set_text(strprintf("%.1f%%",cg*100));
90 b.set_text(strprintf("%.1f%%",cb*100));
91 a.set_text(strprintf("%.1f%%",c.get_a()*100));
94 studio::Dock_Info::Dock_Info()
95 :Dock_CanvasSpecific("info",_("Info"),Gtk::StockID("synfig-info"))
97 set_use_scrolled(false);
99 Gtk::Table *table = manage(new Gtk::Table);
102 table->attach(*manage(new Gtk::Label(_("X: "))),0,1,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
103 table->attach(*manage(new Gtk::Label(_("Y: "))),0,1,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
106 table->attach(x,1,2,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
107 table->attach(y,1,2,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
110 table->attach(*manage(new Gtk::VSeparator),2,3,0,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
113 table->attach(*manage(new Gtk::Label(_("R: "))),3,4,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
114 table->attach(*manage(new Gtk::Label(_("G: "))),3,4,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
115 table->attach(*manage(new Gtk::Label(_("B: "))),3,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
116 table->attach(*manage(new Gtk::Label(_("A: "))),3,4,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
119 table->attach(r,4,5,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
120 table->attach(g,4,5,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
121 table->attach(b,4,5,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
122 table->attach(a,4,5,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
124 table->attach(*manage(new Gtk::Label),0,5,4,5);
131 studio::Dock_Info::~Dock_Info()
135 void studio::Dock_Info::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
137 mousecon.disconnect();
139 if(canvas_view && canvas_view->get_work_area())
141 mousecon = get_canvas_view()->work_area->signal_cursor_moved().connect(sigc::mem_fun(*this,&Dock_Info::on_mouse_move));