利用者:Koilz/2.65.10 bex ED spacetypes init - draw

提供: wiki
移動先: 案内検索

version 1 wiki version 2 wiki

// 2.65.10 bex ED_spacetypes_init - draw
//
//	# 	= no sub functions
//	*	= duplicate
//	no tab 	= no check

/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2009 Blender Foundation
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * ***** END GPL LICENSE BLOCK *****
 */

----------------------------------------------------------------

--------------------------------
// locate: the function that allocates the SpaceType.ARegionType->draw callbacks 
//       : source/blender/editors/space_api/spacetypes.c: ED_spacetypes_init(void)
//	 : ED_spacetypes_init(void) executes the sub functions
--------------------------------

--------------------------------
// locate: ED_spacetypes_init(void)
//       : source/blender/windowmanager/intern/wm_init_exit.c: WM_init(bContext *C, int argc, const char **argv)
--------------------------------

--------------------------------
// locate: the function that executes the allocated SpaceType.ARegionType->draw callbacks
//       : source/blender/windowmanager/intern/wm_draw.c: wm_method_draw_full(C, win);
//       : source/blender/editors/screen/screen_edit.c: ED_region_do_draw(C, ar);
//	 : executes draw(C,ar); from ARegionType
--------------------------------

--------------------------------
main(int argc, const char **argv)					// source/creator/creator.c
	WM_init(C, argc, (const char **)argv);				// source/blender/windowmanager/intern/wm_init_exit.c
		ED_spacetypes_init();					// source/blender/editors/space_api/spacetypes.c
			ED_spacetype_outliner();
			ED_spacetype_time();
			ED_spacetype_view3d();				// example: spacetypes->regiontypes->draw = view3d_main_area_draw;
	WM_main(C);
		wm_draw_update(C);					// source/blender/windowmanager/intern/wm_draw.c
			wm_method_draw_overlap_all(C, win, 0);		// source/blender/windowmanager/intern/wm_draw.c
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);			// example: spacetypes->regiontypes->view3d_main_area_draw(C,ar);
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
			wm_method_draw_full(C, win);			// source/blender/windowmanager/intern/wm_draw.c
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
			wm_method_draw_triple(C, win);			// source/blender/windowmanager/intern/wm_draw.c
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);
				ED_region_do_draw(C, ar);		// source/blender/editors/screen/screen_edit.c
					draw(C, ar);

--------------------------------

----------------------------------------------------------------

