diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
commit | c1ceab1281ccf061f03f8000bf190a082a5385d8 (patch) | |
tree | 01b9a9cfca80432d316bdad6c18c74eb025e9eb0 /source/blender/windowmanager | |
parent | 0d9c98c4bbfbc8c70c4772086dd09a51d01921ef (diff) | |
parent | 66a35e089a64d27bfc09c2225a530069eca05875 (diff) |
Merged changes in the trunk up to revision 55357.
Resolved conflicts:
release/datafiles/startup.blend
source/blender/editors/space_nla/nla_buttons.c
Also updated source/blender/blenkernel/intern/linestyle.c as a follow-up of
recent changes for the use of bool.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 42 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 21 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 100 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 186 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 29 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 1 |
16 files changed, 259 insertions, 163 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 57fe518dd46..4cac73b4cf6 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -165,7 +165,7 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase /* mouse */ void WM_event_add_mousemove(struct bContext *C); void WM_event_add_mousemove_window(struct wmWindow *window); -int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event); +int WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event); /* notifiers */ void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference); @@ -180,19 +180,19 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str /* operator api, default callbacks */ /* invoke callback, uses enum property named "type" */ -int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_menu_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); /* invoke callback, confirm menu + exec */ -int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_operator_confirm (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); /* invoke callback, file selector "filepath" unset + exec */ -int WM_operator_filesel (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_operator_filesel (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format); /* poll callback, context checks */ int WM_operator_winactive (struct bContext *C); /* invoke callback, exec + redo popup */ -int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_operator_props_dialog_popup (struct bContext *C, struct wmOperator *op, int width, int height); int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op); int WM_operator_ui_popup (struct bContext *C, struct wmOperator *op, int width, int height); @@ -282,31 +282,31 @@ void WM_menutype_freelink(struct MenuType *mt); void WM_menutype_free(void); /* default operator callbacks for border/circle/lasso */ -int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_border_select_modal (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_border_select_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_border_select_cancel(struct bContext *C, struct wmOperator *op); -int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op); -int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op); -int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op); const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; -int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); /* Gesture manager API */ -struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int type); +struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type); void WM_gesture_end(struct bContext *C, struct wmGesture *gesture); void WM_gestures_remove(struct bContext *C); /* fileselecting support */ void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op); -void WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval); +void WM_event_fileselect_event(struct wmWindowManager *wm, void *ophandle, int eventval); #ifndef NDEBUG void WM_event_print(const struct wmEvent *event); #endif @@ -317,7 +317,7 @@ void WM_operator_region_active_win_set(struct bContext *C); struct wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value); void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale, int sx, int sy); -struct wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(struct bContext *, struct wmDrag *, struct wmEvent *event), +struct wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event), void (*copy)(struct wmDrag *, struct wmDropBox *)); ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 881d4464ed6..a42e4438311 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -515,6 +515,7 @@ typedef struct wmTimer { typedef struct wmOperatorType { const char *name; /* text for ui, undo */ const char *idname; /* unique identifier */ + const char *translation_context; const char *description; /* tooltips and python docs */ /* this callback executes the operator without any interactive input, @@ -537,13 +538,13 @@ typedef struct wmOperatorType { * any further events are handled in modal. if the operation is * canceled due to some external reason, cancel is called * - see defines below for return values */ - int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *) + int (*invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) #ifdef __GNUC__ __attribute__((warn_unused_result)) #endif ; int (*cancel)(struct bContext *, struct wmOperator *); - int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *) + int (*modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) #ifdef __GNUC__ __attribute__((warn_unused_result)) #endif @@ -648,7 +649,7 @@ typedef struct wmDropBox { struct wmDropBox *next, *prev; /* test if the dropbox is active, then can print optype name */ - int (*poll)(struct bContext *, struct wmDrag *, wmEvent *); + int (*poll)(struct bContext *, struct wmDrag *, const wmEvent *); /* before exec, this copies drag info to wmDrop properties */ void (*copy)(struct wmDrag *, struct wmDropBox *); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index a01f7301ec2..29e0fcf302f 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -218,7 +218,7 @@ void WM_uilisttype_free(void) { GHashIterator *iter = BLI_ghashIterator_new(uilisttypes_hash); - for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for (; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) { uiListType *ult = BLI_ghashIterator_getValue(iter); if (ult->ext.free) { ult->ext.free(ult->ext.data); @@ -271,7 +271,7 @@ void WM_menutype_free(void) { GHashIterator *iter = BLI_ghashIterator_new(menutypes_hash); - for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for (; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) { MenuType *mt = BLI_ghashIterator_getValue(iter); if (mt->ext.free) { mt->ext.free(mt->ext.data); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 0581000e07c..ed066117b28 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -103,7 +103,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) -wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, wmEvent *), +wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, const wmEvent *), void (*copy)(wmDrag *, wmDropBox *)) { wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox"); @@ -323,7 +323,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy); else { glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ - glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale); + glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, GL_NEAREST, drag->imb->rect, drag->scale, drag->scale); } } else { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4e181ec930b..b2647626f3a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2244,12 +2244,12 @@ void wm_event_do_handlers(bContext *C) /* ********** filesector handling ************ */ -void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval) +void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval) { /* add to all windows! */ wmWindow *win; - for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { + for (win = wm->windows.first; win; win = win->next) { wmEvent event = *win->eventstate; event.type = EVT_FILESELECT; @@ -2271,6 +2271,7 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval) void WM_event_add_fileselect(bContext *C, wmOperator *op) { wmEventHandler *handler, *handlernext; + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); int full = 1; // XXX preset? @@ -2302,7 +2303,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) op->type->check(C, op); /* ignore return value */ } - WM_event_fileselect_event(C, op, full ? EVT_FILESELECT_FULL_OPEN : EVT_FILESELECT_OPEN); + WM_event_fileselect_event(wm, op, full ? EVT_FILESELECT_FULL_OPEN : EVT_FILESELECT_OPEN); } #if 0 @@ -2487,14 +2488,14 @@ void WM_event_add_mousemove_window(wmWindow *window) } /* for modal callbacks, check configuration for how to interpret exit with tweaks */ -int WM_modal_tweak_exit(wmEvent *evt, int tweak_event) +int WM_modal_tweak_exit(const wmEvent *event, int tweak_event) { /* if the release-confirm userpref setting is enabled, * tweak events can be canceled when mouse is released */ if (U.flag & USER_RELEASECONFIRM) { /* option on, so can exit with km-release */ - if (evt->val == KM_RELEASE) { + if (event->val == KM_RELEASE) { switch (tweak_event) { case EVT_TWEAK_L: case EVT_TWEAK_M: @@ -2515,7 +2516,7 @@ int WM_modal_tweak_exit(wmEvent *evt, int tweak_event) * some items (i.e. markers) being tweaked may end up getting * dropped all over */ - if (evt->val != KM_RELEASE) + if (event->val != KM_RELEASE) return 1; } @@ -2745,9 +2746,9 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g } /* imperfect but probably usable... draw/enable drags to other windows */ -static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *evt) +static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event) { - int mx = evt->x, my = evt->y; + int mx = event->x, my = event->y; if (wm->windows.first == wm->windows.last) return NULL; @@ -2779,8 +2780,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi if (mx - posx >= 0 && owin->posy >= 0 && mx - posx <= WM_window_pixels_x(owin) && my - posy <= WM_window_pixels_y(owin)) { - evt->x = mx - (int)(U.pixelsize * owin->posx); - evt->y = my - (int)(U.pixelsize * owin->posy); + event->x = mx - (int)(U.pixelsize * owin->posx); + event->y = my - (int)(U.pixelsize * owin->posy); return owin; } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index d1156f77e41..c682165eb69 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -509,7 +509,7 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory G.relbase_valid = 0; if (!from_memory) { - char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); + const char * const cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); if (cfgdir) { BLI_make_file_string(G.main->name, startstr, cfgdir, BLENDER_STARTUP_FILE); BLI_make_file_string(G.main->name, prefstr, cfgdir, BLENDER_USERPREF_FILE); @@ -533,7 +533,8 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory } if (U.themes.first == NULL) { - printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", startstr); + if (G.debug & G_DEBUG) + printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", startstr); success = 0; } } @@ -621,7 +622,7 @@ void wm_read_history(void) struct RecentFile *recent; char *line; int num; - char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); + const char * const cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); if (!cfgdir) return; @@ -650,7 +651,7 @@ static void write_history(void) { struct RecentFile *recent, *next_recent; char name[FILE_MAX]; - char *user_config_dir; + const char *user_config_dir; FILE *fp; int i; @@ -1051,7 +1052,7 @@ void wm_autosave_delete(void) BLI_make_file_string("/", str, BLI_temporary_dir(), BLENDER_QUIT_FILE); /* if global undo; remove tempsave, otherwise rename */ - if (U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0); + if (U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, false, false); else BLI_rename(filename, str); } } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 302bf61756a..adf159bcfee 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -58,7 +58,7 @@ /* context checked on having screen, window and area */ -wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) +wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) { wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture"); wmWindow *window = CTX_wm_window(C); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index da0c6dd2a63..6e557647d12 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -449,6 +449,7 @@ void WM_exit_ext(bContext *C, const short do_python) #ifdef WITH_INTERNATIONAL BLF_free_unifont(); + BLF_free_unifont_mono(); BLF_lang_free(); #endif diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 3c3e2c0feaa..c637b77738e 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -363,7 +363,9 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) if (G.debug & G_DEBUG_JOBS) wm_job->start_time = PIL_check_seconds_timer(); } - else printf("job fails, not initialized\n"); + else { + printf("job fails, not initialized\n"); + } } } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 92a310ac34e..20e715c18d0 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -836,7 +836,7 @@ int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) } strcat(buf, WM_key_event_string(kmi->type)); - return BLI_snprintf(str, len, "%s", buf); + return BLI_strncpy_rlen(str, buf, len); } static wmKeyMapItem *wm_keymap_item_find_handlers( diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 678c77d0d88..8ea507f97e8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -248,7 +248,7 @@ static int wm_macro_exec(bContext *C, wmOperator *op) return wm_macro_end(op, retval); } -static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event, wmOperator *opm) +static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *event, wmOperator *opm) { int retval = OPERATOR_FINISHED; @@ -275,13 +275,13 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event, return wm_macro_end(op, retval); } -static int wm_macro_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wm_macro_start(op); return wm_macro_invoke_internal(C, op, event, op->macro.first); } -static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event) +static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmOperator *opm = op->opm; int retval = OPERATOR_FINISHED; @@ -381,7 +381,9 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); RNA_def_struct_identifier(ot->srna, ot->idname); - RNA_def_struct_translation_context(ot->srna, BLF_I18NCONTEXT_OPERATOR_DEFAULT); + /* Use i18n context from ext.srna if possible (py operators). */ + RNA_def_struct_translation_context(ot->srna, ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : + BLF_I18NCONTEXT_OPERATOR_DEFAULT); BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); @@ -875,7 +877,7 @@ void WM_operator_properties_free(PointerRNA *ptr) /* ************ default op callbacks, exported *********** */ -int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *UNUSED(event)) +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); @@ -905,7 +907,7 @@ int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op } /* invoke callback, uses enum property named "type" */ -int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { PropertyRNA *prop = op->type->prop; uiPopupMenu *pup; @@ -1024,7 +1026,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) } -int WM_enum_search_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { uiPupBlock(C, wm_enum_search_menu, op); return OPERATOR_CANCELLED; @@ -1051,13 +1053,13 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message } -int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { return WM_operator_confirm_message(C, op, NULL); } /* op->invoke, opens fileselect if path property not set, otherwise executes */ -int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); /* call exec direct */ @@ -1475,12 +1477,12 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_ * This way - the button values correspond to the result of the operator. * Without this, first access to a button will make the result jump, * see [#32452] */ -int WM_operator_props_popup_call(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { return wm_operator_props_popup_ex(C, op, TRUE); } -int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { return wm_operator_props_popup_ex(C, op, FALSE); } @@ -1529,7 +1531,7 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { RNA_int_set(op->ptr, "debug_value", G.debug_value); return WM_operator_props_dialog_popup(C, op, 9 * UI_UNIT_X, UI_UNIT_Y); @@ -1598,14 +1600,14 @@ static void wm_block_splash_refreshmenu(bContext *UNUSED(C), void *UNUSED(arg_bl static int wm_resource_check_prev(void) { - char *res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, TRUE); + const char *res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, true); // if (res) printf("USER: %s\n", res); #if 0 /* ignore the local folder */ if (res == NULL) { /* with a local dir, copying old files isn't useful since local dir get priority for config */ - res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE); + res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, true); } #endif @@ -1614,7 +1616,7 @@ static int wm_resource_check_prev(void) return FALSE; } else { - return (BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION - 1, TRUE) != NULL); + return (BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION - 1, true) != NULL); } } @@ -1704,7 +1706,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); - if (strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release") == 0) { + if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION / 100, BLENDER_VERSION % 100); @@ -1742,7 +1744,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar return block; } -static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { uiPupBlock(C, wm_block_create_splash, NULL); @@ -1796,7 +1798,7 @@ static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { uiPupBlock(C, wm_block_search_menu, op); @@ -1944,7 +1946,7 @@ static void open_set_use_scripts(wmOperator *op) } } -static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { const char *openname = G.main->name; @@ -2034,7 +2036,7 @@ static int wm_link_append_poll(bContext *C) return 0; } -static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); @@ -2168,7 +2170,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* append, rather than linking */ if ((flag & FILE_LINK) == 0) { Library *lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); - if (lib) BKE_library_make_local(bmain, lib, 1); + if (lib) BKE_library_make_local(bmain, lib, true); else BLI_assert(!"cant find name of just added library!"); } @@ -2289,7 +2291,7 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { char filename[FILE_MAX]; @@ -2319,7 +2321,7 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot) static void untitled(char *filepath) { if (G.save_over == 0 && strlen(filepath) < FILE_MAX - 16) { - char *c = BLI_last_slash(filepath); + char *c = (char *)BLI_last_slash(filepath); if (c) strcpy(&c[1], "untitled.blend"); @@ -2338,7 +2340,7 @@ static void save_set_compress(wmOperator *op) } } -static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { char name[FILE_MAX]; @@ -2409,7 +2411,7 @@ static int blend_save_check(bContext *UNUSED(C), wmOperator *op) RNA_string_get(op->ptr, "filepath", filepath); if (!BLO_has_bfile_extension(filepath)) { /* some users would prefer BLI_replace_extension(), - * we keep getting knit-picking bug reports about this - campbell */ + * we keep getting nitpicking bug reports about this - campbell */ BLI_ensure_extension(filepath, FILE_MAX, ".blend"); RNA_string_set(op->ptr, "filepath", filepath); return TRUE; @@ -2444,7 +2446,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) /* *************** save file directly ******** */ -static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { char name[FILE_MAX]; int ret; @@ -2650,7 +2652,7 @@ static void wm_gesture_end(bContext *C, wmOperator *op) WM_cursor_restore(CTX_wm_window(C)); } -int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event) +int WM_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (ISTWEAK(event->type)) op->customdata = WM_gesture_new(C, event, WM_GESTURE_RECT); @@ -2665,7 +2667,7 @@ int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) +int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -2734,7 +2736,7 @@ int WM_border_select_cancel(bContext *C, wmOperator *op) int circle_select_size = 25; /* XXX - need some operator memory thing! */ #endif -int WM_gesture_circle_invoke(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) { op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE); @@ -2769,7 +2771,7 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) #endif } -int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -2787,7 +2789,18 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) gesture_circle_apply(C, op); } else if (event->type == EVT_MODAL_MAP) { + float fac; + switch (event->val) { + case GESTURE_MODAL_CIRCLE_SIZE: + fac = 0.3f * (event->y - event->prevy); + if (fac > 0) + rect->xmax += ceil(fac); + else + rect->xmax += floor(fac); + if (rect->xmax < 1) rect->xmax = 1; + wm_gesture_tag_redraw(C); + break; case GESTURE_MODAL_CIRCLE_ADD: rect->xmax += 2 + rect->xmax / 10; wm_gesture_tag_redraw(C); @@ -2854,7 +2867,7 @@ void WM_OT_circle_gesture(wmOperatorType *ot) /* **************** Tweak gesture *************** */ -static void tweak_gesture_modal(bContext *C, wmEvent *event) +static void tweak_gesture_modal(bContext *C, const wmEvent *event) { wmWindow *window = CTX_wm_window(C); wmGesture *gesture = window->tweak; @@ -2896,7 +2909,9 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event) WM_gesture_end(C, gesture); /* when tweak fails we should give the other keymap entries a chance */ - event->val = KM_RELEASE; + + /* XXX, assigning to readonly, BAD JUJU! */ + ((wmEvent *)event)->val = KM_RELEASE; } break; default: @@ -2932,7 +2947,7 @@ void wm_tweakevent_test(bContext *C, wmEvent *event, int action) /* *********************** lasso gesture ****************** */ -int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) { op->customdata = WM_gesture_new(C, event, WM_GESTURE_LASSO); @@ -2947,7 +2962,7 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event) { op->customdata = WM_gesture_new(C, event, WM_GESTURE_LINES); @@ -2989,7 +3004,7 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op) } } -int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmGesture *gesture = op->customdata; int sx, sy; @@ -3045,7 +3060,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_gesture_lines_modal(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event) { return WM_gesture_lasso_modal(C, op, event); } @@ -3164,7 +3179,7 @@ static int straightline_apply(bContext *C, wmOperator *op) } -int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event) { op->customdata = WM_gesture_new(C, event, WM_GESTURE_STRAIGHTLINE); @@ -3179,7 +3194,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event) +int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmGesture *gesture = op->customdata; rcti *rect = gesture->customdata; @@ -3271,7 +3286,7 @@ typedef struct { void *cursor; } RadialControl; -static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) +static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *event) { float d[2] = {0, 0}; float zoom[2] = {1, 1}; @@ -3587,7 +3602,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) return 1; } -static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindowManager *wm; RadialControl *rc; @@ -3684,7 +3699,7 @@ static int radial_control_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) +static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event) { RadialControl *rc = op->customdata; float new_value, dist, zoom[2]; @@ -4062,6 +4077,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) {GESTURE_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {GESTURE_MODAL_CIRCLE_ADD, "ADD", 0, "Add", ""}, {GESTURE_MODAL_CIRCLE_SUB, "SUBTRACT", 0, "Subtract", ""}, + {GESTURE_MODAL_CIRCLE_SIZE, "SIZE", 0, "Size", ""}, {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, {GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""}, @@ -4100,6 +4116,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB); WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); WM_modalkeymap_add_item(keymap, PADPLUSKEY, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); + WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, GESTURE_MODAL_CIRCLE_SIZE); /* assign map to operators */ WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_circle"); @@ -4184,6 +4201,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "MARKER_OT_select_border"); WM_modalkeymap_assign(keymap, "NLA_OT_select_border"); WM_modalkeymap_assign(keymap, "NODE_OT_select_border"); + WM_modalkeymap_assign(keymap, "NODE_OT_viewer_border"); WM_modalkeymap_assign(keymap, "PAINT_OT_hide_show"); WM_modalkeymap_assign(keymap, "OUTLINER_OT_select_border"); // WM_modalkeymap_assign(keymap, "SCREEN_OT_border_select"); // template diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index b510956dbc1..a289d182f1c 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -49,12 +49,12 @@ #include "PIL_time.h" +#include "BLI_utildefines.h" #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" -#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -76,10 +76,16 @@ #include "WM_api.h" /* only for WM_main_playanim */ struct PlayState; -static void playanim_window_zoom(const struct PlayState *ps, const float zoom_offset); +static void playanim_window_zoom(struct PlayState *ps, const float zoom_offset); typedef struct PlayState { + /* window and viewport size */ + int win_x, win_y; + + /* current zoom level */ + float zoom; + /* playback state */ short direction; short next_frame; @@ -91,7 +97,7 @@ typedef struct PlayState { short wait2; short stopped; short go; - + int fstep; /* current picture */ @@ -103,6 +109,9 @@ typedef struct PlayState { /* saves passing args */ struct ImBuf *curframe_ibuf; + + /* restarts player for file drop */ + char dropped_file[FILE_MAX]; } PlayState; /* for debugging */ @@ -204,7 +213,6 @@ typedef struct PlayAnimPict { static struct ListBase picsbase = {NULL, NULL}; static int fromdisk = FALSE; -static float zoomx = 1.0, zoomy = 1.0; static double ptottime = 0.0, swaptime = 0.04; static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step) @@ -234,8 +242,9 @@ static int pupdate_time(void) return (ptottime < 0); } -static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) +static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) { + float offsx, offsy; if (ibuf == NULL) { printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : "<NIL>"); @@ -250,17 +259,29 @@ static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fon GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); - glRasterPos2f(0.0f, 0.0f); + /* offset within window */ + offsx = 0.5f * (((float)ps->win_x - ps->zoom * ibuf->x) / (float)ps->win_x); + offsy = 0.5f * (((float)ps->win_y - ps->zoom * ibuf->y) / (float)ps->win_y); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + CLAMP(offsx, 0.0f, 1.0f); + CLAMP(offsy, 0.0f, 1.0f); + glRasterPos2f(offsx, offsy); - fdrawcheckerboard(0.0f, 0.0f, ibuf->x, ibuf->y); + glClearColor(0.1, 0.1, 0.1, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* checkerboard for case alpha */ + if (ibuf->planes == 32) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + fdrawcheckerboard(offsx, offsy, offsx + (ps->zoom * ibuf->x) / (float)ps->win_x, offsy + (ps->zoom * ibuf->y) / (float)ps->win_y); + } + glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glDisable(GL_BLEND); - + pupdate_time(); if (picture && (g_WS.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) && (fontid != -1)) { @@ -283,7 +304,7 @@ static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fon GHOST_SwapWindowBuffers(g_WS.ghost_window); } -static void build_pict_list(char *first, int totframes, int fstep, int fontid) +static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep, int fontid) { char *mem, filepath[FILE_MAX]; // short val; @@ -299,7 +320,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid) int pic; ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); if (ibuf) { - playanim_toscreen(NULL, ibuf, fontid, fstep); + playanim_toscreen(ps, NULL, ibuf, fontid, fstep); IMB_freeImBuf(ibuf); } @@ -402,7 +423,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid) ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL); } if (ibuf) { - playanim_toscreen(picture, ibuf, fontid, fstep); + playanim_toscreen(ps, picture, ibuf, fontid, fstep); IMB_freeImBuf(ibuf); } pupdate_time(); @@ -587,7 +608,9 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) case GHOST_kKeyPeriod: case GHOST_kKeyNumpadPeriod: if (val) { - if (ps->sstep) ps->wait2 = FALSE; + if (ps->sstep) { + ps->wait2 = FALSE; + } else { ps->sstep = TRUE; ps->wait2 = !ps->wait2; @@ -704,28 +727,33 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) case GHOST_kEventWindowSize: case GHOST_kEventWindowMove: { - int sizex, sizey; - - playanim_window_get_size(&sizex, &sizey); + float zoomx, zoomy; + + playanim_window_get_size(&ps->win_x, &ps->win_y); GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); - glViewport(0, 0, sizex, sizey); - glScissor(0, 0, sizex, sizey); - - zoomx = (float) sizex / ps->ibufx; - zoomy = (float) sizey / ps->ibufy; - zoomx = floor(zoomx + 0.5f); - zoomy = floor(zoomy + 0.5f); - if (zoomx < 1.0f) zoomx = 1.0f; - if (zoomy < 1.0f) zoomy = 1.0f; - - sizex = zoomx * ps->ibufx; - sizey = zoomy * ps->ibufy; + zoomx = (float) ps->win_x / ps->ibufx; + zoomy = (float) ps->win_y / ps->ibufy; + + /* zoom always show entire image */ + ps->zoom = MIN2(zoomx, zoomy); + + /* zoom steps of 2 for speed */ + ps->zoom = floor(ps->zoom + 0.5f); + if (ps->zoom < 1.0f) ps->zoom = 1.0f; + + glViewport(0, 0, ps->win_x, ps->win_y); + glScissor(0, 0, ps->win_x, ps->win_y); + + /* unified matrix, note it affects offset for drawing */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); - glPixelZoom(zoomx, zoomy); - glEnable(GL_DITHER); + glPixelZoom(ps->zoom, ps->zoom); ptottime = 0.0; - playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep); + playanim_toscreen(ps, ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep); break; } @@ -735,6 +763,23 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) ps->go = FALSE; break; } + case GHOST_kEventDraggingDropDone: + { + GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt); + + if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { + GHOST_TStringArray *stra = ddd->data; + int a; + + for (a = 0; a < stra->count; a++) { + BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file)); + ps->go = FALSE; + printf("drop file %s\n", stra->strings[a]); + break; /* only one drop element supported now */ + } + } + break; + } default: /* quiet warnings */ break; @@ -765,32 +810,31 @@ static void playanim_window_open(const char *title, int posx, int posy, int size FALSE /* no stereo */, FALSE); } -static void playanim_window_zoom(const PlayState *ps, const float zoom_offset) +static void playanim_window_zoom(PlayState *ps, const float zoom_offset) { int sizex, sizey; /* int ofsx, ofsy; */ /* UNUSED */ - if (zoomx + zoom_offset > 0.0f) zoomx += zoom_offset; - if (zoomy + zoom_offset > 0.0f) zoomy += zoom_offset; + if (ps->zoom + zoom_offset > 0.0f) ps->zoom += zoom_offset; // playanim_window_get_position(&ofsx, &ofsy); playanim_window_get_size(&sizex, &sizey); /* ofsx += sizex / 2; */ /* UNUSED */ /* ofsy += sizey / 2; */ /* UNUSED */ - sizex = zoomx * ps->ibufx; - sizey = zoomy * ps->ibufy; + sizex = ps->zoom * ps->ibufx; + sizey = ps->zoom * ps->ibufy; /* ofsx -= sizex / 2; */ /* UNUSED */ /* ofsy -= sizey / 2; */ /* UNUSED */ // window_set_position(g_WS.ghost_window,sizex,sizey); GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey); } -void WM_main_playanim(int argc, const char **argv) +/* return path for restart */ +static char *wm_main_playanim_intern(int argc, const char **argv) { struct ImBuf *ibuf = NULL; - char filepath[FILE_MAX]; + static char filepath[FILE_MAX]; /* abused to return dropped file path */ GHOST_TUns32 maxwinx, maxwiny; - /* short c233 = FALSE, yuvx = FALSE; */ /* UNUSED */ int i; /* This was done to disambiguate the name for use under c++. */ struct anim *anim = NULL; @@ -798,7 +842,7 @@ void WM_main_playanim(int argc, const char **argv) int sfra = -1; int efra = -1; int totblock; - + PlayState ps = {0}; /* ps.doubleb = TRUE;*/ /* UNUSED */ @@ -813,6 +857,8 @@ void WM_main_playanim(int argc, const char **argv) ps.wait2 = FALSE; ps.stopped = FALSE; ps.picture = NULL; + ps.dropped_file[0] = 0; + ps.zoom = 1.0f; /* resetmap = FALSE */ ps.fstep = 1; @@ -918,20 +964,16 @@ void WM_main_playanim(int argc, const char **argv) #endif #endif //XXX25 - /* XXX, fixme zr */ { -// extern void add_to_mainqueue(wmWindow *win, void *user_data, short evt, short val, char ascii); GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps); g_WS.ghost_system = GHOST_CreateSystem(); GHOST_AddEventConsumer(g_WS.ghost_system, consumer); - - playanim_window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y, 0); -//XXX25 window_set_handler(g_WS.ghost_window, add_to_mainqueue, NULL); + /* unified matrix, note it affects offset for drawing */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); @@ -949,11 +991,15 @@ void WM_main_playanim(int argc, const char **argv) ps.ibufx = ibuf->x; ps.ibufy = ibuf->y; + + ps.win_x = ps.ibufx; + ps.win_y = ps.ibufy; if (maxwinx % ibuf->x) maxwinx = ibuf->x * (1 + (maxwinx / ibuf->x)); if (maxwiny % ibuf->y) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y)); - glClearColor(0.0, 0.0, 0.0, 0.0); + + glClearColor(0.1, 0.1, 0.1, 0.0); glClear(GL_COLOR_BUFFER_BIT); GHOST_SwapWindowBuffers(g_WS.ghost_window); @@ -964,11 +1010,11 @@ void WM_main_playanim(int argc, const char **argv) efra = MAXFRAME; } - build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid); + build_pict_list(&ps, filepath, (efra - sfra) + 1, ps.fstep, ps.fontid); for (i = 2; i < argc; i++) { BLI_strncpy(filepath, argv[i], sizeof(filepath)); - build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid); + build_pict_list(&ps, filepath, (efra - sfra) + 1, ps.fstep, ps.fontid); } IMB_freeImBuf(ibuf); @@ -1041,8 +1087,8 @@ void WM_main_playanim(int argc, const char **argv) while (pupdate_time()) PIL_sleep_ms(1); ptottime -= swaptime; - playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep); - } /* else deleten */ + playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep); + } /* else delete */ else { printf("error: can't play this image type\n"); exit(0); @@ -1060,16 +1106,17 @@ void WM_main_playanim(int argc, const char **argv) ps.next_frame = ps.direction; - while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0) || ps.wait2 != 0)) { + while ( (hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0)) || ps.wait2 != 0) { if (hasevent) { GHOST_DispatchEvents(g_WS.ghost_system); } + /* Note, this still draws for mousemoves on pause */ if (ps.wait2) { if (hasevent) { if (ibuf) { while (pupdate_time()) PIL_sleep_ms(1); ptottime -= swaptime; - playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep); + playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep); } } } @@ -1142,12 +1189,20 @@ void WM_main_playanim(int argc, const char **argv) #else /* we still miss freeing a lot!, * but many areas could skip initialization too for anim play */ - IMB_exit(); - BKE_images_exit(); + BLF_exit(); #endif GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window); + /* early exit, IMB and BKE should be exited only in end */ + if (ps.dropped_file) { + BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath)); + return filepath; + } + + IMB_exit(); + BKE_images_exit(); + totblock = MEM_get_memory_blocks_in_use(); if (totblock != 0) { /* prints many bAKey, bArgument's which are tricky to fix */ @@ -1156,4 +1211,25 @@ void WM_main_playanim(int argc, const char **argv) MEM_printmemlist(); #endif } + + return NULL; +} + + +void WM_main_playanim(int argc, const char **argv) +{ + bool looping = true; + + while (looping) { + char *filepath = wm_main_playanim_intern(argc, argv); + + if (filepath) { /* use simple args */ + argv[1] = "-a"; + argv[2] = filepath; + argc = 3; + } + else { + looping = false; + } + } } diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 20406ac463d..01bebe8a1b8 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -257,9 +257,9 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); if (srct) { - int width = BLI_rcti_size_x(srct) + 1; /* only here */ - int height = BLI_rcti_size_y(srct) + 1; - glScissor(srct->xmin, srct->ymin, width, height); + int scissor_width = BLI_rcti_size_x(srct) + 1; /* only here */ + int scissor_height = BLI_rcti_size_y(srct) + 1; + glScissor(srct->xmin, srct->ymin, scissor_width, scissor_height); } else glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a1ab0de49cf..53698ca7e9e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -28,7 +28,6 @@ * \ingroup wm */ - #include <math.h> #include <stdlib.h> #include <stdio.h> @@ -37,7 +36,6 @@ #include "DNA_listBase.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "RNA_access.h" #include "MEM_guardedalloc.h" @@ -55,9 +53,10 @@ #include "BKE_global.h" #include "BKE_main.h" - #include "BIF_gl.h" +#include "RNA_access.h" + #include "WM_api.h" #include "WM_types.h" #include "wm.h" @@ -445,11 +444,15 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) #endif #if !defined(__APPLE__) && !defined(WIN32) /* X11 */ - /* X11, start maximized but use default same size */ + /* X11, start maximized but use default sane size */ wm_init_state.size_x = min_ii(wm_init_state.size_x, WM_WIN_INIT_SIZE_X); wm_init_state.size_y = min_ii(wm_init_state.size_y, WM_WIN_INIT_SIZE_Y); + /* pad */ + wm_init_state.start_x = WM_WIN_INIT_PAD; + wm_init_state.start_y = WM_WIN_INIT_PAD; + wm_init_state.size_x -= WM_WIN_INIT_PAD * 2; + wm_init_state.size_y -= WM_WIN_INIT_PAD * 2; #endif - } for (win = wm->windows.first; win; win = win->next) { @@ -460,19 +463,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) win->sizex = wm_init_state.size_x; win->sizey = wm_init_state.size_y; -#if !defined(__APPLE__) && !defined(WIN32) /* X11 */ - if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) { - /* we can't properly resize a maximized window */ - win->windowstate = GHOST_kWindowStateNormal; - } - else { - /* loading without userpref, default to maximized */ - win->windowstate = GHOST_kWindowStateMaximized; - } -#else win->windowstate = GHOST_kWindowStateNormal; -#endif - wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM; } @@ -1253,7 +1244,9 @@ void WM_clipboard_text_set(char *buf, int selection) if (*p == '\n') { *(p2++) = '\r'; *p2 = '\n'; } - else *p2 = *p; + else { + *p2 = *p; + } } *p2 = '\0'; diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index bc7e7efdcfd..338ef8bc65b 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -384,6 +384,8 @@ enum { #define GESTURE_MODAL_IN 9 #define GESTURE_MODAL_OUT 10 +#define GESTURE_MODAL_CIRCLE_SIZE 11 /* circle sel: size brush (for trackpad event) */ + #endif /* __WM_EVENT_TYPES_H__ */ diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index c4c64ed429f..a0546c88b78 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -74,6 +74,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op); * Clamped by real desktop limits */ #define WM_WIN_INIT_SIZE_X 1800 #define WM_WIN_INIT_SIZE_Y 1000 +#define WM_WIN_INIT_PAD 40 #endif /* __WM_WINDOW_H__ */ |