source: synfigstudio/trunk/fuentes/.pc/c++11.patch/src/gui/iconcontroller.cpp @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 28.8 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file iconcontroller.cpp
3**      \brief Template File
4**
5**      $Id$
6**
7**      \legal
8**      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9**      Copyright (c) 2007, 2008 Chris Moore
10**  Copyright (c) 2008 Paul Wise
11**  Copyright (c) 2009 Gerco Ballintijn
12**      Copyright (c) 2009, 2011 Carlos López
13**      Copyright (c) 2009 Nikita Kitaev
14**
15**      This package is free software; you can redistribute it and/or
16**      modify it under the terms of the GNU General Public License as
17**      published by the Free Software Foundation; either version 2 of
18**      the License, or (at your option) any later version.
19**
20**      This package is distributed in the hope that it will be useful,
21**      but WITHOUT ANY WARRANTY; without even the implied warranty of
22**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23**      General Public License for more details.
24**      \endlegal
25*/
26/* ========================================================================= */
27
28/* === H E A D E R S ======================================================= */
29
30#ifdef USING_PCH
31#       include "pch.h"
32#else
33#ifdef HAVE_CONFIG_H
34#       include <config.h>
35#endif
36
37#include "iconcontroller.h"
38#include <synfig/valuenodes/valuenode_const.h>
39#include <gtkmm/button.h>
40#include <gtkmm/window.h>
41#include <synfigapp/action.h>
42#include <synfig/interpolation.h>
43
44#include <gdkmm.h>
45
46#include "general.h"
47
48#endif
49
50/* === U S I N G =========================================================== */
51
52using namespace etl;
53using namespace std;
54using namespace studio;
55using namespace synfig;
56
57/* === M A C R O S ========================================================= */
58
59#ifdef WIN32
60#       ifdef IMAGE_DIR
61#               undef IMAGE_DIR
62#               define IMAGE_DIR "share\\pixmaps"
63#       endif
64#endif
65
66#ifndef IMAGE_DIR
67#       define IMAGE_DIR "/usr/local/share/pixmaps"
68#endif
69
70
71#ifndef IMAGE_EXT
72#       define IMAGE_EXT        "png"
73#endif
74
75/* === M E T H O D S ======================================================= */
76
77static std::map< int, Glib::RefPtr<Gdk::Pixbuf> > _tree_pixbuf_table_value_type;
78static Glib::RefPtr<Gdk::Pixbuf> _tree_pixbuf_table_interpolation[(int)INTERPOLATION_CLAMPED+1];
79
80#ifdef WIN32
81IconController::IconController(const synfig::String& basepath)
82#else
83IconController::IconController(const synfig::String& /*basepath*/)
84#endif
85{
86       
87        icon_factory=Gtk::IconFactory::create();
88}
89
90IconController::~IconController()
91{
92        _tree_pixbuf_table_value_type.clear();
93        for(int i(0);i<((int)INTERPOLATION_CLAMPED+1);i++)
94                _tree_pixbuf_table_interpolation[i]=Glib::RefPtr<Gdk::Pixbuf>();
95
96        icon_factory->remove_default();
97}
98
99void
100IconController::init_icons(const synfig::String& path_to_icons)
101{
102       
103        Gtk::IconSource icon_source;
104        icon_source.set_direction_wildcarded();
105        icon_source.set_state_wildcarded();
106        icon_source.set_size_wildcarded();
107       
108        try{
109        Gtk::Window::set_default_icon_from_file(path_to_icons+"synfig_icon."+IMAGE_EXT);
110        } catch(...)
111        {
112                synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
113        }
114
115#define INIT_STOCK_ICON(name,iconfile,desc){                                                    \
116        Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
117        Gtk::Stock::add(stockitem);                                                             \
118        Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create(); \
119        icon_source.set_filename(path_to_icons+iconfile);                                                       \
120        icon_set->add_source(icon_source);                                              \
121        icon_factory->add(stockitem.get_stock_id(),icon_set); \
122        }
123
124#define INIT_STOCK_ICON_CLONE(name,stockid,desc){                                                       \
125        Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
126        Gtk::Stock::add(stockitem);                                                             \
127        Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create(); \
128        if(Gtk::Stock::lookup(stockitem.get_stock_id(),icon_set))       \
129        icon_factory->add(stockitem.get_stock_id(),icon_set); \
130        }
131
132#define INIT_STOCK_ITEM(name,desc)                                                      \
133        stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc);                        \
134        Gtk::Stock::add(stock_##name);
135
136        // Types
137        INIT_STOCK_ICON(type_bool,"type_bool_icon."IMAGE_EXT,_("Bool"));
138        INIT_STOCK_ICON(type_integer,"type_integer_icon."IMAGE_EXT,_("Integer"));
139        INIT_STOCK_ICON(type_angle,"type_angle_icon."IMAGE_EXT,_("Angle"));
140        INIT_STOCK_ICON(type_time,"type_time_icon."IMAGE_EXT,_("Time"));
141        INIT_STOCK_ICON(type_real,"type_real_icon."IMAGE_EXT,_("Real"));
142        INIT_STOCK_ICON(type_vector,"type_vector_icon."IMAGE_EXT,_("Vector"));
143        INIT_STOCK_ICON(type_color,"type_color_icon."IMAGE_EXT,_("Color"));
144        INIT_STOCK_ICON(type_segment,"type_segment_icon."IMAGE_EXT,_("Segment"));
145        INIT_STOCK_ICON(type_blinepoint,"type_splinepoint_icon."IMAGE_EXT,_("Spline Point"));
146        INIT_STOCK_ICON(type_list,"type_list_icon."IMAGE_EXT,_("List"));
147        INIT_STOCK_ICON(type_string,"type_string_icon."IMAGE_EXT,_("String"));
148        INIT_STOCK_ICON(type_canvas,"type_canvas_icon."IMAGE_EXT,_("Canvas"));
149        INIT_STOCK_ICON(type_gradient,"type_gradient_icon."IMAGE_EXT,_("Gradient"))
150
151        // ToolBox Tools
152        INIT_STOCK_ICON(normal,"tool_normal_icon."IMAGE_EXT,_("Transform Tool"));
153        INIT_STOCK_ICON(polygon,"tool_polyline_icon."IMAGE_EXT,_("Polygon Tool"));
154        INIT_STOCK_ICON(bline,"tool_spline_icon."IMAGE_EXT,_("Spline Tool"));
155        INIT_STOCK_ICON(eyedrop,"tool_eyedrop_icon."IMAGE_EXT,_("Eyedrop Tool"));
156        INIT_STOCK_ICON(fill,"tool_fill_icon."IMAGE_EXT,_("Fill Tool"));
157        INIT_STOCK_ICON(draw,"tool_draw_icon."IMAGE_EXT,_("Draw Tool"));
158        INIT_STOCK_ICON(lasso,"tool_cutout_icon."IMAGE_EXT,_("Cutout Tool"));
159        INIT_STOCK_ICON(brush,"tool_brush_icon."IMAGE_EXT,_("Brush Tool"));
160        INIT_STOCK_ICON(sketch,"tool_sketch_icon."IMAGE_EXT,_("Sketch Tool"));
161        INIT_STOCK_ICON(circle,"tool_circle_icon."IMAGE_EXT,_("Circle Tool"));
162        INIT_STOCK_ICON(rectangle,"tool_rectangle_icon."IMAGE_EXT,_("Rectangle Tool"));
163        INIT_STOCK_ICON(smooth_move,"tool_smooth_move_icon."IMAGE_EXT,_("SmoothMove Tool"));
164        INIT_STOCK_ICON(rotate,"tool_rotate_icon."IMAGE_EXT,"Rotate Tool");
165        INIT_STOCK_ICON(width,"tool_width_icon."IMAGE_EXT,_("Width Tool"));
166        INIT_STOCK_ICON(scale,"tool_scale_icon."IMAGE_EXT,"Scale Tool");
167        INIT_STOCK_ICON(zoom,"tool_zoom_icon."IMAGE_EXT,_("Zoom Tool"));
168        INIT_STOCK_ICON(mirror,"tool_mirror_icon."IMAGE_EXT,_("Mirror Tool"));
169        INIT_STOCK_ICON(text,"tool_text_icon."IMAGE_EXT,"Text Tool");
170        INIT_STOCK_ICON(gradient,"tool_gradient_icon."IMAGE_EXT,_("Gradient Tool"));
171        INIT_STOCK_ICON(star,"tool_star_icon."IMAGE_EXT,_("Star Tool"));
172        // ToolBox Others
173        INIT_STOCK_ICON(reset_colors,"reset_colors_icon."IMAGE_EXT,_("Reset Colors"));
174        INIT_STOCK_ICON(swap_colors,"swap_colors_icon."IMAGE_EXT,_("Swap Colors"));
175        INIT_STOCK_ICON(value_node,"valuenode_icon."IMAGE_EXT,_("ValueNode"));
176        INIT_STOCK_ICON(valuenode_forbidanimation,"valuenode_forbidanimation_icon."IMAGE_EXT,_("ValueNode Forbid Animation"));
177        INIT_STOCK_ICON(rename,"rename_icon."IMAGE_EXT,_("Rename"));
178        INIT_STOCK_ICON(canvas,"canvas_icon."IMAGE_EXT,_("Canvas"));
179        INIT_STOCK_ICON(canvas_new,"canvas_icon."IMAGE_EXT,_("New Canvas"));
180
181        // Document Related Actions
182        INIT_STOCK_ICON(about,"about_icon."IMAGE_EXT,_("About"));
183        INIT_STOCK_ICON(new_doc,"action_doc_new_icon."IMAGE_EXT,_("New"));
184        INIT_STOCK_ICON(open,"action_doc_open_icon."IMAGE_EXT,_("Open"));
185        INIT_STOCK_ICON(save,"action_doc_save_icon."IMAGE_EXT,_("Save"));
186        INIT_STOCK_ICON(save_as,"action_doc_saveas_icon."IMAGE_EXT,_("Save As"));
187        INIT_STOCK_ICON(save_all,"action_doc_saveall_icon."IMAGE_EXT,_("Save All"));
188        INIT_STOCK_ICON(redo,"action_doc_redo_icon."IMAGE_EXT,_("Redo"));
189        INIT_STOCK_ICON(undo,"action_doc_undo_icon."IMAGE_EXT,_("Undo"));
190
191        // Layers
192        INIT_STOCK_ICON(layer,"layer_icon."IMAGE_EXT,_("Layer"));
193        // Blur Layers
194        INIT_STOCK_ICON(layer_blur_blur,"layer_blur_blur_icon."IMAGE_EXT,_("Blur Layer"));
195        INIT_STOCK_ICON(layer_blur_motion,"layer_blur_motion_icon."IMAGE_EXT,_("Motion Blur Layer"));
196        INIT_STOCK_ICON(layer_blur_radial,"layer_blur_radial_icon."IMAGE_EXT,_("Radial Blur Layer"));
197        // Distortion Layers
198        INIT_STOCK_ICON(layer_distortion_curvewarp,"layer_distortion_curvewarp_icon."IMAGE_EXT,_("Curve Warp Layer"));
199        INIT_STOCK_ICON(layer_distortion_insideout,"layer_distortion_insideout_icon."IMAGE_EXT,_("Inside Out Layer"));
200        INIT_STOCK_ICON(layer_distortion_noise,"layer_distortion_noise_icon."IMAGE_EXT,_("Noise Distort Layer"));
201        INIT_STOCK_ICON(layer_distortion_spherize,"layer_distortion_spherize_icon."IMAGE_EXT,_("Spherize Layer"));
202        INIT_STOCK_ICON(layer_distortion_stretch,"layer_distortion_stretch_icon."IMAGE_EXT,_("Stretch Layer"));
203        INIT_STOCK_ICON(layer_distortion_twirl,"layer_distortion_twirl_icon."IMAGE_EXT,_("Twirl Layer"));
204        INIT_STOCK_ICON(layer_distortion_warp,"layer_distortion_warp_icon."IMAGE_EXT,_("Warp Layer"));
205        // Example Layers
206        INIT_STOCK_ICON(layer_example_filledrectangle,"layer_example_filledrectangle_icon."IMAGE_EXT,_("Filled Rectangle Layer"));
207        INIT_STOCK_ICON(layer_example_metaballs,"layer_example_metaballs_icon."IMAGE_EXT,_("Metallballs Layer"));
208        INIT_STOCK_ICON(layer_example_simplecircle,"layer_example_simplecircle_icon."IMAGE_EXT,_("Simple Circle Layer"));
209        // Filter Layers
210        INIT_STOCK_ICON(layer_filter_clamp,"layer_filter_clamp_icon."IMAGE_EXT,_("Clamp Layer"));
211        INIT_STOCK_ICON(layer_filter_colorcorrect,"layer_filter_colorcorrect_icon."IMAGE_EXT,_("Color Correct Layer"));
212        INIT_STOCK_ICON(layer_filter_halftone2,"layer_filter_halftone2_icon."IMAGE_EXT,_("Halftone 2 Layer"));
213        INIT_STOCK_ICON(layer_filter_halftone3,"layer_filter_halftone3_icon."IMAGE_EXT,_("Halftone 3 Layer"));
214        INIT_STOCK_ICON(layer_filter_lumakey,"layer_filter_lumakey_icon."IMAGE_EXT,_("Luma Key Layer"));
215        // Fractal Layers
216        INIT_STOCK_ICON(layer_fractal_julia,"layer_fractal_julia_icon."IMAGE_EXT,_("Julia Set Layer"));
217        INIT_STOCK_ICON(layer_fractal_mandelbrot,"layer_fractal_mandelbrot_icon."IMAGE_EXT,_("Mandelbrot Set Layer"));
218        // Geometry Layers
219        INIT_STOCK_ICON(layer_geometry_checkerboard,"layer_geometry_checkerboard_icon."IMAGE_EXT,_("Checker Board Layer"));
220        INIT_STOCK_ICON(layer_geometry_circle,"layer_geometry_circle_icon."IMAGE_EXT,_("Circle Layer"));
221        INIT_STOCK_ICON(layer_geometry_outline,"layer_geometry_outline_icon."IMAGE_EXT,_("Outline Layer"));
222        INIT_STOCK_ICON(layer_geometry_advanced_outline,"layer_geometry_advanced_outline_icon."IMAGE_EXT,_("Advanced Outline Layer"));
223        INIT_STOCK_ICON(layer_geometry_polygon,"layer_geometry_polygon_icon."IMAGE_EXT,_("Polygon Layer"));
224        INIT_STOCK_ICON(layer_geometry_rectangle,"layer_geometry_rectangle_icon."IMAGE_EXT,_("Rectangle Layer"));
225        INIT_STOCK_ICON(layer_geometry_region,"layer_geometry_region_icon."IMAGE_EXT,_("Region Layer"));
226        INIT_STOCK_ICON(layer_geometry_solidcolor,"layer_geometry_solidcolor_icon."IMAGE_EXT,_("Solid Color Layer"));
227        INIT_STOCK_ICON(layer_geometry_star,"layer_geometry_star_icon."IMAGE_EXT,_("Star Layer"));
228        // Gradient Layers
229        INIT_STOCK_ICON(layer_gradient_conical,"layer_gradient_conical_icon."IMAGE_EXT,_("Conical Gradient Layer"));
230        INIT_STOCK_ICON(layer_gradient_curve,"layer_gradient_curve_icon."IMAGE_EXT,_("Curve Gradient Layer"));
231        INIT_STOCK_ICON(layer_gradient_noise,"layer_gradient_noise_icon."IMAGE_EXT,_("Noise Gradient Layer"));
232        INIT_STOCK_ICON(layer_gradient_linear,"layer_gradient_linear_icon."IMAGE_EXT,_("Linear Gradient Layer"));
233        INIT_STOCK_ICON(layer_gradient_radial,"layer_gradient_radial_icon."IMAGE_EXT,_("Radial Gradient Layer"));
234        INIT_STOCK_ICON(layer_gradient_spiral,"layer_gradient_spiral_icon."IMAGE_EXT,_("Spiral Gradient Layer"));
235        // Other Layers
236        INIT_STOCK_ICON(layer_other_duplicate,"layer_other_duplicate_icon."IMAGE_EXT,_("Duplicate Layer"));
237        INIT_STOCK_ICON(layer_other_importimage,"layer_other_importimage_icon."IMAGE_EXT,_("Import Image Layer"));
238        INIT_STOCK_ICON(layer_other_pastecanvas,"layer_other_group_icon."IMAGE_EXT,_("Group Layer"));
239        INIT_STOCK_ICON(layer_other_plant,"layer_other_plant_icon."IMAGE_EXT,_("Plant Layer"));
240        INIT_STOCK_ICON(layer_other_stroboscope,"layer_other_stroboscope_icon."IMAGE_EXT,_("Stroboscope Layer"));
241        INIT_STOCK_ICON(layer_other_supersample,"layer_other_supersample_icon."IMAGE_EXT,_("Super Sample Layer"));
242        INIT_STOCK_ICON(layer_other_sound,"layer_other_sound_icon."IMAGE_EXT,_("Sound Layer"));
243        INIT_STOCK_ICON(layer_other_switch,"layer_other_switch_icon."IMAGE_EXT,_("Switch Layer"));
244        INIT_STOCK_ICON(layer_other_skeleton,"layer_other_skeleton_icon."IMAGE_EXT,_("Skeleton Layer"));
245        INIT_STOCK_ICON(layer_other_text,"layer_other_text_icon."IMAGE_EXT,_("Text Layer"));
246        INIT_STOCK_ICON(layer_other_timeloop,"layer_other_timeloop_icon."IMAGE_EXT,_("Time Loop Layer"));
247        INIT_STOCK_ICON(layer_other_xorpattern,"layer_other_xorpattern_icon."IMAGE_EXT,_("XOR Pattern Layer"));
248        // Stylize Layers
249        INIT_STOCK_ICON(layer_stylize_bevel,"layer_stylize_bevel_icon."IMAGE_EXT,_("Bevel Layer"));
250        INIT_STOCK_ICON(layer_stylize_shade,"layer_stylize_shade_icon."IMAGE_EXT,_("Shade Layer"));
251        // Transform Layers
252        INIT_STOCK_ICON(layer_transform_rotate,"layer_transform_rotate_icon."IMAGE_EXT,_("Rotate Layer"));
253        INIT_STOCK_ICON(layer_transform_translate,"layer_transform_translate_icon."IMAGE_EXT,_("Translate Layer"));
254        INIT_STOCK_ICON(layer_transform_scale,"layer_transform_scale_icon."IMAGE_EXT,_("Scale Layer"));
255
256        INIT_STOCK_ICON(info,"info_icon."IMAGE_EXT,_("Info Tool"));
257        INIT_STOCK_ICON(group,"set_icon."IMAGE_EXT,_("Set"));
258
259        INIT_STOCK_ICON(grid_enable,"grid_enable_icon."IMAGE_EXT,_("Show Grid"));
260        INIT_STOCK_ICON(grid_disable,"grid_disable_icon."IMAGE_EXT,_("Hide Grid"));
261        INIT_STOCK_ICON(grid_snap_enable,"grid_snap_enable_icon."IMAGE_EXT,_("Enable Grid Snap"));
262        INIT_STOCK_ICON(grid_snap_disable,"grid_snap_disable_icon."IMAGE_EXT,_("Disable Grid Snap"));
263        INIT_STOCK_ICON(duplicate,"duplicate_icon."IMAGE_EXT,_("Duplicate"));
264        INIT_STOCK_ICON(encapsulate,"group_icon."IMAGE_EXT,_("Group"));
265        INIT_STOCK_ICON(select_all_child_layers,"select_all_child_layers_icon."IMAGE_EXT,_("Select All Child Layers"));
266
267        INIT_STOCK_ICON(clear_undo,"clear_undo_icon."IMAGE_EXT,_("Clear Undo Stack"));
268        INIT_STOCK_ICON(clear_redo,"clear_redo_icon."IMAGE_EXT,_("Clear Redo Stack"));
269
270        INIT_STOCK_ICON(children,"library_icon."IMAGE_EXT,_("Library"));
271        INIT_STOCK_ICON(curves,"graphs_icon."IMAGE_EXT,_("Graphs"));
272        INIT_STOCK_ICON(keyframes,"keyframe_icon."IMAGE_EXT,_("Keyframes"));
273        INIT_STOCK_ICON(meta_data,"meta_data_icon."IMAGE_EXT,_("MetaData"));
274        INIT_STOCK_ICON(navigator,"navigator_icon."IMAGE_EXT,_("Navigator"));
275        INIT_STOCK_ICON(timetrack,"time_track_icon."IMAGE_EXT,_("Time Track"));
276        INIT_STOCK_ICON(history,"history_icon."IMAGE_EXT,_("History"));
277        INIT_STOCK_ICON(palette,"palette_icon."IMAGE_EXT,_("Palette"));
278        INIT_STOCK_ICON(params,"parameters_icon."IMAGE_EXT,_("Parameters"));
279
280        INIT_STOCK_ICON(keyframe_lock_past_off,"keyframe_lock_past_off_icon."IMAGE_EXT,_("Past keyframes unlocked"));
281        INIT_STOCK_ICON(keyframe_lock_past_on,"keyframe_lock_past_on_icon."IMAGE_EXT,_("Past keyframes locked"));
282        INIT_STOCK_ICON(keyframe_lock_future_off,"keyframe_lock_future_off_icon."IMAGE_EXT,_("Future keyframes unlocked"));
283        INIT_STOCK_ICON(keyframe_lock_future_on,"keyframe_lock_future_on_icon."IMAGE_EXT,_("Future keyframes locked"));
284
285        INIT_STOCK_ICON(animate_mode_off,"animate_mode_off_icon."IMAGE_EXT,_("Animate Mode Off"));
286        INIT_STOCK_ICON(animate_mode_on,"animate_mode_on_icon."IMAGE_EXT,_("Animate Mode On"));
287       
288        INIT_STOCK_ICON(jack, "jack_icon."IMAGE_EXT, _("JACK"));
289
290        INIT_STOCK_ICON(set_outline_color,"set_outline_color."IMAGE_EXT,_("Set as Outline"));
291        INIT_STOCK_ICON(set_fill_color,"set_fill_color."IMAGE_EXT,_("Set as Fill"));
292
293        INIT_STOCK_ICON(animate_seek_begin,"animate_seek_begin_icon."IMAGE_EXT,_("Seek to Begin"));
294        INIT_STOCK_ICON(animate_seek_prev_keyframe,"animate_seek_prev_keyframe_icon."IMAGE_EXT,_("Seek to Previous Keyframe"));
295        INIT_STOCK_ICON(animate_seek_prev_frame,"animate_seek_prev_frame_icon."IMAGE_EXT,_("Seek to Previous Frame"));
296        INIT_STOCK_ICON(animate_play,"animate_play_icon."IMAGE_EXT,_("Play"));
297        INIT_STOCK_ICON(animate_stop,"animate_stop_icon."IMAGE_EXT,_("Stop"));
298        INIT_STOCK_ICON(animate_pause,"animate_pause_icon."IMAGE_EXT,_("Pause"));
299        INIT_STOCK_ICON(animate_seek_next_frame,"animate_seek_next_frame_icon."IMAGE_EXT,_("Seek to Next frame"));
300        INIT_STOCK_ICON(animate_seek_next_keyframe,"animate_seek_next_keyframe_icon."IMAGE_EXT,_("Seek to Next Keyframe"));
301        INIT_STOCK_ICON(animate_seek_end,"animate_seek_end_icon."IMAGE_EXT,_("Seek to End"));
302        INIT_STOCK_ICON(animate_loop,"animate_loop_icon."IMAGE_EXT,_("Animate Loop"));
303
304        INIT_STOCK_ICON(add_to_group,"action_add_to_set_icon."IMAGE_EXT,_("Add Layer to Set"));
305        INIT_STOCK_ICON(remove_from_group,"action_remove_from_set_icon."IMAGE_EXT,_("Remove Layer from Set"));
306        INIT_STOCK_ICON(set_desc,"action_set_layer_description_icon."IMAGE_EXT,_("Set Layer Description"));
307        INIT_STOCK_ICON(export,"action_export_icon."IMAGE_EXT,_("Export Value Node"));
308        INIT_STOCK_ICON(unexport,"action_unexport_icon."IMAGE_EXT,_("Unexport Value Node"));
309        INIT_STOCK_ICON(flat_interpolation,"action_flat_interpolation_icon."IMAGE_EXT,_("Set Interpolation to Flat"));
310        INIT_STOCK_ICON(interpolate_interpolation,"action_interpolate_interpolation_icon."IMAGE_EXT,_("Set Interpolation to Interpolate"));
311        INIT_STOCK_ICON(peak_interpolation,"action_peak_interpolation_icon."IMAGE_EXT,_("Set Interpolation to Peak"));
312        INIT_STOCK_ICON(rounded_interpolation,"action_rounded_interpolation_icon."IMAGE_EXT,_("Set Interpolation to Rounded"));
313        INIT_STOCK_ICON(squared_interpolation,"action_squared_interpolation_icon."IMAGE_EXT,_("Set Interpolation to Squared"));
314
315        INIT_STOCK_ICON(toggle_duck_position,"duck_position_icon."IMAGE_EXT,_("Toggle position handles"));
316        INIT_STOCK_ICON(toggle_duck_vertex,"duck_vertex_icon."IMAGE_EXT,_("Toggle vertex handles"));
317        INIT_STOCK_ICON(toggle_duck_tangent,"duck_tangent_icon."IMAGE_EXT,_("Toggle tangent handles"));
318        INIT_STOCK_ICON(toggle_duck_radius,"duck_radius_icon."IMAGE_EXT,_("Toggle radius handles"));
319        INIT_STOCK_ICON(toggle_duck_width,"duck_width_icon."IMAGE_EXT,_("Toggle width handles"));
320        INIT_STOCK_ICON(toggle_duck_angle,"duck_angle_icon."IMAGE_EXT,_("Toggle angle handles"));
321
322        INIT_STOCK_ICON(toggle_show_grid,"show_grid_icon."IMAGE_EXT,_("Toggle show grid"));
323        INIT_STOCK_ICON(toggle_snap_grid,"snap_grid_icon."IMAGE_EXT,_("Toggle snap grid"));
324        INIT_STOCK_ICON(toggle_show_guide,"show_guide_icon."IMAGE_EXT,_("Toggle show guide"));
325        INIT_STOCK_ICON(toggle_snap_guide,"snap_guide_icon."IMAGE_EXT,_("Toggle snap guide"));
326
327        INIT_STOCK_ICON(toggle_onion_skin,"onion_skin_icon."IMAGE_EXT,_("Toggle onion skin"));
328
329        INIT_STOCK_ICON(increase_resolution,"incr_resolution_icon."IMAGE_EXT,_("Increase resolution"));
330        INIT_STOCK_ICON(decrease_resolution,"decr_resolution_icon."IMAGE_EXT,_("Decrease resolution"));
331
332        INIT_STOCK_ICON(preview_options,"preview_options_icon."IMAGE_EXT,_("Preview Options Dialog"));
333        INIT_STOCK_ICON(render_options,"render_options_icon."IMAGE_EXT,_("Render Options Dialog"));
334
335        INIT_STOCK_ICON(interpolation_type_tcb,"interpolation_type_tcb_icon."IMAGE_EXT,_("TCB interpolation"));
336        INIT_STOCK_ICON(interpolation_type_ease,"interpolation_type_ease_icon."IMAGE_EXT,_("Ease In/Out interpolation"));
337        INIT_STOCK_ICON(interpolation_type_const,"interpolation_type_const_icon."IMAGE_EXT,_("Const interpolation"));
338        INIT_STOCK_ICON(interpolation_type_linear,"interpolation_type_linear_icon."IMAGE_EXT,_("Linear interpolation"));
339        INIT_STOCK_ICON(interpolation_type_clamped,"interpolation_type_clamped_icon."IMAGE_EXT,_("Clamped interpolation"));
340
341        INIT_STOCK_ICON(utils_chain_link_on,"utils_chain_link_on_icon."IMAGE_EXT,_("Linked"));
342        INIT_STOCK_ICON(utils_chain_link_off,"utils_chain_link_off_icon."IMAGE_EXT,_("Unlinked"));
343        INIT_STOCK_ICON(utils_timetrack_align,"utils_timetrack_align_icon."IMAGE_EXT,"Utils Timetrack align");
344
345        INIT_STOCK_ICON_CLONE(cvs_add,"gtk-add",_("CVS Add"));
346        INIT_STOCK_ICON_CLONE(cvs_update,"gtk-open",_("CVS Update"));
347        INIT_STOCK_ICON_CLONE(cvs_commit,"gtk-save",_("CVS Commit"));
348        INIT_STOCK_ICON_CLONE(cvs_revert,"gtk-revert",_("CVS Revert"));
349
350#undef INIT_STOCK_ICON
351#undef INIT_STOCK_ICON_CLONE
352
353        icon_factory->add_default();
354
355        Gtk::IconSize::register_new("synfig-tiny_icon", 8, 8);
356        Gtk::IconSize::register_new("synfig-small_icon",12,12);
357        Gtk::IconSize::register_new("synfig-small_icon_16x16",16,16);
358
359        for(Type *type = Type::get_first(); type != NULL; type = type->get_next())
360                _tree_pixbuf_table_value_type[type->identifier]=Gtk::Button().render_icon_pixbuf(value_icon(*type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
361
362        for(int i(0);i<((int)INTERPOLATION_CLAMPED+1);i++)
363                _tree_pixbuf_table_interpolation[i]=Gtk::Button().render_icon_pixbuf(interpolation_icon(Interpolation(i)),Gtk::ICON_SIZE_SMALL_TOOLBAR);
364}
365
366Glib::RefPtr<Gdk::Cursor>
367IconController::get_normal_cursor()
368{
369        return Gdk::Cursor::create(Gdk::TOP_LEFT_ARROW);
370}
371
372Glib::RefPtr<Gdk::Cursor>
373IconController::get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window)
374{
375        //this function is never called
376        //it is commented out in WorkArea::refresh_cursor()
377        assert(0);
378        // \todo Do we still need it?
379
380        Glib::RefPtr<Gdk::Pixbuf> pixbuf =
381                Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-"+name),Gtk::ICON_SIZE_SMALL_TOOLBAR);
382        return Gdk::Cursor::create(window->get_display(), pixbuf, 0, 0);
383}
384
385Gtk::StockID
386studio::value_icon(Type &type)
387{
388        if (type == type_bool)
389                return Gtk::StockID("synfig-type_bool");
390        if (type == type_integer)
391                return Gtk::StockID("synfig-type_integer");
392        if (type == type_angle)
393                return Gtk::StockID("synfig-type_angle");
394        if (type == type_time)
395                return Gtk::StockID("synfig-type_time");
396        if (type == type_real)
397                return Gtk::StockID("synfig-type_real");
398        if (type == type_vector)
399                return Gtk::StockID("synfig-type_vector");
400        if (type == type_color)
401                return Gtk::StockID("synfig-type_color");
402        if (type == type_segment)
403                return Gtk::StockID("synfig-type_segment");
404        if (type == type_bline_point)
405                return Gtk::StockID("synfig-type_blinepoint");
406        if (type == type_list)
407                return Gtk::StockID("synfig-type_list");
408        if (type == type_canvas)
409                return Gtk::StockID("synfig-type_canvas");
410        if (type == type_string)
411                return Gtk::StockID("synfig-type_string");
412        if (type == type_gradient)
413                return Gtk::StockID("synfig-type_gradient");
414
415        return Gtk::StockID("synfig-unknown");
416}
417
418Gtk::StockID
419studio::interpolation_icon(synfig::Interpolation type)
420{
421        switch(type)
422        {
423                case INTERPOLATION_TCB:
424                        return Gtk::StockID("synfig-interpolation_type_tcb");
425                case INTERPOLATION_CONSTANT:
426                        return Gtk::StockID("synfig-interpolation_type_const");
427                case INTERPOLATION_LINEAR:
428                        return Gtk::StockID("synfig-interpolation_type_linear");
429                case INTERPOLATION_HALT:
430                        return Gtk::StockID("synfig-interpolation_type_ease");
431                case INTERPOLATION_CLAMPED:
432                        return Gtk::StockID("synfig-interpolation_type_clamped");
433                case INTERPOLATION_MANUAL:
434                case INTERPOLATION_UNDEFINED:
435                case INTERPOLATION_NIL:
436                default:
437                        break;
438        }
439        return Gtk::StockID();
440}
441
442
443Gtk::StockID
444studio::valuenode_icon(etl::handle<synfig::ValueNode> value_node)
445{
446        if(handle<ValueNode_Const>::cast_dynamic(value_node))
447        {
448                return value_icon(value_node->get_type());
449        }
450        else
451        {
452                return Gtk::StockID("synfig-value_node");
453        }
454}
455
456Glib::RefPtr<Gdk::Pixbuf>
457studio::get_tree_pixbuf(Type &type)
458{
459        //return Gtk::Button().render_icon_pixbuf(value_icon(type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
460        return _tree_pixbuf_table_value_type[type.identifier];
461}
462
463Glib::RefPtr<Gdk::Pixbuf>
464studio::get_interpolation_pixbuf(synfig::Interpolation type)
465{
466        return _tree_pixbuf_table_interpolation[int(type)];
467}
468
469#ifdef WIN32
470#define TEMPORARY_DELETE_MACRO DELETE
471#undef DELETE
472#endif
473
474Gtk::StockID
475studio::get_action_stock_id(const synfigapp::Action::BookEntry& action)
476{
477        Gtk::StockID stock_id;
478        if(action.task=="add")                          stock_id=Gtk::Stock::ADD;
479        else if(action.task=="connect")         stock_id=Gtk::Stock::CONNECT;
480        else if(action.task=="disconnect")      stock_id=Gtk::Stock::DISCONNECT;
481        else if(action.task=="insert")          stock_id=Gtk::Stock::ADD;
482        else if(action.task=="lower")           stock_id=Gtk::Stock::GO_DOWN;
483        else if(action.task=="move_bottom")     stock_id=Gtk::Stock::GOTO_BOTTOM;
484        else if(action.task=="move_top")        stock_id=Gtk::Stock::GOTO_TOP;
485        else if(action.task=="raise")           stock_id=Gtk::Stock::GO_UP;
486        else if(action.task=="remove")          stock_id=Gtk::Stock::DELETE;
487        else if(action.task=="set_off")         stock_id=Gtk::Stock::NO;
488        else if(action.task=="set_on")          stock_id=Gtk::Stock::YES;
489        else                                                            stock_id=Gtk::StockID("synfig-"+
490                                                                                                                          action.task);
491        return stock_id;
492}
493
494#ifdef WIN32
495#define DELETE TEMPORARY_DELETE_MACRO
496#undef TEMPORARY_DELETE_MACRO
497#endif
498
499Gtk::StockID
500studio::layer_icon(const synfig::String &layer)
501{
502        // Blur Layers
503        if(layer=="blur")
504                return Gtk::StockID("synfig-layer_blur_blur");
505        else if(layer=="MotionBlur") // in the future should be "motion_blur"
506                return Gtk::StockID("synfig-layer_blur_motion");
507        else if(layer=="radial_blur")
508                return Gtk::StockID("synfig-layer_blur_radial");
509        // Distortion Layers
510        else if(layer=="curve_warp")
511                return Gtk::StockID("synfig-layer_distortion_curvewarp");
512        else if(layer=="inside_out")
513                return Gtk::StockID("synfig-layer_distortion_insideout");
514        else if(layer=="noise_distort")
515                return Gtk::StockID("synfig-layer_distortion_noise");
516        else if(layer=="spherize")
517                return Gtk::StockID("synfig-layer_distortion_spherize");
518        else if(layer=="stretch")
519                return Gtk::StockID("synfig-layer_distortion_stretch");
520        else if(layer=="twirl")
521                return Gtk::StockID("synfig-layer_distortion_twirl");
522        else if(layer=="warp")
523                return Gtk::StockID("synfig-layer_distortion_warp");
524        // Example Layers
525        else if(layer=="filled_rectangle")
526                return Gtk::StockID("synfig-layer_example_filledrectangle");
527        else if(layer=="metaballs")
528                return Gtk::StockID("synfig-layer_example_metaballs");
529        else if(layer=="simple_circle")
530                return Gtk::StockID("synfig-layer_example_simplecircle");
531        // Filter Layers
532        else if(layer=="clamp")
533                return Gtk::StockID("synfig-layer_filter_clamp");
534        else if(layer=="colorcorrect")
535                return Gtk::StockID("synfig-layer_filter_colorcorrect");
536        else if(layer=="halftone2")
537                return Gtk::StockID("synfig-layer_filter_halftone2");
538        else if(layer=="halftone3")
539                return Gtk::StockID("synfig-layer_filter_halftone3");
540        else if(layer=="lumakey")
541                return Gtk::StockID("synfig-layer_filter_lumakey");
542        // Fractal Layers
543        else if(layer=="mandelbrot")
544                return Gtk::StockID("synfig-layer_fractal_mandelbrot");
545        else if(layer=="julia")
546                return Gtk::StockID("synfig-layer_fractal_julia");
547        // Geometry Layers
548        else if(layer=="checker_board")
549                return Gtk::StockID("synfig-layer_geometry_checkerboard");
550        else if(layer=="circle")
551                return Gtk::StockID("synfig-layer_geometry_circle");
552        else if(layer=="outline")
553                return Gtk::StockID("synfig-layer_geometry_outline");
554        else if(layer=="advanced_outline")
555                return Gtk::StockID("synfig-layer_geometry_advanced_outline");
556        else if(layer=="polygon")
557                return Gtk::StockID("synfig-layer_geometry_polygon");
558        else if(layer=="rectangle")
559                return Gtk::StockID("synfig-layer_geometry_rectangle");
560        else if(layer=="region")
561                return Gtk::StockID("synfig-layer_geometry_region");
562        else if(layer=="solid_color" || layer=="SolidColor")
563                return Gtk::StockID("synfig-layer_geometry_solidcolor");
564        else if(layer=="star")
565                return Gtk::StockID("synfig-layer_geometry_star");
566        // Gradient Layers
567        else if(layer=="conical_gradient")
568                return Gtk::StockID("synfig-layer_gradient_conical");
569        else if(layer=="curve_gradient")
570                return Gtk::StockID("synfig-layer_gradient_curve");
571        else if(layer=="noise")
572                return Gtk::StockID("synfig-layer_gradient_noise");
573        else if(layer=="linear_gradient")
574                return Gtk::StockID("synfig-layer_gradient_linear");
575        else if(layer=="radial_gradient")
576                return Gtk::StockID("synfig-layer_gradient_radial");
577        else if(layer=="spiral_gradient")
578                return Gtk::StockID("synfig-layer_gradient_spiral");
579        // Other Layers
580        else if(layer=="duplicate")
581                return Gtk::StockID("synfig-layer_other_duplicate");
582        else if(layer=="importimage" || layer=="import")
583                return Gtk::StockID("synfig-layer_other_importimage");
584        else if(layer=="group" || layer=="PasteCanvas" || layer=="pastecanvas" || layer=="paste_canvas")
585                return Gtk::StockID("synfig-layer_other_pastecanvas");
586        else if(layer=="plant")
587                return Gtk::StockID("synfig-layer_other_plant");
588        else if(layer=="stroboscope")
589                return Gtk::StockID("synfig-layer_other_stroboscope");
590        else if(layer=="skeleton")
591                return Gtk::StockID("synfig-layer_other_skeleton");
592        else if(layer=="super_sample")
593                return Gtk::StockID("synfig-layer_other_supersample");
594        else if(layer=="switch")
595                return Gtk::StockID("synfig-layer_other_switch");
596        else if(layer=="text")
597                return Gtk::StockID("synfig-layer_other_text");
598        else if(layer=="sound")
599                return Gtk::StockID("synfig-layer_other_sound");
600        else if(layer=="timeloop")
601                return Gtk::StockID("synfig-layer_other_timeloop");
602        else if(layer=="xor_pattern")
603                return Gtk::StockID("synfig-layer_other_xorpattern");
604        // Stylize Layers
605        else if(layer=="bevel")
606                return Gtk::StockID("synfig-layer_stylize_bevel");
607        else if(layer=="shade")
608                return Gtk::StockID("synfig-layer_stylize_shade");
609        // Transform Layers
610        else if(layer=="rotate")
611                return Gtk::StockID("synfig-layer_transform_rotate");
612        else if(layer=="translate")
613                return Gtk::StockID("synfig-layer_transform_translate");
614        else if(layer=="zoom")
615                return Gtk::StockID("synfig-layer_transform_scale");
616        else
617                return Gtk::StockID("synfig-layer");
618}
619
620Glib::RefPtr<Gdk::Pixbuf>
621studio::get_tree_pixbuf_layer(const synfig::String &layer)
622{
623        return Gtk::Button().render_icon_pixbuf(layer_icon(layer),Gtk::ICON_SIZE_SMALL_TOOLBAR);
624}
625
Note: See TracBrowser for help on using the repository browser.