----------------------------------------------------------------
int main(int argc, const char **argv)										// source/creator/creator.c
{
	/* -------------------------------- */
	skipped some of the condition init macro functions, e.g. python module.
	
	WM_main
	 wm_window_process_events	mouse keyboard (OS to blender)
	 wm_event_do_handlers		view handlers to notiiers (view) and operators (data)
	 wm_event_do_notifiers		notiiers to listeners to view (view update)
	 wm_draw_update			draw view
	
	the draw methods are:	wm_method_draw_overlap_all
					wm_method_draw_full
					wm_method_draw_triple
			
	screen -> area -> space
	screen -> area -> region -> panel

	event
		keyboard mouse input
	view
		view
	handler		
		a handler handleds the the GUI events (mouse over, mouse click)
		the results are sent to operators and notifiers
	notifier
		a notifier updates the view via listeners
		if a mouse is over a button the button should be highlighted
		the results are sent to listeners
	operator
		operators executes tools
		rotate armature, scale mesh, pad view, add shapekey
		they also update the view
		the results are sent to operator_storage, data and listeners
	listener
		listeners update the view with with the results from the notifiers
	data
		this is the memory, context, project
	operator_storage
		dont know, operator data

	/* -------------------------------- */

	CTX_create();
	CommandLineToArgvW(GetCommandLineW(), &argc);
	MEM_mallocN(argc * sizeof(char *), "argv array");
	alloc_utf_8_from_16(argv_16[argci], 0);
	LocalFree(argv_16);
	BLI_init_program_path(argv[0]);
	BLI_threadapi_init();
	initglobals();
	IMB_init();
	BKE_images_init();
	IMB_ffmpeg_init();
	BLI_callback_global_init();
	SYS_GetSystem();
	RNA_init();
	RE_engines_init();
	init_nodesystem();
	BKE_vfont_builtin_register(datatoc_bfont_pfb, datatoc_bfont_pfb_size);
	sound_init_once();
	init_def_material();
	WM_init(C, argc, (const char **)argv);									// source/blender/windowmanager/intern/wm_init_exit.c
		wm_ghost_init(C);
		wm_init_cursor_data();
		GHOST_CreateSystemPaths();
		BKE_addon_pref_type_init();
		wm_operatortype_init();
		WM_menutype_init();
		WM_uilisttype_init();
		set_free_windowmanager_cb(wm_close_and_free);
		set_blender_test_break_cb(wm_window_testbreak);
		DAG_editors_update_cb(ED_render_id_flush_update, ED_render_scene_update);
		ED_spacetypes_init();										// source/blender/editors/space_api/spacetypes.c
			ED_spacetype_outliner();
			ED_spacetype_time();
			ED_spacetype_view3d();									// source/blender/editors/space_view3d/space_view3d.c
			...
			ED_operatortypes_screen();
			ED_operatortypes_anim();
			ED_operatortypes_animchannels();
			...
			UI_view2d_operatortypes();
			UI_buttons_operatortypes();
			BKE_spacetypes_list();
			operatortypes();
			ED_operatormacros_armature();
			ED_operatormacros_mesh();
			ED_operatormacros_node();
			...
			BKE_spacetypes_list();
			dropboxes();
		ED_file_init();
		ED_node_init_butfuncs();
		BLF_init(11, U.dpi);
		BLF_lang_init();
		wm_homefile_read(C, NULL, G.factory_startup);
		BLF_lang_set(NULL);
		BPY_context_set(C);
		BPY_python_start(argc, argv);
		BPY_driver_reset();
		BPY_app_handlers_reset(FALSE);
		BPY_modules_load_user(C);
		GHOST_toggleConsole(3);
		wm_init_reports(C);
		GPU_extensions_init();
		GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
		GPU_set_anisotropic(U.anisotropic_filter);
		GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
		UI_init();
		clear_matcopybuf();
		ED_render_clear_mtex_copybuf();
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		ED_preview_init_dbase();
		wm_read_history();
		BLI_make_file_string("/", G.main->name, BLI_getDefaultDocumentFolder(), "untitled.blend");
		BLI_strncpy(G.lib, G.main->name, FILE_MAX);
		wm_recover_last_session(C, NULL);
	BLI_init_temporary_dir(U.tempdir);
	BLI_setenv("SDL_VIDEODRIVER", "dummy");
	WM_init(C, argc, (const char **)argv);
	BLI_init_temporary_dir(NULL);
	CTX_py_init_set(C, 1);
	WM_keymap_init(C);											// source/blender/windowmanager/intern/wm.c
		CTX_wm_manager(C);
		WM_keyconfig_new(wm, "Blender");
		WM_keyconfig_new(wm, "Blender Addon");
		WM_keyconfig_new(wm, "Blender User");
		CTX_py_init_get(C)
		wm_window_keymap(wm->defaultconf);
		ED_spacetypes_keymap(wm->defaultconf);
		WM_keyconfig_update_tag(NULL, NULL);
		WM_keyconfig_update(wm);
	free(argv[--argci]);
	MEM_freeN(argv);
	WM_exit(C);
	WM_init_game(C))
	WM_init_splash(C);
	WM_main(C);												// source/blender/windowmanager/intern/wm.c
		wm_window_process_events(C); 
		wm_event_do_handlers(C);
		wm_event_do_notifiers(C);									// source/blender/windowmanager/intern/wm_event_system.c
			CTX_wm_manager(C);
			CTX_wm_window_set(C, win);
			ELEM(note->data, ND_FILEREAD, ND_FILESAVE)
			wm_window_title(wm, win);
			wm_window_title(wm, win);
			ED_screen_set(C, note->reference);
			printf("%s: screen set %p\n", __func__, note->reference);
			ED_screen_delete(C, note->reference);
			printf("%s: screen delete %p\n", __func__, note->reference);
			CTX_data_scene(C)
			ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)
			ED_info_stats_clear(CTX_data_scene(C));
			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
			ED_update_for_newframe(CTX_data_main(C), win->screen->scene, 1);
			CTX_wm_window_set(C, win);
			ED_screen_do_listen(C, note);								// source/blender/editors/screen/screen_edit.c
				CTX_wm_window(C);
				uiFreeActiveButtons(C, win->screen);
				region_cursor_set(win, note->swinid, TRUE);
			ED_region_do_listen(ar, note);								// source/blender/editors/screen/area.c
				ED_region_tag_redraw(ar);
				ED_region_tag_redraw(ar);
				ar->type->listener(ar, note);
			ED_area_do_listen(sa, note);								// source/blender/editors/screen/area.c
				sa->type->listener(sa, note);
			ED_region_do_listen(ar, note);
				*
			MEM_freeN(note);
			ED_view3d_screen_datamask(win->screen);
			CTX_wm_window_set(C, win);
			CTX_wm_area_set(C, sa);
			ED_area_do_refresh(C, sa);
			CTX_data_main(C);
			BKE_scene_update_tagged(bmain, win->screen->scene);
			CTX_wm_window_set(C, NULL);
		wm_draw_update(C);										// source/blender/windowmanager/intern/wm_draw.c
			CTX_wm_manager(C);									// source/blender/windowmanager/intern/wm_draw.c
			GPU_free_unused_buffers();
			GHOST_GetWindowState(win->ghostwin);
			wm_draw_window_clear(win);
			CTX_wm_window_set(C, win);
			wm_window_make_drawable(C, win);
			ED_screen_refresh(wm, win);								// source/blender/editors/screen/screen_edit.c
				WM_window_pixels_x(win)
				WM_window_pixels_y(win)
				screen_refresh_headersizes();
				screen_test_scale(win->screen, WM_window_pixels_x(win), WM_window_pixels_y(win));
				wm_subwindow_open(win, &winrct);
				wm_subwindow_position(win, win->screen->mainwin, &winrct);
				ED_area_initialize(wm, win, sa);						// source/blender/editors/screen/area.c
					BKE_spacetype_from_id(sa->spacetype);
					BKE_spacetype_from_id(sa->spacetype);
					BKE_regiontype_from_id(sa->type, ar->regiontype);
					area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
					area_azone_initialize(win->screen, sa);
					region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
					ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
					init(wm, sa);								// spacetype callback
					region_subwindow(win, ar);
					ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag);
					init(wm, ar);
					uiFreeBlocks(NULL, &ar->uiblocks);
				WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
				printf("%s: set screen\n", __func__);
			wm_automatic_draw_method(win);
			wm_method_draw_overlap_all(C, win, 0);							// source/blender/windowmanager/intern/wm_draw.c
				CTX_wm_manager(C);
				ED_region_tag_redraw(ar);							// source/blender/editors/screen/screen_edit.c
					memset(&ar->drawrct, 0, sizeof(ar->drawrct));
				wm_flush_regions_up(screen, &ar->winrct);
				wm_flush_regions_up(screen, &ar->winrct);
				wm_flush_regions_down(screen, &ar->winrct);
				wm_flush_regions_down(screen, &rect);
				wm_drags_draw(C, win, &rect);
				CTX_wm_area_set(C, sa);
				CTX_wm_region_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				wm_paintcursor_draw(C, ar);
				ED_area_overdraw_flush(sa, ar);
				CTX_wm_region_set(C, NULL);
				CTX_wm_region_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				wm_paintcursor_draw(C, ar);
				ED_area_overdraw_flush(sa, ar);
				CTX_wm_region_set(C, NULL);
				wm_area_mark_invalid_backbuf(sa);
				CTX_wm_area_set(C, NULL);
				ED_screen_draw(win);
				ED_screen_draw(win);
				ED_area_overdraw(C);
				CTX_wm_menu_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				CTX_wm_menu_set(C, NULL);
				wm_gesture_draw(win);
				wm_drags_draw(C, win, NULL);
			wm_method_draw_full(C, win);								// source/blender/windowmanager/intern/wm_draw.c
				CTX_wm_area_set(C, sa);
				CTX_wm_region_set(C, ar);
				ED_region_do_draw(C, ar);							// source/blender/editors/screen/screen_edit.c
					CTX_wm_window(C);
					CTX_wm_area(C);
					max_ii(ar->winrct.xmin, ar->drawrct.xmin);
					max_ii(ar->winrct.ymin, ar->drawrct.ymin);
					min_ii(ar->winrct.xmax, ar->drawrct.xmax);
					min_ii(ar->winrct.ymax, ar->drawrct.ymax);
					wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);			// source/blender/windowmanager/intern/wm_subwindow.c
						swin_from_swinid(win, swinid);
						printf("%s %d: doesn't exist\n", __func__, swinid);
						BLI_rcti_size_x(&_curswin->winrct)
						BLI_rcti_size_y(&_curswin->winrct)
						glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
						BLI_rcti_size_x(srct)
						BLI_rcti_size_y(srct)
						glScissor(srct->xmin, srct->ymin, width, height);
						glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
						wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
						glLoadIdentity();
						glFlush();
					UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
					UI_ThemeClearColor(TH_HEADER);
					glClear(GL_COLOR_BUFFER_BIT);
					UI_ThemeColor(TH_TEXT);
					BLF_draw_default(UI_UNIT_X, 0.4f*UI_UNIT_Y, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
					draw(C, ar);
					ED_region_pixelspace(ar);
					ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
					memset(&ar->drawrct, 0, sizeof(ar->drawrct));
					uiFreeInactiveBlocks(C, &ar->uiblocks);
					region_draw_emboss(ar, &ar->winrct);					// source/blender/editors/screen/area.c
						glEnable(GL_BLEND);
						glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
						glColor4ub(0, 0, 0, 30);
						sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax);
						glColor4ub(0, 0, 0, 30);
						sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
						glColor4ub(255, 255, 255, 30);
						sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
						glColor4ub(255, 255, 255, 30);
						sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax);
						glDisable(GL_BLEND);
				wm_paintcursor_draw(C, ar);							// source/blender/windowmanager/intern/wm_draw.c
					CTX_wm_manager(C);
					CTX_wm_window(C);
					poll(C)
					ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)
					wm_get_cursor_position(win, &x, &y);
					pc->draw(C,x - ar_other->winrct.xmin, y - ar_other->winrct.ymin, pc->customdata);
					pc->draw(C,win->eventstate->x - ar_other->winrct.xmin,win->eventstate->y - ar_other->winrct.ymin,pc->customdata);
				ED_area_overdraw_flush(sa, ar);							// source/blender/editors/screen/area.c
					BLI_rcti_isect_pt(&ar->winrct, xs, ys)
				CTX_wm_region_set(C, NULL);
				wm_area_mark_invalid_backbuf(sa);
				CTX_wm_area_set(C, NULL);
				ED_screen_draw(win);								// source/blender/editors/screen/screen_edit.c
					wmSubWindowSet(win, win->screen->mainwin);
					drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 0);
					drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 1);
					area_getorientation(sa1, sa2);
					scrarea_draw_shape_dark(sa2, dir);
					scrarea_draw_shape_light(sa1, dira);
					glEnable(GL_BLEND);
					glColor4ub(255, 255, 255, 100);
					sdrawline(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y);
					glColor4ub(0, 0, 0, 100);
					sdrawline(sa3->totrct.xmin, win->eventstate->y + 1, sa3->totrct.xmax, win->eventstate->y + 1);
					sdrawline(win->eventstate->x, sa3->totrct.ymin, win->eventstate->x, sa3->totrct.ymax);
					glColor4ub(0, 0, 0, 100);
					sdrawline(win->eventstate->x + 1, sa3->totrct.ymin, win->eventstate->x + 1, sa3->totrct.ymax);
					glDisable(GL_BLEND);
				ED_area_overdraw(C);								// source/blender/editors/screen/area.c
					CTX_wm_window(C);
					CTX_wm_screen(C);
					wmSubWindowSet(win, screen->mainwin);
					glEnable(GL_BLEND);
					glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
					area_draw_azone(az->x1, az->y1, az->x2, az->y2);
					region_draw_azone_icon(az);
					region_draw_azone_tria(az);
					region_draw_azone_tab(az);
					region_draw_azone_tab_plus(az);
					glDisable(GL_BLEND);
				CTX_wm_menu_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				CTX_wm_menu_set(C, NULL);
				wm_gesture_draw(win);
			wm_method_draw_overlap_all(C, win, 0);							// source/blender/windowmanager/intern/wm_draw.c
				*
			wm_method_draw_overlap_all(C, win, 1);							// source/blender/windowmanager/intern/wm_draw.c
				*
			wm_method_draw_triple(C, win);								// source/blender/windowmanager/intern/wm_draw.c
				CTX_wm_manager(C);
				glClearColor(0, 0, 0, 0);
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				wmSubWindowSet(win, screen->mainwin);
				wm_triple_draw_textures(win, win->drawdata, 1.0f);
				MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
				wm_triple_gen_textures(win, win->drawdata)
				wm_draw_triple_fail(C, win);
				CTX_wm_area_set(C, sa);
				CTX_wm_region_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				ED_area_overdraw_flush(sa, ar);
				CTX_wm_region_set(C, NULL);
				wm_area_mark_invalid_backbuf(sa);
				CTX_wm_area_set(C, NULL);
				wmSubWindowSet(win, screen->mainwin);
				ED_area_overdraw(C);
				wm_triple_copy_textures(win, triple);
				CTX_wm_area_set(C, sa);
				CTX_wm_region_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				CTX_wm_region_set(C, NULL);
				wm_draw_region_blend(win, ar);
				CTX_wm_area_set(C, NULL);
				ED_screen_draw(win);
				CTX_wm_menu_set(C, ar);
				ED_region_do_draw(C, ar);
					*
				CTX_wm_menu_set(C, NULL);
				wm_gesture_draw(win);
				CTX_wm_area_set(C, sa);
				CTX_wm_region_set(C, ar);
				ED_region_set(C, ar);
				wm_paintcursor_draw(C, ar);
				CTX_wm_region_set(C, NULL);
				CTX_wm_area_set(C, NULL);
				wmSubWindowSet(win, screen->mainwin);
				wm_drags_draw(C, win, NULL);
			wm_window_swap_buffers(win);
			CTX_wm_window_set(C, NULL);
}
----------------------------------------------------------------