- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# workarea.h

Go to the documentation of this file.

    00001 /* === S Y N F I G ========================================================= */
    00022 /* ========================================================================= */
    00023
    00024 /* === S T A R T =========================================================== */
    00025
    00026 #ifndef __SYNFIG_GTKMM_WORKAREA_H
    00027 #define __SYNFIG_GTKMM_WORKAREA_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030
    00031 #include <list>
    00032 #include <map>
    00033 #include <set>
    00034
    00035 #include <ETL/smart_ptr>
    00036 #include <ETL/handle>
    00037
    00038 #include <gtkmm/drawingarea.h>
    00039 #include <gtkmm/table.h>
    00040 #include <gtkmm/adjustment.h>
    00041 #include <gtkmm/ruler.h>
    00042 #include <gtkmm/image.h>
    00043 #include <gdkmm/pixbuf.h>
    00044 #include <gdkmm/cursor.h>
    00045 #include <gdkmm/device.h>
    00046
    00047 #include <synfig/time.h>
    00048 #include <synfig/vector.h>
    00049 #include <synfig/general.h>
    00050 #include <synfig/renddesc.h>
    00051 #include <synfig/canvas.h>
    00052
    00053 #include "zoomdial.h"
    00054 #include "duckmatic.h"
    00055 #include "instance.h"
    00056
    00057 /* === M A C R O S ========================================================= */
    00058
    00059 /* === T Y P E D E F S ===================================================== */
    00060
    00061 /* === C L A S S E S & S T R U C T S ======================================= */
    00062
    00063 /*
    00064 namespace etl {
    00065
    00066 template <typename T_, typename C_=std::less<T_,T_> >
    00067 class dereferenced_compare
    00068 {
    00069 public:
    00070     typedef etl::loose_handle<T_> first_argument_type;
    00071     typedef etl::loose_handle<T_> second_argument_type;
    00072     typedef bool result_type;
    00073
    00074 }
    00075 };
    00076 */
    00077
    00078 namespace synfigapp { class CanvasInterface; };
    00079
    00080 namespace synfig { class Layer; };
    00081 namespace Gtk { class Frame; };
    00082
    00083 namespace studio
    00084 {
    00085 class WorkAreaTarget;
    00086 class WorkAreaTarget_Full;
    00087
    00088 class Instance;
    00089 class CanvasView;
    00090 class WorkArea;
    00091 class WorkAreaRenderer;
    00092 class AsyncRenderer;
    00093 class DirtyTrap
    00094 {
    00095     friend class WorkArea;
    00096     WorkArea *work_area;
    00097 public:
    00098     DirtyTrap(WorkArea *work_area);
    00099     ~DirtyTrap();
    00100 };
    00101
    00102
    00103 class WorkArea : public Gtk::Table, public Duckmatic
    00104 {
    00105     friend class WorkAreaTarget;
    00106     friend class WorkAreaTarget_Full;
    00107     friend class DirtyTrap;
    00108     friend class WorkAreaRenderer;
    00109     friend class WorkAreaProgress;
    00110
    00111     /*
    00112  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
    00113     */
    00114
    00115 public:
    00116
    00117     void insert_renderer(const etl::handle<WorkAreaRenderer> &x);
    00118     void insert_renderer(const etl::handle<WorkAreaRenderer> &x,int priority);
    00119     void erase_renderer(const etl::handle<WorkAreaRenderer> &x);
    00120     void resort_render_set();
    00121
    00122     enum DragMode
    00123     {
    00124         DRAG_NONE=0,
    00125         DRAG_WINDOW,
    00126         DRAG_DUCK,
    00127         DRAG_GUIDE,
    00128         DRAG_BOX
    00129     };
    00130
    00131     /*
    00132  -- ** -- P R I V A T E   D A T A ---------------------------------------------
    00133     */
    00134
    00135 private:
    00136
    00137     std::set<etl::handle<WorkAreaRenderer> > renderer_set_;
    00138
    00139     etl::handle<studio::AsyncRenderer> async_renderer;
    00140
    00141
    00142     etl::loose_handle<synfigapp::CanvasInterface> canvas_interface;
    00143     etl::handle<synfig::Canvas> canvas;
    00144     etl::loose_handle<studio::Instance> instance;
    00145     etl::loose_handle<studio::CanvasView> canvas_view;
    00146
    00147     // Widgets
    00148     Gtk::DrawingArea *drawing_area;
    00149     Gtk::Adjustment scrollx_adjustment;
    00150     Gtk::Adjustment scrolly_adjustment;
    00151     Gtk::VRuler *vruler;
    00152     Gtk::HRuler *hruler;
    00153     Gtk::Button *menubutton;
    00154     Gtk::Frame *drawing_frame;
    00155
    00156     GdkDevice* curr_input_device;
    00157
    00158     // Bleh!
    00159     int w;
    00160     int h;
    00161     synfig::Real    canvaswidth;
    00162     synfig::Real    canvasheight;
    00163     synfig::Real    pw;
    00164     synfig::Real    ph;
    00165     float zoom;
    00166     float prev_zoom;
    00167     synfig::Point window_tl;
    00168     synfig::Point window_br;
    00169
    00170     guint32 last_event_time;
    00171
    00172     int bpp;
    00173     //unsigned char *buffer;
    00174
    00176     synfig::ProgressCallback *progresscallback;
    00177
    00179     synfig::RendDesc desc;
    00180
    00182
    00183     DragMode dragging;
    00184
    00185     etl::handle<Duckmatic::Duck> clicked_duck;
    00186     etl::handle<Duckmatic::Duck> hover_duck;
    00187
    00189     synfig::Point drag_point;
    00190
    00191     synfig::Point curr_point;
    00192
    00194     synfig::Point previous_focus;
    00195
    00197     bool show_grid;
    00198
    00200     bool show_guides;
    00201
    00202     bool low_resolution;
    00203
    00204     bool meta_data_lock;
    00205
    00207     bool full_frame;
    00208
    00209     //Glib::RefPtr<Gdk::Pixbuf> pix_buf;
    00210
    00212     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> > tile_book;
    00213
    00215     int refreshes;
    00216
    00218     //std::list<int> tile_queue;
    00219
    00220     int tile_w, tile_h;
    00221
    00222     gint render_idle_func_id;
    00223
    00225     synfig::Point last_focus_point;
    00226
    00227     bool canceled_;
    00228
    00229     int quality;
    00230     int low_res_pixel_size;
    00231
    00232     bool dirty_trap_enabled;
    00233
    00234     int dirty_trap_queued;
    00235
    00236
    00237     bool onion_skin;
    00239     int onion_skins[2];
    00240
    00241     etl::loose_handle<synfig::ValueNode> selected_value_node_;
    00242
    00243     bool allow_duck_clicks;
    00244     bool allow_layer_clicks;
    00245     bool cancel;
    00246     bool curr_guide_is_x;
    00247     bool dirty;
    00248     bool queued;
    00249     bool rendering;
    00250
    00251     /*
    00252  -- ** -- P U B L I C   D A T A -----------------------------------------------
    00253     */
    00254
    00255 public:
    00256
    00257     const etl::loose_handle<synfig::ValueNode>& get_selected_value_node() { return  selected_value_node_; }
    00258     const synfig::Point& get_drag_point()const { return drag_point; }
    00259     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& get_tile_book(){ return tile_book; }
    00260     int get_refreshes()const { return refreshes; }
    00261     bool get_canceled()const { return canceled_; }
    00262     bool get_queued()const { return queued; }
    00263     bool get_rendering()const { return rendering; }
    00264 #ifdef SINGLE_THREADED
    00265     bool get_updating()const;
    00266     void stop_updating(bool cancel = false);
    00267 #endif
    00268     bool get_full_frame()const { return full_frame; }
    00269     //int get_w()const { return w; }
    00270     //int get_h()const { return h; }
    00271
    00272     int get_tile_w()const { return tile_w; }
    00273     int get_tile_h()const { return tile_h; }
    00274
    00275     bool get_allow_layer_clicks() { return allow_layer_clicks; }
    00276     void set_allow_layer_clicks(bool value) { allow_layer_clicks=value; }
    00277
    00278     bool get_allow_duck_clicks() { return allow_duck_clicks; }
    00279     void set_allow_duck_clicks(bool value) { allow_duck_clicks=value; }
    00280
    00281     // used in renderer_ducks.cpp
    00282     bool solid_lines;
    00283
    00284     // used in renderer_guides.cpp
    00285     GuideList::iterator curr_guide;
    00286
    00287     // used in renderer_timecode.cpp
    00288     int timecode_width, timecode_height;
    00289
    00290     /*
    00291  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
    00292     */
    00293
    00294 private:
    00295
    00296     //unsigned char *get_buffer() { return buffer; }
    00297     bool set_wh(int w, int h,int chan=3);
    00298
    00299     int next_unrendered_tile(int refreshes)const;
    00300     int next_unrendered_tile()const { return next_unrendered_tile(refreshes); }
    00301
    00302     /*
    00303  -- ** -- S I G N A L S -------------------------------------------------------
    00304     */
    00305
    00306 private:
    00307
    00308     sigc::signal<void,GdkDevice* > signal_input_device_changed_;
    00309
    00311     sigc::signal<void,synfig::Point> signal_user_click_[5];
    00312
    00313     sigc::signal<void> signal_popup_menu_;
    00314
    00315     sigc::signal<void> signal_cursor_moved_;
    00316     sigc::signal<void> signal_rendering_;
    00317
    00318     sigc::signal<void> signal_onion_skin_changed_;
    00319
    00321     sigc::signal<void, etl::handle<synfig::Layer> > signal_layer_selected_;
    00322
    00323     sigc::signal<void> signal_view_window_changed_;
    00324
    00325 public:
    00326
    00327     sigc::signal<void>& signal_onion_skin_changed() { return signal_onion_skin_changed_; }
    00328
    00329     sigc::signal<void>& signal_rendering() { return signal_rendering_; }
    00330
    00331     sigc::signal<void>& signal_cursor_moved() { return signal_cursor_moved_; }
    00332
    00333     sigc::signal<void>& signal_view_window_changed() { return signal_view_window_changed_; }
    00334     void view_window_changed() { signal_view_window_changed()(); }
    00335
    00336     sigc::signal<void,GdkDevice* >& signal_input_device_changed() { return signal_input_device_changed_; }
    00337
    00338     sigc::signal<void> &signal_popup_menu() { return signal_popup_menu_; }
    00339
    00341     sigc::signal<void,synfig::Point> &signal_user_click(int button=0){ return signal_user_click_[button]; }
    00342
    00343     sigc::signal<void, etl::handle<synfig::Layer> >& signal_layer_selected() { return signal_layer_selected_; }
    00344
    00345     /*
    00346  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
    00347     */
    00348
    00349 public:
    00350     void set_onion_skin(bool x);
    00351     bool get_onion_skin()const;
    00352     void toggle_onion_skin() { set_onion_skin(!get_onion_skin()); }
    00353     void set_onion_skins(int *onions);
    00354
    00355     void set_selected_value_node(etl::loose_handle<synfig::ValueNode> x);
    00356
    00357     bool is_dragging() { return dragging!=DRAG_NONE; }
    00358
    00359     DragMode get_dragging_mode() { return dragging; }
    00360
    00361     WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface);
    00362     virtual ~WorkArea();
    00363
    00364     void set_cursor(const Gdk::Cursor& x);
    00365     void set_cursor(Gdk::CursorType x);
    00366
    00367     const synfig::Point& get_cursor_pos()const { return curr_point; }
    00368
    00369     Gtk::Adjustment *get_scrollx_adjustment() { return &scrollx_adjustment; }
    00370     Gtk::Adjustment *get_scrolly_adjustment() { return &scrolly_adjustment; }
    00371     const Gtk::Adjustment *get_scrollx_adjustment()const { return &scrollx_adjustment; }
    00372     const Gtk::Adjustment *get_scrolly_adjustment()const { return &scrolly_adjustment; }
    00373
    00374     void set_instance(etl::loose_handle<studio::Instance> x) { instance=x; }
    00375     void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; }
    00376     void set_canvas_view(etl::loose_handle<studio::CanvasView> x) { canvas_view=x; }
    00377     etl::handle<synfig::Canvas> get_canvas()const { return canvas; }
    00378     etl::handle<studio::Instance> get_instance()const { return instance; }
    00379     etl::loose_handle<studio::CanvasView> get_canvas_view()const { return canvas_view; }
    00380
    00381     void refresh_dimension_info();
    00382
    00384     void enable_grid();
    00385
    00387     void disable_grid();
    00388
    00390     void toggle_grid();
    00391
    00393     bool grid_status()const { return show_grid; }
    00394
    00395     void toggle_grid_snap() { Duckmatic::toggle_grid_snap(); }
    00396
    00397     bool get_show_guides()const { return show_guides; }
    00398     void set_show_guides(bool x);
    00399     void toggle_show_guides() { set_show_guides(!get_show_guides()); }
    00400
    00401     bool get_low_resolution_flag()const { return low_resolution; }
    00402     void set_low_resolution_flag(bool x);
    00403     void toggle_low_resolution_flag();
    00404
    00406     void queue_scroll();
    00407
    00409     void set_grid_size(const synfig::Vector &s);
    00410
    00412     void popup_menu();
    00413
    00414     int get_quality()const { return quality; }
    00415     int get_low_res_pixel_size()const { return low_res_pixel_size; }
    00416
    00417     void set_quality(int x);
    00418     void set_low_res_pixel_size(int x);
    00419
    00420
    00421     int get_w()const { return w; }
    00422     int get_h()const { return h; }
    00423     int get_bpp()const { return bpp; }
    00424
    00426     const synfig::RendDesc &get_rend_desc()const { return desc; }
    00427
    00429     void set_rend_desc(const synfig::RendDesc &x) { desc=x; }
    00430
    00432     synfig::Point screen_to_comp_coords(synfig::Point pos)const;
    00433
    00435     synfig::Point comp_to_screen_coords(synfig::Point pos)const;
    00436
    00437     float get_pw()const { return pw; }
    00438     float get_ph()const { return ph; }
    00439
    00440     const synfig::Point &get_window_tl()const { return window_tl; }
    00441     const synfig::Point &get_window_br()const { return window_br; }
    00442
    00443
    00444     bool async_update_preview();
    00445     void async_update_finished();
    00446     void async_render_preview(synfig::Time time);
    00447     void async_render_preview();
    00448
    00449     bool sync_update_preview();
    00450     bool sync_render_preview(synfig::Time time);
    00451     bool sync_render_preview();
    00452     void sync_render_preview_hook();
    00453
    00454     void queue_render_preview();
    00455
    00456
    00457     void queue_draw_preview();
    00458
    00459     void zoom_in();
    00460     void zoom_out();
    00461     void zoom_fit();
    00462     void zoom_norm();
    00463     float get_zoom()const { return zoom; }
    00464
    00465     void set_zoom(float z);
    00466
    00467
    00468     void set_progress_callback(synfig::ProgressCallback *x) { progresscallback=x; }
    00469     synfig::ProgressCallback *get_progress_callback() { return progresscallback; }
    00470
    00471     void set_focus_point(const synfig::Point &x);
    00472
    00473     synfig::Point get_focus_point()const;
    00474
    00475     void done_rendering();
    00476
    00477     bool refresh(GdkEventExpose*bleh=NULL);
    00478
    00479     void reset_cursor();
    00480     void refresh_cursor();
    00481
    00482     void save_meta_data();
    00483     void load_meta_data();
    00484
    00485     /*
    00486  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
    00487     */
    00488
    00489 private:
    00490     bool on_key_press_event(GdkEventKey* event);
    00491     bool on_drawing_area_event(GdkEvent* event);
    00492     bool on_hruler_event(GdkEvent* event);
    00493     bool on_vruler_event(GdkEvent* event);
    00494
    00495     /*
    00496  -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
    00497     */
    00498
    00499 public:
    00500
    00501     /*
    00502  -- ** -- S T A T I C   P R I V A T E   M E T H O D S -------------------------
    00503     */
    00504
    00505 private:
    00506
    00507     static gboolean __render_preview(gpointer data);
    00508
    00509 }; // END of class WorkArea
    00510
    00511 }; // END of namespace studio
    00512
    00513 /* === E N D =============================================================== */
    00514
    00515 #endif