Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2008 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include <string.h> 00033 #include <stdio.h> 00034 00035 00036 #include "MEM_guardedalloc.h" 00037 00038 #include "BLI_blenlib.h" 00039 #include "BLI_utildefines.h" 00040 00041 #include "BKE_context.h" 00042 #include "BKE_screen.h" 00043 00044 #include "ED_screen.h" 00045 #include "ED_space_api.h" 00046 00047 #include "WM_api.h" 00048 #include "WM_types.h" 00049 00050 #include "UI_view2d.h" 00051 00052 #include "userpref_intern.h" // own include 00053 00054 /* ******************** default callbacks for userpref space ***************** */ 00055 00056 static SpaceLink *userpref_new(const bContext *UNUSED(C)) 00057 { 00058 ARegion *ar; 00059 SpaceUserPref *spref; 00060 00061 spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); 00062 spref->spacetype= SPACE_USERPREF; 00063 00064 /* header */ 00065 ar= MEM_callocN(sizeof(ARegion), "header for userpref"); 00066 00067 BLI_addtail(&spref->regionbase, ar); 00068 ar->regiontype= RGN_TYPE_HEADER; 00069 ar->alignment= RGN_ALIGN_BOTTOM; 00070 00071 /* main area */ 00072 ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); 00073 00074 BLI_addtail(&spref->regionbase, ar); 00075 ar->regiontype= RGN_TYPE_WINDOW; 00076 00077 return (SpaceLink *)spref; 00078 } 00079 00080 /* not spacelink itself */ 00081 static void userpref_free(SpaceLink *UNUSED(sl)) 00082 { 00083 // SpaceUserPref *spref= (SpaceUserPref*) sl; 00084 00085 } 00086 00087 00088 /* spacetype; init callback */ 00089 static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) 00090 { 00091 00092 } 00093 00094 static SpaceLink *userpref_duplicate(SpaceLink *sl) 00095 { 00096 SpaceUserPref *sprefn= MEM_dupallocN(sl); 00097 00098 /* clear or remove stuff from old */ 00099 00100 return (SpaceLink *)sprefn; 00101 } 00102 00103 00104 00105 /* add handlers, stuff you only do once or on area/region changes */ 00106 static void userpref_main_area_init(wmWindowManager *wm, ARegion *ar) 00107 { 00108 ED_region_panels_init(wm, ar); 00109 } 00110 00111 static void userpref_main_area_draw(const bContext *C, ARegion *ar) 00112 { 00113 /* this solves "vibrating UI" bug #25422 */ 00114 UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); 00115 00116 ED_region_panels(C, ar, 1, NULL, -1); 00117 } 00118 00119 static void userpref_operatortypes(void) 00120 { 00121 } 00122 00123 static void userpref_keymap(struct wmKeyConfig *UNUSED(keyconf)) 00124 { 00125 00126 } 00127 00128 /* add handlers, stuff you only do once or on area/region changes */ 00129 static void userpref_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) 00130 { 00131 ED_region_header_init(ar); 00132 } 00133 00134 static void userpref_header_area_draw(const bContext *C, ARegion *ar) 00135 { 00136 ED_region_header(C, ar); 00137 } 00138 00139 static void userpref_main_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) 00140 { 00141 /* context changes */ 00142 } 00143 00144 static void userpref_header_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) 00145 { 00146 /* context changes */ 00147 #if 0 00148 switch(wmn->category) { 00149 default: 00150 break; 00151 } 00152 #endif 00153 } 00154 00155 /* only called once, from space/spacetypes.c */ 00156 void ED_spacetype_userpref(void) 00157 { 00158 SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); 00159 ARegionType *art; 00160 00161 st->spaceid= SPACE_USERPREF; 00162 strncpy(st->name, "Userpref", BKE_ST_MAXNAME); 00163 00164 st->new= userpref_new; 00165 st->free= userpref_free; 00166 st->init= userpref_init; 00167 st->duplicate= userpref_duplicate; 00168 st->operatortypes= userpref_operatortypes; 00169 st->keymap= userpref_keymap; 00170 00171 /* regions: main window */ 00172 art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); 00173 art->regionid = RGN_TYPE_WINDOW; 00174 art->init= userpref_main_area_init; 00175 art->draw= userpref_main_area_draw; 00176 art->listener= userpref_main_area_listener; 00177 art->keymapflag= ED_KEYMAP_UI; 00178 00179 BLI_addhead(&st->regiontypes, art); 00180 00181 /* regions: header */ 00182 art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); 00183 art->regionid = RGN_TYPE_HEADER; 00184 art->prefsizey= HEADERY; 00185 art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; 00186 art->listener= userpref_header_listener; 00187 art->init= userpref_header_area_init; 00188 art->draw= userpref_header_area_draw; 00189 00190 BLI_addhead(&st->regiontypes, art); 00191 00192 00193 BKE_spacetype_register(st); 00194 } 00195