Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-06-16 17:09:36 +0400
committerTon Roosendaal <ton@blender.org>2009-06-16 17:09:36 +0400
commit2d40b8d56ff100b71dac7c4694f6115dcc0b01b5 (patch)
treee6ad74b116dccf3442290ba4a76bd314729bce6b /source/blender/editors/space_logic/space_logic.c
parent7d026421142306dee486628bd15d4f5aa2b77481 (diff)
2.5
Added SpaceLogic, to restore the old logic buttons into. In future it can be used for a more advanced logic editor, with states, behaviour, whatever. We'll see! This commit only adds the backend for new space. Committed this now as reference for when we need another space type. It's still not well plugin-able (dynamic space types), but my idea is to just have a new SpacePlugIn for this, with a neat small API to define all relevant callbacks. Also note the icon for the spacetype is wrong still.
Diffstat (limited to 'source/blender/editors/space_logic/space_logic.c')
-rw-r--r--source/blender/editors/space_logic/space_logic.c342
1 files changed, 342 insertions, 0 deletions
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
new file mode 100644
index 00000000000..12eeed35ec8
--- /dev/null
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -0,0 +1,342 @@
+/**
+ * $Id:
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+#include "DNA_image_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "BKE_context.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
+
+#include "ED_space_api.h"
+#include "ED_screen.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "logic_intern.h"
+
+/* ******************** manage regions ********************* */
+
+ARegion *logic_has_buttons_region(ScrArea *sa)
+{
+ ARegion *ar, *arnew;
+
+ for(ar= sa->regionbase.first; ar; ar= ar->next)
+ if(ar->regiontype==RGN_TYPE_UI)
+ return ar;
+
+ /* add subdiv level; after header */
+ for(ar= sa->regionbase.first; ar; ar= ar->next)
+ if(ar->regiontype==RGN_TYPE_HEADER)
+ break;
+
+ /* is error! */
+ if(ar==NULL) return NULL;
+
+ arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
+
+ BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+ arnew->regiontype= RGN_TYPE_UI;
+ arnew->alignment= RGN_ALIGN_LEFT;
+
+ arnew->flag = RGN_FLAG_HIDDEN;
+
+ return arnew;
+}
+
+/* ******************** default callbacks for image space ***************** */
+
+static SpaceLink *logic_new(const bContext *C)
+{
+ ARegion *ar;
+ SpaceLogic *slogic;
+
+ slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic");
+ slogic->spacetype= SPACE_LOGIC;
+
+ /* header */
+ ar= MEM_callocN(sizeof(ARegion), "header for logic");
+
+ BLI_addtail(&slogic->regionbase, ar);
+ ar->regiontype= RGN_TYPE_HEADER;
+ ar->alignment= RGN_ALIGN_BOTTOM;
+
+ /* buttons/list view */
+ ar= MEM_callocN(sizeof(ARegion), "buttons for logic");
+
+ BLI_addtail(&slogic->regionbase, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_LEFT;
+
+ /* main area */
+ ar= MEM_callocN(sizeof(ARegion), "main area for logic");
+
+ BLI_addtail(&slogic->regionbase, ar);
+ ar->regiontype= RGN_TYPE_WINDOW;
+
+ return (SpaceLink *)slogic;
+}
+
+/* not spacelink itself */
+static void logic_free(SpaceLink *sl)
+{
+// Spacelogic *slogic= (SpaceLogic*) sl;
+
+// if(slogic->gpd)
+// XXX free_gpencil_data(slogic->gpd);
+
+}
+
+
+/* spacetype; init callback */
+static void logic_init(struct wmWindowManager *wm, ScrArea *sa)
+{
+
+}
+
+static SpaceLink *logic_duplicate(SpaceLink *sl)
+{
+ SpaceLogic *slogicn= MEM_dupallocN(sl);
+
+ return (SpaceLink *)slogicn;
+}
+
+void logic_operatortypes(void)
+{
+ WM_operatortype_append(LOGIC_OT_properties);
+
+}
+
+void logic_keymap(struct wmWindowManager *wm)
+{
+ ListBase *keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+
+ WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
+}
+
+static void logic_refresh(const bContext *C, ScrArea *sa)
+{
+// SpaceLogic *slogic= (SpaceImage*)CTX_wm_space_data(C);
+// Object *obedit= CTX_data_edit_object(C);
+
+}
+
+static void logic_listener(ARegion *ar, wmNotifier *wmn)
+{
+ /* context changes */
+ switch(wmn->category) {
+ case NC_SCENE:
+ switch(wmn->data) {
+ case ND_FRAME:
+ ED_region_tag_redraw(ar);
+ break;
+
+ case ND_OB_ACTIVE:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_OBJECT:
+ break;
+ }
+}
+
+static int logic_context(const bContext *C, const char *member, bContextDataResult *result)
+{
+// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C);
+
+
+ return 0;
+}
+
+/************************** main region ***************************/
+
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void logic_main_area_init(wmWindowManager *wm, ARegion *ar)
+{
+ ListBase *keymap;
+
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
+
+ /* own keymaps */
+ keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+ WM_event_add_keymap_handler(&ar->handlers, keymap);
+}
+
+static void logic_main_area_draw(const bContext *C, ARegion *ar)
+{
+ /* draw entirely, view changes should be handled here */
+// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C);
+ View2D *v2d= &ar->v2d;
+ float col[3];
+
+ /* clear and setup matrix */
+ UI_GetThemeColor3fv(TH_BACK, col);
+ glClearColor(col[0], col[1], col[2], 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* we set view2d from own zoom and offset each time */
+// image_main_area_set_view2d(sima, ar, scene);
+
+ UI_view2d_view_ortho(C, v2d);
+
+ /* scrollers? */
+ /*scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ UI_view2d_scrollers_draw(C, v2d, scrollers);
+ UI_view2d_scrollers_free(scrollers);*/
+}
+
+
+/* *********************** buttons region ************************ */
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar)
+{
+ ListBase *keymap;
+
+ ED_region_panels_init(wm, ar);
+
+ keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0);
+ WM_event_add_keymap_handler(&ar->handlers, keymap);
+}
+
+static void logic_buttons_area_draw(const bContext *C, ARegion *ar)
+{
+ ED_region_panels(C, ar, 1, NULL);
+}
+
+/************************* header region **************************/
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void logic_header_area_init(wmWindowManager *wm, ARegion *ar)
+{
+ ED_region_header_init(ar);
+}
+
+static void logic_header_area_draw(const bContext *C, ARegion *ar)
+{
+ float col[3];
+
+ /* clear */
+ if(ED_screen_area_active(C))
+ UI_GetThemeColor3fv(TH_HEADER, col);
+ else
+ UI_GetThemeColor3fv(TH_HEADERDESEL, col);
+
+ glClearColor(col[0], col[1], col[2], 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* set view2d view matrix for scrolling (without scrollers) */
+ UI_view2d_view_ortho(C, &ar->v2d);
+
+ logic_header_buttons(C, ar);
+
+ /* restore view matrix? */
+ UI_view2d_view_restore(C);
+}
+
+/**************************** spacetype *****************************/
+
+/* only called once, from space/spacetypes.c */
+void ED_spacetype_logic(void)
+{
+ SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype logic");
+ ARegionType *art;
+
+ st->spaceid= SPACE_LOGIC;
+
+ st->new= logic_new;
+ st->free= logic_free;
+ st->init= logic_init;
+ st->duplicate= logic_duplicate;
+ st->operatortypes= logic_operatortypes;
+ st->keymap= logic_keymap;
+ st->refresh= logic_refresh;
+ st->context= logic_context;
+
+ /* regions: main window */
+ art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->keymapflag= ED_KEYMAP_FRAMES;
+ art->init= logic_main_area_init;
+ art->draw= logic_main_area_draw;
+ art->listener= logic_listener;
+ art->keymapflag= 0;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: listview/buttons */
+ art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
+ art->regionid = RGN_TYPE_UI;
+ art->minsizex= 220; // XXX
+ art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
+ art->listener= logic_listener;
+ art->init= logic_buttons_area_init;
+ art->draw= logic_buttons_area_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ logic_buttons_register(art);
+
+ /* regions: header */
+ art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->minsizey= HEADERY;
+ art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
+ art->init= logic_header_area_init;
+ art->draw= logic_header_area_draw;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+}
+
+