Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_time/space_time.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | |||||
| #include "RNA_access.h" | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "ED_space_api.h" | #include "ED_space_api.h" | ||||
| ▲ Show 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | case NC_WM: | ||||
| ED_area_tag_refresh(sa); | ED_area_tag_refresh(sa); | ||||
| break; | break; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void time_main_message_bus_init(const bContext *C, ARegion *ar) | |||||
| { | |||||
| struct wmMsgBus *mbus = CTX_wm_message_bus(C); | |||||
| bScreen *sc = CTX_wm_screen(C); | |||||
| SpaceLink *sl = CTX_wm_space_data(C); | |||||
| PointerRNA ptr; | |||||
| RNA_pointer_create(&sc->id, &RNA_SpaceTimeline, sl, &ptr); | |||||
| wmMsgSubscribeValue msg_sub_value_area_tag_redraw = { | |||||
| .owner = ar, | |||||
| .user_data = ar, | |||||
| .notify = ED_region_do_msg_notify_tag_redraw, | |||||
| }; | |||||
| /* Timeline depends on scene properties. */ | |||||
| { | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| bool use_preview = (scene->r.flag & SCER_PRV_RANGE); | |||||
| extern PropertyRNA rna_Scene_frame_start; | |||||
| extern PropertyRNA rna_Scene_frame_end; | |||||
| extern PropertyRNA rna_Scene_frame_preview_start; | |||||
| extern PropertyRNA rna_Scene_frame_preview_end; | |||||
| extern PropertyRNA rna_Scene_use_preview_range; | |||||
| extern PropertyRNA rna_Scene_frame_current; | |||||
| const PropertyRNA *props[] = { | |||||
| use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start, | |||||
| use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end, | |||||
| &rna_Scene_use_preview_range, | |||||
| &rna_Scene_frame_current, | |||||
| }; | |||||
| PointerRNA idptr; | |||||
| RNA_id_pointer_create(&scene->id, &idptr); | |||||
| for (int i = 0; i < ARRAY_SIZE(props); i++) { | |||||
| WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_area_tag_redraw, __func__); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* ---------------- */ | /* ---------------- */ | ||||
| /* add handlers, stuff you only do once or on area/region changes */ | /* add handlers, stuff you only do once or on area/region changes */ | ||||
| static void time_main_region_init(wmWindowManager *wm, ARegion *ar) | static void time_main_region_init(wmWindowManager *wm, ARegion *ar) | ||||
| { | { | ||||
| wmKeyMap *keymap; | wmKeyMap *keymap; | ||||
| UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); | UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); | ||||
| Show All 12 Lines | static void time_main_region_draw(const bContext *C, ARegion *ar) | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| View2DGrid *grid; | View2DGrid *grid; | ||||
| View2DScrollers *scrollers; | View2DScrollers *scrollers; | ||||
| int unit, flag = 0; | int unit, flag = 0; | ||||
| /* clear and setup matrix */ | /* clear and setup matrix */ | ||||
| UI_ThemeClearColor(TH_BACK); | UI_ThemeClearColor(TH_BACK); | ||||
| glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | ||||
| time_main_message_bus_init(C, ar); | |||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| /* grid */ | /* grid */ | ||||
| unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; | unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; | ||||
| grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); | grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); | ||||
| UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); | UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); | ||||
| UI_view2d_grid_free(grid); | UI_view2d_grid_free(grid); | ||||
| ▲ Show 20 Lines • Show All 240 Lines • Show Last 20 Lines | |||||