--- /dev/null
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_CONTEXT_H
+#define BKE_CONTEXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "DNA_listBase.h"
+
+struct ARegion;
+struct bScreen;
+struct EditMesh;
+struct ListBase;
+struct Main;
+struct Object;
+struct PointerRNA;
+struct ReportList;
+struct Scene;
+struct ScrArea;
+struct SpaceLink;
+struct StructRNA;
+struct ToolSettings;
+struct wmWindow;
+struct wmWindowManager;
+
+/* Structs */
+
+struct bContext;
+typedef struct bContext bContext;
+
+struct bContextDataMember;
+typedef struct bContextDataMember bContextDataMember;
+
+extern bContextDataMember CTX_DataMain;
+extern bContextDataMember CTX_DataScene;
+extern bContextDataMember CTX_DataObjects;
+extern bContextDataMember CTX_DataEditObject;
+extern bContextDataMember CTX_DataEditArmature;
+extern bContextDataMember CTX_DataEditMesh;
+
+typedef struct bContextDataIterator {
+ void *data;
+ int valid;
+
+ void (*begin)(bContext *C, struct bContextDataIterator *iter);
+ void (*next)(struct bContextDataIterator *iter);
+ void (*end)(struct bContextDataIterator *iter);
+ void *internal;
+} bContextDataIterator;
+
+typedef struct bContextDataResult {
+ void *pointer;
+ bContextDataIterator iterator;
+} bContextDataResult;
+
+typedef int (*bContextDataCallback)(const bContext *C,
+ const bContextDataMember *member, bContextDataResult *result);
+
+/* Context */
+
+bContext *CTX_create(void);
+void CTX_free(bContext *C);
+
+bContext *CTX_copy(const bContext *C, int thread);
+int CTX_thread(const bContext *C);
+
+/* Context Task and Reports */
+
+typedef enum bContextTask {
+ CTX_DRAWING = 0,
+ CTX_EDITING = 1,
+ CTX_EVALUATING = 2,
+ CTX_UNDEFINED = 3
+} bContextTask;
+
+bContextTask CTX_task(const bContext *C);
+void CTX_task_set(bContext *C, bContextTask task);
+
+struct ReportList *CTX_reports(const bContext *C);
+void CTX_reports_set(bContext *C, struct ReportList *reports);
+
+/* Window Manager Context */
+
+struct wmWindowManager *CTX_wm_manager(const bContext *C);
+struct wmWindow *CTX_wm_window(const bContext *C);
+struct bScreen *CTX_wm_screen(const bContext *C);
+struct ScrArea *CTX_wm_area(const bContext *C);
+struct SpaceLink *CTX_wm_space_data(const bContext *C);
+struct ARegion *CTX_wm_region(const bContext *C);
+void *CTX_wm_region_data(const bContext *C);
+struct uiBlock *CTX_wm_ui_block(const bContext *C);
+
+void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
+void CTX_wm_window_set(bContext *C, struct wmWindow *win);
+void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */
+void CTX_wm_area_set(bContext *C, struct ScrArea *win);
+void CTX_wm_region_set(bContext *C, struct ARegion *win);
+void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallback cb);
+
+/* Data Context */
+
+struct Main *CTX_data_main(const bContext *C);
+struct Scene *CTX_data_scene(const bContext *C);
+struct ToolSettings *CTX_data_tool_settings(const bContext *C);
+
+void CTX_data_main_set(bContext *C, struct Main *bmain);
+void CTX_data_scene_set(bContext *C, struct Scene *bmain);
+
+int CTX_data_objects(const bContext *C, bContextDataIterator *iter);
+
+struct Object *CTX_data_edit_object(const bContext *C);
+struct EditMesh *CTX_data_edit_mesh(const bContext *C);
+struct ListBase *CTX_data_edit_armature(const bContext *C);
+
+/* Data Evaluation Context */
+
+float CTX_eval_frame(const bContext *C);
+
+int CTX_eval_render_resolution(const bContext *C);
+void CTX_eval_render_resolution_set(bContext *C, int render);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
struct EditMesh;
struct BME_Glob;
-/* former global stuff. context is derived, not storage! */
-typedef struct bContext {
-
- /* windowmanager tree context */
- struct wmWindowManager *wm;
- struct wmWindow *window;
- struct bScreen *screen;
- struct ScrArea *area;
- struct ARegion *region;
-
- /* data context */
- struct Scene *scene;
- struct Object *obact;
- struct Object *obedit;
-
- /* edit data context */
- struct EditMesh *editMesh;
- struct ListBase edbo; /* Armature Editmode bones */
-
-} bContext;
-
typedef struct Global {
/* active pointers */
--- /dev/null
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_REPORT_H
+#define BKE_REPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "DNA_listBase.h"
+
+/* Reporting Information and Errors */
+
+typedef enum ReportType {
+ RPT_DEBUG = 0,
+ RPT_INFO = 1000,
+ RPT_WARNING = 2000,
+ RPT_ERROR = 3000,
+ RPT_ERROR_INVALID_INPUT = 3001,
+ RPT_ERROR_INVALID_CONTEXT = 3002,
+ RPT_ERROR_OUT_OF_MEMORY = 3003
+} ReportType;
+
+enum ReportListFlags {
+ RPT_PRINT = 1,
+ RPT_STORE = 2
+};
+
+typedef struct Report {
+ struct Report *next, *prev;
+ ReportType type;
+ char *typestr;
+ char *message;
+} Report;
+
+typedef struct ReportList {
+ ListBase list;
+ ReportType level;
+ int flags;
+} ReportList;
+
+void BKE_report_list_init(ReportList *reports, int flag);
+void BKE_report_list_clear(ReportList *reports);
+
+void BKE_report(ReportList *reports, ReportType type, const char *message);
+void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
+
+ReportType BKE_report_level(ReportList *reports);
+void BKE_report_level_set(ReportList *reports, ReportType level);
+
+int BKE_report_has_error(ReportList *reports);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
#ifndef BKE_SCREEN_H
#define BKE_SCREEN_H
-struct SpaceType;
-struct ScrArea;
-struct bScreen;
struct ARegion;
+struct bContext;
+struct bContextDataMember;
+struct bContextDataResult;
+struct bScreen;
+struct ListBase;
+struct ScrArea;
+struct SpaceType;
struct wmNotifier;
-struct wmWindowManager;
struct wmWindow;
-struct ListBase;
+struct wmWindowManager;
/* spacetype has everything stored to get an editor working, it gets initialized via
ED_spacetypes_init() in editors/area/spacetypes.c */
/* sets default cursor per region */
void (*cursor)(struct wmWindow *win, struct ARegion *ar);
+ /* return context data */
+ int (*context)(const struct bContext *, const struct bContextDataMember *, struct bContextDataResult *);
+
/* region type definitions */
ListBase regiontypes;
/* add own items to keymap */
void (*keymap)(struct wmWindowManager *);
+ /* return context data */
+ int (*context)(const struct bContext *, const struct bContextDataMember *, struct bContextDataResult *);
+
/* hardcoded constraints, smaller than these values region is not visible */
int minsizex, minsizey;
/* default keymaps to add */
sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc ../editors/include ../blenlib ../makesdna'
-incs += ' ../render/extern/include #/intern/decimation/extern'
+incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna'
incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes'
incs += ' #/intern/iksolver/extern ../blenloader'
incs += ' #/extern/bullet2/src'
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
# Reference to the types in makesdna and imbuf
CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I../../makesrna
CPPFLAGS += -I../../imbuf
# This mod uses the BLI and BLO module
CPPFLAGS += -I../../blenlib
#include "BKE_action.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
SWAP(ListBase, G.main->script, bfd->main->script);
/* we re-use current screen */
- curscreen= C->screen;
+ curscreen= CTX_wm_screen(C);
/* but use new Scene pointer */
curscene= bfd->curscene;
if(curscene==NULL) curscene= bfd->main->scene.first;
if(mode!='u') G.save_over = 1;
G.main= bfd->main;
+ CTX_data_main_set(C, G.main);
if (bfd->user) {
/* case G_FILE_NO_UI or no screens in file */
if(mode) {
- C->screen= curscreen;
- C->scene= curscene;
+ CTX_wm_screen_set(C, curscreen);
+ CTX_data_scene_set(C, curscene);
}
else {
G.winpos= bfd->winpos;
G.displaymode= bfd->displaymode;
G.fileflags= bfd->fileflags;
- C->screen= bfd->curscreen;
- C->scene= C->screen->scene;
+ CTX_wm_screen_set(C, bfd->curscreen);
+ CTX_data_scene_set(C, bfd->curscreen->scene);
}
/* this can happen when active scene was lib-linked, and doesnt exist anymore */
- if(C->scene==NULL) {
- C->scene= G.main->scene.first;
- C->screen->scene= C->scene;
+ if(CTX_data_scene(C)==NULL) {
+ CTX_data_scene_set(C, G.main->scene.first);
+ CTX_wm_screen(C)->scene= CTX_data_scene(C);
}
/* special cases, override loaded flags: */
}
/* baseflags, groups, make depsgraph, etc */
- set_scene_bg(C->scene);
+ set_scene_bg(CTX_data_scene(C));
/* clear BONE_UNKEYED flags, these are not valid anymore for proxies */
framechange_poses_clear_unkeyed();
}
/* now tag update flags, to ensure deformers get calculated on redraw */
- DAG_scene_update_flags(C->scene, C->scene->lay);
+ DAG_scene_update_flags(CTX_data_scene(C), CTX_data_scene(C)->lay);
if (G.f & G_DOSCRIPTLINKS) {
/* there's an onload scriptlink to execute in screenmain */
--- /dev/null
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "RNA_access.h"
+
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_screen.h"
+
+#include <string.h>
+
+/* struct */
+
+struct bContext {
+ bContextTask task;
+ ReportList *reports;
+ int thread;
+
+ /* windowmanager context */
+ struct {
+ struct wmWindowManager *manager;
+ struct wmWindow *window;
+ struct bScreen *screen;
+ struct ScrArea *area;
+ struct ARegion *region;
+ struct uiBlock *block;
+
+ bContextDataCallback manager_cb;
+ bContextDataCallback window_cb;
+ bContextDataCallback screen_cb;
+ bContextDataCallback area_cb;
+ bContextDataCallback region_cb;
+ bContextDataCallback block_cb;
+ } wm;
+
+ /* data context */
+ struct {
+ struct Main *main;
+ struct Scene *scene;
+ } data;
+
+ /* data evaluation */
+ struct {
+ int render;
+ } eval;
+};
+
+/* context */
+
+bContext *CTX_create()
+{
+ bContext *C;
+
+ C= MEM_callocN(sizeof(bContext), "bContext");
+
+ C->task= CTX_UNDEFINED;
+ C->thread= 0;
+
+ return C;
+}
+
+bContext *CTX_copy(const bContext *C, int thread)
+{
+ bContext *newC;
+
+ if(C->task != CTX_UNDEFINED)
+ BKE_report(C->reports, RPT_ERROR_INVALID_CONTEXT, "CTX_copy not allowed for this task");
+
+ newC= MEM_dupallocN((void*)C);
+ newC->thread= thread;
+
+ return newC;
+}
+
+int CTX_thread(const bContext *C)
+{
+ return C->thread;
+}
+
+void CTX_free(bContext *C)
+{
+ MEM_freeN(C);
+}
+
+/* context task and reports */
+
+bContextTask CTX_task(const bContext *C)
+{
+ return C->task;
+}
+
+void CTX_task_set(bContext *C, bContextTask task)
+{
+ C->task= task;
+}
+
+ReportList *CTX_reports(const bContext *C)
+{
+ return C->reports;
+}
+
+void CTX_reports_set(bContext *C, ReportList *reports)
+{
+ C->reports= reports;
+}
+
+/* window manager context */
+
+wmWindowManager *CTX_wm_manager(const bContext *C)
+{
+ return C->wm.manager;
+}
+
+wmWindow *CTX_wm_window(const bContext *C)
+{
+ return C->wm.window;
+}
+
+bScreen *CTX_wm_screen(const bContext *C)
+{
+ return C->wm.screen;
+}
+
+ScrArea *CTX_wm_area(const bContext *C)
+{
+ return C->wm.area;
+}
+
+SpaceLink *CTX_wm_space_data(const bContext *C)
+{
+ return (C->wm.area)? C->wm.area->spacedata.first: NULL;
+}
+
+ARegion *CTX_wm_region(const bContext *C)
+{
+ return C->wm.region;
+}
+
+void *CTX_wm_region_data(const bContext *C)
+{
+ return (C->wm.region)? C->wm.region->regiondata: NULL;
+}
+
+struct uiBlock *CTX_wm_ui_block(const bContext *C)
+{
+ return C->wm.block;
+}
+
+void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
+{
+ C->wm.manager= wm;
+}
+
+void CTX_wm_window_set(bContext *C, wmWindow *win)
+{
+ C->wm.window= win;
+ C->wm.screen= (win)? win->screen: NULL;
+ C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
+}
+
+void CTX_wm_screen_set(bContext *C, bScreen *screen)
+{
+ C->wm.screen= screen;
+ C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
+}
+
+void CTX_wm_area_set(bContext *C, ScrArea *area)
+{
+ C->wm.area= area;
+ C->wm.area_cb= (area && area->type)? area->type->context: NULL;
+}
+
+void CTX_wm_region_set(bContext *C, ARegion *region)
+{
+ C->wm.region= region;
+ C->wm.region_cb= (region && region->type)? region->type->context: NULL;
+}
+
+void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallback cb)
+{
+ C->wm.block= block;
+ C->wm.block_cb= cb;
+}
+
+/* data context utility functions */
+
+struct bContextDataMember {
+ StructRNA *rna;
+ const char *name;
+ int collection;
+};
+
+bContextDataMember CTX_DataMain = {&RNA_Main, "main", 0};
+bContextDataMember CTX_DataScene = {&RNA_Scene, "scene", 0};
+
+bContextDataMember CTX_DataObjects = {&RNA_Object, "objects", 1};
+
+bContextDataMember CTX_DataEditObject = {&RNA_Object, "edit_object", 0};
+bContextDataMember CTX_DataEditArmature = {NULL, "edit_armature", 0};
+bContextDataMember CTX_DataEditMesh = {NULL, "edit_mesh", 0};
+
+static int ctx_data_get(const bContext *C, const bContextDataMember *member, bContextDataResult *result)
+{
+ if(C->wm.block_cb && C->wm.block_cb(C, member, result)) return 1;
+ if(C->wm.region_cb && C->wm.region_cb(C, member, result)) return 1;
+ if(C->wm.area_cb && C->wm.area_cb(C, member, result)) return 1;
+ if(C->wm.screen_cb && C->wm.screen_cb(C, member, result)) return 1;
+ if(C->wm.window_cb && C->wm.window_cb(C, member, result)) return 1;
+ if(C->wm.manager_cb && C->wm.manager_cb(C, member, result)) return 1;
+
+ return 0;
+}
+
+static void *ctx_data_pointer_get(const bContext *C, const bContextDataMember *member)
+{
+ bContextDataResult result;
+
+ if(ctx_data_get(C, member, &result))
+ return result.pointer;
+
+ return NULL;
+}
+
+static int ctx_data_pointer_verify(const bContext *C, const bContextDataMember *member, void **pointer)
+{
+ bContextDataResult result;
+
+ if(ctx_data_get(C, member, &result)) {
+ *pointer= result.pointer;
+ return 1;
+ }
+ else {
+ *pointer= NULL;
+ return 0;
+ }
+}
+
+static int ctx_data_collection_get(const bContext *C, const bContextDataMember *member, bContextDataIterator *iter)
+{
+ bContextDataResult result;
+
+ if(ctx_data_get(C, member, &result)) {
+ *iter= result.iterator;
+ return 1;
+ }
+
+ return 0;
+}
+
+/* data context */
+
+Main *CTX_data_main(const bContext *C)
+{
+ Main *bmain;
+
+ if(ctx_data_pointer_verify(C, &CTX_DataMain, (void*)&bmain))
+ return bmain;
+ else
+ return C->data.main;
+}
+
+void CTX_data_main_set(bContext *C, Main *bmain)
+{
+ C->data.main= bmain;
+}
+
+Scene *CTX_data_scene(const bContext *C)
+{
+ Scene *scene;
+
+ if(ctx_data_pointer_verify(C, &CTX_DataScene, (void*)&scene))
+ return scene;
+ else
+ return C->data.scene;
+}
+
+void CTX_data_scene_set(bContext *C, Scene *scene)
+{
+ C->data.scene= scene;
+}
+
+ToolSettings *CTX_data_tool_settings(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+
+ if(scene)
+ return scene->toolsettings;
+ else
+ return NULL;
+}
+
+int CTX_data_objects(const bContext *C, bContextDataIterator *iter)
+{
+ return ctx_data_collection_get(C, &CTX_DataObjects, iter);
+}
+
+struct Object *CTX_data_edit_object(const bContext *C)
+{
+ return ctx_data_pointer_get(C, &CTX_DataEditObject);
+}
+
+struct EditMesh *CTX_data_edit_mesh(const bContext *C)
+{
+ return ctx_data_pointer_get(C, &CTX_DataEditMesh);
+}
+
+ListBase *CTX_data_edit_armature(const bContext *C)
+{
+ return ctx_data_pointer_get(C, &CTX_DataEditArmature);
+}
+
+/* data evaluation */
+
+float CTX_eval_frame(const bContext *C)
+{
+ return (C->data.scene)? C->data.scene->r.cfra: 0.0f;
+}
+
+int CTX_eval_render_resolution(const bContext *C)
+{
+ return C->eval.render;
+}
+
+void CTX_eval_render_resolution_set(bContext *C, int render)
+{
+ C->eval.render= render;
+}
+
#include "BLI_dynstr.h"
#include "BKE_library.h"
+#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_sound.h"
--- /dev/null
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_report.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef _WIN32
+#ifndef vsnprintf
+#define vsnprintf _vsnprintf
+#endif
+#endif
+
+static char *report_type_str(int type)
+{
+ switch(type) {
+ case RPT_DEBUG: return "Debug";
+ case RPT_INFO: return "Info";
+ case RPT_WARNING: return "Warning";
+ case RPT_ERROR: return "Error";
+ case RPT_ERROR_INVALID_INPUT: return "Invalid Input Error";
+ case RPT_ERROR_INVALID_CONTEXT: return "Invalid Context Error";
+ case RPT_ERROR_OUT_OF_MEMORY: return "Out Of Memory Error";
+ default: return "Undefined Type";
+ }
+}
+
+void BKE_report_list_init(ReportList *reports, int flags)
+{
+ memset(reports, 0, sizeof(ReportList));
+
+ reports->level= RPT_WARNING;
+ reports->flags= flags;
+}
+
+void BKE_report_list_clear(ReportList *reports)
+{
+ Report *report;
+
+ for(report=reports->list.first; report; report=report->next)
+ MEM_freeN(report->message);
+
+ BLI_freelistN(&reports->list);
+}
+
+void BKE_report(ReportList *reports, ReportType type, const char *message)
+{
+ Report *report;
+ int len;
+
+ if(!reports || type < reports->level)
+ return;
+
+ if(reports->flags & RPT_PRINT) {
+ printf("%s: %s\n", report_type_str(type), message);
+ fflush(stdout); /* this ensures the message is printed before a crash */
+ }
+
+ if(reports->flags & RPT_STORE) {
+ report= MEM_callocN(sizeof(Report), "Report");
+ report->type= type;
+ report->typestr= report_type_str(type);
+
+ len= strlen(message);
+ report->message= MEM_callocN(sizeof(char)*(len+1), "ReportMessage");
+ memcpy(report->message, message, sizeof(char)*(len+1));
+
+ BLI_addtail(&reports->list, report);
+ }
+}
+
+void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
+{
+ Report *report;
+ va_list args;
+ char *message;
+ int len= 256, maxlen= 65536, retval;
+
+ if(!reports || type < reports->level)
+ return;
+
+ if(reports->flags & RPT_PRINT) {
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+ fflush(stdout); /* this ensures the message is printed before a crash */
+ }
+
+ if(reports->flags & RPT_STORE) {
+ while(1) {
+ message= MEM_callocN(sizeof(char)*len+1, "ReportMessage");
+
+ va_start(args, format);
+ retval= vsnprintf(message, len, format, args);
+ va_end(args);
+
+ if(retval == -1) {
+ /* -1 means not enough space, but on windows it may also mean
+ * there is a formatting error, so we impose a maximum length */
+ MEM_freeN(message);
+ message= NULL;
+
+ len *= 2;
+ if(len > maxlen) {
+ fprintf(stderr, "BKE_reportf message too long or format error.\n");
+ break;
+ }
+ }
+ else if(retval > len) {
+ /* in C99 the actual length required is returned */
+ MEM_freeN(message);
+ message= NULL;
+
+ len= retval;
+ }
+ else
+ break;
+ }
+
+ if(message) {
+ report= MEM_callocN(sizeof(Report), "Report");
+ report->type= type;
+ report->typestr= report_type_str(type);
+ report->message= message;
+
+ BLI_addtail(&reports->list, report);
+ }
+ }
+}
+
+ReportType BKE_report_level(ReportList *reports)
+{
+ return reports->level;
+}
+
+void BKE_report_level_set(ReportList *reports, ReportType level)
+{
+ reports->level= level;
+}
+
+int BKE_report_has_error(ReportList *reports)
+{
+ Report *report;
+
+ if(!reports)
+ return 0;
+
+ for(report=reports->list.first; report; report=report->next)
+ if(report->type >= RPT_ERROR)
+ return 1;
+
+ return 0;
+}
+
#include "BKE_action.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_cloth.h"
#include "BKE_curve.h"
#include "BKE_customdata.h"
Scene *sce;
int data[8];
- sce= G.main->scene.first;
+ sce= CTX_data_main(C)->scene.first;
while(sce) {
- if(sce->id.lib==0 && ( sce==C->scene || (sce->r.scemode & R_BG_RENDER)) ) {
+ if(sce->id.lib==0 && ( sce==CTX_data_scene(C) || (sce->r.scemode & R_BG_RENDER)) ) {
data[0]= sce->r.sfra;
data[1]= sce->r.efra;
FileGlobal fg;
char subvstr[8];
- fg.curscreen= C->screen;
- fg.curscene= C->scene;
+ fg.curscreen= CTX_wm_screen(C);
+ fg.curscene= CTX_data_scene(C);
fg.displaymode= G.displaymode;
fg.winpos= G.winpos;
fg.fileflags= (G.fileflags & ~G_FILE_NO_UI); // prevent to save this, is not good convention, and feature with concerns...
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_screen.h"
wmWindow *window;
int getsizex, getsizey;
- window= C->window;
+ window= CTX_wm_window(C);
lb= ®ion->uiblocks;
/* each listbase only has one block with this name, free block
static void autocomplete_id(bContext *C, char *str, void *arg_v)
{
int blocktype= (intptr_t)arg_v;
- ListBase *listb= wich_libbase(G.main, blocktype); /* XXX */
+ ListBase *listb= wich_libbase(CTX_data_main(C), blocktype);
if(listb==NULL) return;
#include "PIL_time.h"
#include "BKE_colortools.h"
+#include "BKE_context.h"
#include "BKE_idprop.h"
-#include "BKE_global.h"
+#include "BKE_report.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
/* XXX 2.50 missing python api */
#if 0
if(BPY_button_eval(data->str, &data->value)) {
- WM_report(C, WM_LOG_WARNING, "Invalid Python expression, check console");
+ BKE_report(CTX_reports(C), RPT_WARNING, "Invalid Python expression, check console");
data->value = 0.0f; /* Zero out value on error */
if(data->str[0]) {
if(ELEM(event->type, LEFTMOUSE, RETKEY)) {
if(but->lock) {
if(but->lockstr) {
- WM_report(C, WM_LOG_WARNING, but->lockstr);
+ BKE_report(CTX_reports(C), RPT_WARNING, but->lockstr);
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
}
else if(but->pointype && but->poin==0) {
/* there's a pointer needed */
- WM_reportf(C, WM_LOG_WARNING, "DoButton pointer error: %s", but->str);
+ BKE_reportf(CTX_reports(C), RPT_WARNING, "DoButton pointer error: %s", but->str);
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
/* setup struct */
data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
- data->window= C->window;
+ data->window= CTX_wm_window(C);
data->region= ar;
data->interactive= 0;
data->state = BUTTON_STATE_INIT;
int retval;
/* here we handle buttons at the region level, non-modal */
- ar= C->region;
+ ar= CTX_wm_region(C);
retval= WM_UI_HANDLER_CONTINUE;
if(ar==NULL) return retval;
bScreen *sc;
ARegion *ar;
- ar= C->region;
+ ar= CTX_wm_region(C);
if(ar == NULL) return;
uiFreeBlocks(C, &ar->uiblocks);
- sc= C->screen;
+ sc= CTX_wm_screen(C);
if(sc == NULL) return;
/* delayed apply callbacks, but not for screen level regions, those
/* here we handle buttons at the window level, modal, for example
* while number sliding, text editing, or when a menu block is open */
- ar= C->region;
+ ar= CTX_wm_region(C);
but= ui_but_find_activated(ar);
if(but) {
/* free if done, does not free handle itself */
if(menu->menuretval) {
ui_menu_block_free(C, menu);
- WM_event_remove_ui_handler(&C->window->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
+ WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
if(menu->menuretval == UI_RETURN_OK && menu->popup_func)
menu->popup_func(C, menu->popup_arg, menu->retvalue);
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
return NULL;
/* create area region */
- ar= ui_add_temporary_region(C->window->screen);
+ ar= ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
type.draw= ui_tooltip_region_draw;
y2 += butregion->winrct.ymin;
}
- wm_window_get_size(C->window, &winx, &winy);
+ wm_window_get_size(CTX_wm_window(C), &winx, &winy);
if(x2 > winx) {
/* super size */
void ui_tooltip_free(bContext *C, ARegion *ar)
{
- ui_remove_temporary_region(C, C->window->screen, ar);
+ ui_remove_temporary_region(C, CTX_wm_screen(C), ar);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockFuncFP block_func, void *arg)
{
+ wmWindow *window= CTX_wm_window(C);
static ARegionType type;
ARegion *ar;
uiBlock *block;
handle= MEM_callocN(sizeof(uiMenuBlockHandle), "uiMenuBlockHandle");
/* create area region */
- ar= ui_add_temporary_region(C->window->screen);
+ ar= ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
type.draw= ui_block_region_draw;
if(but->flag & UI_MAKE_LEFT) block->direction |= UI_LEFT;
if(but->flag & UI_MAKE_RIGHT) block->direction |= UI_RIGHT;
- ui_block_position(C->window, butregion, but, block);
+ ui_block_position(window, butregion, but, block);
}
else {
/* keep a list of these, needed for pulldown menus */
ED_region_init(C, ar);
/* get winmat now that we actually have the subwindow */
- wm_subwindow_set(C->window, ar->swinid);
- wm_subwindow_getmatrix(C->window, ar->swinid, block->winmat);
+ wm_subwindow_set(window, ar->swinid);
+ wm_subwindow_getmatrix(window, ar->swinid, block->winmat);
/* notify change and redraw */
ED_region_tag_redraw(ar);
void ui_menu_block_free(bContext *C, uiMenuBlockHandle *handle)
{
- ui_remove_temporary_region(C, C->window->screen, handle->region);
+ ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region);
MEM_freeN(handle);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
width+= 10;
if (width<50) width=50;
- wm_window_get_size(C->window, &xmax, &ymax);
+ wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
/* set first item */
lastselected= 0;
height= rows*MENU_BUTTON_HEIGHT;
if (md->title) height+= MENU_BUTTON_HEIGHT;
- wm_window_get_size(C->window, &xmax, &ymax);
+ wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
/* find active item */
fvalue= handle->retvalue;
uiBoundsBlock(block, 1);
uiEndBlock(C, block);
-
-#if 0
- event= uiDoBlocks(&listb, 0, 1);
-#endif
menudata_free(md);
void uiPupmenu(bContext *C, int maxrow, uiPupmenuFunc func, void *arg, char *str, ...)
{
+ wmWindow *window= CTX_wm_window(C);
uiPupMenuInfo info;
uiMenuBlockHandle *menu;
memset(&info, 0, sizeof(info));
- info.mx= C->window->eventstate->x;
- info.my= C->window->eventstate->y;
+ info.mx= window->eventstate->x;
+ info.my= window->eventstate->y;
info.maxrow= maxrow;
info.instr= str;
menu= ui_menu_block_create(C, NULL, NULL, ui_block_func_PUPMENU, &info);
menu->popup= 1;
- UI_add_popup_handlers(&C->window->handlers, menu);
+ UI_add_popup_handlers(&window->handlers, menu);
WM_event_add_mousemove(C);
menu->popup_func= func;
#include "BLI_blenlib.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
{
+ wmWindow *window= CTX_wm_window(C);
rctf curmasked;
/* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied,
* as they were causing some unwanted offsets when drawing
*/
view2d_map_cur_using_mask(v2d, &curmasked);
- wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
+ wmOrtho2(window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
/* XXX is this necessary? */
- wmLoadIdentity(C->window);
+ wmLoadIdentity(window);
}
/* Set view matrices to only use one axis of 'cur' only
*/
void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
{
- ARegion *ar= C->region;
+ wmWindow *window= CTX_wm_window(C);
+ ARegion *ar= CTX_wm_region(C);
rctf curmasked;
/* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied,
*/
view2d_map_cur_using_mask(v2d, &curmasked);
if (xaxis)
- wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, 0, ar->winy);
+ wmOrtho2(window, curmasked.xmin, curmasked.xmax, 0, ar->winy);
else
- wmOrtho2(C->window, 0, ar->winx, curmasked.ymin, curmasked.ymax);
+ wmOrtho2(window, 0, ar->winx, curmasked.ymin, curmasked.ymax);
/* XXX is this necessary? */
- wmLoadIdentity(C->window);
+ wmLoadIdentity(window);
}
/* Restore view matrices after drawing */
void UI_view2d_view_restore(const bContext *C)
{
- ED_region_pixelspace(C, C->region);
+ ED_region_pixelspace(C, CTX_wm_region(C));
}
/* *********************************************************************** */
/* View2D data by default resides in region, so get from region stored in context */
View2D *UI_view2d_fromcontext(const bContext *C)
{
- if (C->area == NULL) return NULL;
- if (C->region == NULL) return NULL;
- return &(C->region->v2d);
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
+
+ if (area == NULL) return NULL;
+ if (region == NULL) return NULL;
+ return &(region->v2d);
}
/* same as above, but it returns regionwindow. Utility for pulldowns or buttons */
View2D *UI_view2d_fromcontext_rwin(const bContext *C)
{
- if (C->area == NULL) return NULL;
- if (C->region == NULL) return NULL;
- if (C->region->regiontype!=RGN_TYPE_WINDOW) {
- ARegion *ar= C->area->regionbase.first;
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
+
+ if (area == NULL) return NULL;
+ if (region == NULL) return NULL;
+ if (region->regiontype!=RGN_TYPE_WINDOW) {
+ ARegion *ar= area->regionbase.first;
for(; ar; ar= ar->next)
if(ar->regiontype==RGN_TYPE_WINDOW)
return &(ar->v2d);
return NULL;
}
- return &(C->region->v2d);
+ return &(region->v2d);
}
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
*/
static short mouse_in_v2d_scrollers (const bContext *C, View2D *v2d, int x, int y)
{
- ARegion *ar= C->region;
+ ARegion *ar= CTX_wm_region(C);
int co[2];
/* clamp x,y to region-coordinates first */
/* initialise panning customdata */
static int view_pan_init(bContext *C, wmOperator *op)
{
+ ARegion *ar= CTX_wm_region(C);
v2dViewPanData *vpd;
- ARegion *ar;
View2D *v2d;
float winx, winy;
/* regions now have v2d-data by default, so check for region */
- if (C->region == NULL)
+ if (ar == NULL)
return 0;
- ar= C->region;
/* set custom-data for operator */
vpd= MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- ED_area_tag_redraw(C->area);
- UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
}
/* cleanup temp customdata */
/* set up modal operator and relevant settings */
static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ wmWindow *window= CTX_wm_window(C);
v2dViewPanData *vpd;
View2D *v2d;
RNA_int_set(op->ptr, "deltay", 0);
if (v2d->keepofs & V2D_LOCKOFS_X)
- WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_NS_SCROLLCURSOR);
else if (v2d->keepofs & V2D_LOCKOFS_Y)
- WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_EW_SCROLLCURSOR);
else
- WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR);
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &window->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
view_pan_exit(C, op);
- WM_cursor_restore(C->window);
+ WM_cursor_restore(CTX_wm_window(C));
return OPERATOR_FINISHED;
}
/* check if step-zoom can be applied */
static short view_zoomstep_ok(bContext *C)
{
+ ARegion *ar= CTX_wm_region(C);
View2D *v2d;
/* check if there's a region in context to work with */
- if (C->region == NULL)
+ if (ar == NULL)
return 0;
- v2d= &C->region->v2d;
+ v2d= &ar->v2d;
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
/* apply transform to view (i.e. adjust 'cur' rect) */
static void view_zoomstep_apply(bContext *C, wmOperator *op)
{
- View2D *v2d= &C->region->v2d;
+ ARegion *ar= CTX_wm_region(C);
+ View2D *v2d= &ar->v2d;
float dx, dy;
/* calculate amount to move view by */
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- ED_area_tag_redraw(C->area);
- UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
}
/* --------------- Individual Operators ------------------- */
/* initialise panning customdata */
static int view_zoomdrag_init(bContext *C, wmOperator *op)
{
+ ARegion *ar= CTX_wm_region(C);
v2dViewZoomData *vzd;
View2D *v2d;
/* regions now have v2d-data by default, so check for region */
- if (C->region == NULL)
+ if (ar == NULL)
return 0;
- v2d= &C->region->v2d;
+ v2d= &ar->v2d;
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- ED_area_tag_redraw(C->area);
- UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
}
/* cleanup temp customdata */
/* set up modal operator and relevant settings */
static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ wmWindow *window= CTX_wm_window(C);
v2dViewZoomData *vzd;
View2D *v2d;
RNA_float_set(op->ptr, "deltay", 0);
if (v2d->keepofs & V2D_LOCKOFS_X)
- WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_NS_SCROLLCURSOR);
else if (v2d->keepofs & V2D_LOCKOFS_Y)
- WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_EW_SCROLLCURSOR);
else
- WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR);
+ WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR);
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &window->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
/* free customdata */
view_zoomdrag_exit(C, op);
- WM_cursor_restore(C->window);
+ WM_cursor_restore(CTX_wm_window(C));
return OPERATOR_FINISHED;
}
{
v2dScrollerMove *vsm;
View2DScrollers *scrollers;
- ARegion *ar= C->region;
+ ARegion *ar= CTX_wm_region(C);
View2D *v2d= &ar->v2d;
float mask_size;
int x, y;
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- ED_area_tag_redraw(C->area);
- UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
}
/* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */
/* a click (or click drag in progress) should have occurred, so check if it happened in scrollbar */
static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ARegion *ar= CTX_wm_region(C);
View2D *v2d= NULL;
short in_scroller= 0;
/* firstly, check context to see if mouse is actually in region */
// XXX isn't this the job of poll() callbacks which can't check events, but only context?
- if (C->region == NULL)
+ if (ar == NULL)
return OPERATOR_CANCELLED;
else
- v2d= &C->region->v2d;
+ v2d= &ar->v2d;
/* check if mouse in scrollbars, if they're enabled */
in_scroller= mouse_in_v2d_scrollers(C, v2d, event->x, event->y);
}
/* still ok, so can add */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
else {
#include "BLI_arithb.h"
#include "BLI_rand.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
void ED_region_pixelspace(const bContext *C, ARegion *ar)
{
+ wmWindow *win= CTX_wm_window(C);
int width= ar->winrct.xmax-ar->winrct.xmin+1;
int height= ar->winrct.ymax-ar->winrct.ymin+1;
- wmOrtho2(C->window, -0.375, (float)width-0.375, -0.375, (float)height-0.375);
- wmLoadIdentity(C->window);
+ wmOrtho2(win, -0.375, (float)width-0.375, -0.375, (float)height-0.375);
+ wmLoadIdentity(win);
}
void ED_region_do_listen(ARegion *ar, wmNotifier *note)
{
ScrArea *sa;
- for(sa= C->screen->areabase.first; sa; sa= sa->next) {
+ for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) {
ARegion *ar;
for(ar= sa->regionbase.first; ar; ar= ar->next) {
void ED_area_overdraw(bContext *C)
{
+ wmWindow *win= CTX_wm_window(C);
+ bScreen *screen= CTX_wm_screen(C);
ScrArea *sa;
/* Draw AZones, in screenspace */
- wm_subwindow_set(C->window, C->window->screen->mainwin);
+ wm_subwindow_set(win, screen->mainwin);
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- for(sa= C->screen->areabase.first; sa; sa= sa->next) {
+ for(sa= screen->areabase.first; sa; sa= sa->next) {
AZone *az;
for(az= sa->actionzones.first; az; az= az->next) {
if(az->do_draw) {
void ED_region_do_draw(bContext *C, ARegion *ar)
{
+ wmWindow *win= CTX_wm_window(C);
+ ScrArea *sa= CTX_wm_area(C);
ARegionType *at= ar->type;
- wm_subwindow_set(C->window, ar->swinid);
+ wm_subwindow_set(win, ar->swinid);
if(ar->swinid && at->draw) {
- UI_SetTheme(C->area);
+ UI_SetTheme(sa);
at->draw(C, ar);
UI_SetTheme(NULL);
}
glRecti(20, 2, 30, 12);
}
- if(C->area)
+ if(sa)
region_draw_emboss(ar);
/* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
// ARegionType *at= ar->type;
/* refresh can be called before window opened */
- region_subwindow(C->wm, C->window, ar);
+ region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar);
}
}
}
- ED_area_initialize(C->wm, C->window, sa);
+ ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
static void spacefunc(struct bContext *C, void *arg1, void *arg2)
{
- area_newspace(C, C->area, C->area->butspacetype);
- ED_area_tag_redraw(C->area);
+ area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
+ ED_area_tag_redraw(CTX_wm_area(C));
}
/* returns offset for next button in header */
int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
{
+ ScrArea *sa= CTX_wm_area(C);
uiBut *but;
int xco= 8;
but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D,
windowtype_pup(), xco, yco, XIC+10, YIC,
- &(C->area->butspacetype), 1.0, SPACEICONMAX, 0, 0,
+ &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0,
"Displays Current Window Type. "
"Click for menu of available types.");
uiButSetFunc(but, spacefunc, NULL, NULL);
xco += XIC + 14;
uiBlockSetEmboss(block, UI_EMBOSSN);
- if (C->area->flag & HEADER_NO_PULLDOWN) {
+ if (sa->flag & HEADER_NO_PULLDOWN) {
uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
ICON_DISCLOSURE_TRI_RIGHT,
xco,yco,XIC,YIC-2,
- &(C->area->flag), 0, 0, 0, 0,
+ &(sa->flag), 0, 0, 0, 0,
"Show pulldown menus");
}
else {
uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
ICON_DISCLOSURE_TRI_DOWN,
xco,yco,XIC,YIC-2,
- &(C->area->flag), 0, 0, 0, 0,
+ &(sa->flag), 0, 0, 0, 0,
"Hide pulldown menus");
}
xco+=XIC;
#include "BLI_blenlib.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
void ED_region_exit(bContext *C, ARegion *ar)
{
- ARegion *prevar= C->region;
+ ARegion *prevar= CTX_wm_region(C);
- C->region= ar;
+ CTX_wm_region_set(C, ar);
WM_event_remove_handlers(C, &ar->handlers);
- C->region= prevar;
+ CTX_wm_region_set(C, prevar);
}
void ED_area_exit(bContext *C, ScrArea *sa)
{
- ScrArea *prevsa= C->area;
+ ScrArea *prevsa= CTX_wm_area(C);
ARegion *ar;
- C->area= sa;
+ CTX_wm_area_set(C, sa);
for(ar= sa->regionbase.first; ar; ar= ar->next)
ED_region_exit(C, ar);
WM_event_remove_handlers(C, &sa->handlers);
- C->area= prevsa;
+ CTX_wm_area_set(C, prevsa);
}
void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
{
- wmWindow *prevwin= C?C->window:NULL;
+ wmWindow *prevwin= CTX_wm_window(C);
ScrArea *sa;
ARegion *ar;
- C->window= window;
+ CTX_wm_window_set(C, window);
for(ar= screen->regionbase.first; ar; ar= ar->next)
ED_region_exit(C, ar);
for(sa= screen->areabase.first; sa; sa= sa->next)
ED_area_exit(C, sa);
- C->window= prevwin;
+ CTX_wm_window_set(C, prevwin);
}
/* case when on area-edge or in azones, or outside window */
int ED_screen_area_active(const bContext *C)
{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa= CTX_wm_area(C);
- if(C->screen && C->area) {
+ if(sc && sa) {
ARegion *ar;
- for(ar= C->area->regionbase.first; ar; ar= ar->next)
- if(ar->swinid == C->screen->subwinactive)
+ for(ar= sa->regionbase.first; ar; ar= ar->next)
+ if(ar->swinid == sc->subwinactive)
return 1;
}
return 0;
/* Do NOT call in area/region queues! */
void ed_screen_set(bContext *C, bScreen *sc)
{
-
if(sc->full) { /* find associated full */
bScreen *sc1;
for(sc1= G.main->screen.first; sc1; sc1= sc1->id.next) {
if(sc1==NULL) printf("set screen error\n");
}
- if (C->screen != sc) {
- ED_screen_exit(C, C->window, C->screen);
- C->window->screen= sc;
- C->screen= sc;
+ if (CTX_wm_screen(C) != sc) {
+ ED_screen_exit(C, CTX_wm_window(C), CTX_wm_screen(C));
+ CTX_wm_window(C)->screen= sc;
- ED_screen_refresh(C->wm, C->window);
+ ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
}
ScrArea *newa, *old;
short fulltype;
- if(C->area->full) {
- sc= C->area->full; /* the old screen to restore */
- oldscreen= C->screen; /* the one disappearing */
+ if(CTX_wm_area(C)->full) {
+ sc= CTX_wm_area(C)->full; /* the old screen to restore */
+ oldscreen= CTX_wm_screen(C); /* the one disappearing */
fulltype = sc->full;
// in autoplay screens the headers are disabled by
// default. So use the old headertype instead
- area_copy_data(old, C->area, 1); /* 1 = swap spacelist */
+ area_copy_data(old, CTX_wm_area(C), 1); /* 1 = swap spacelist */
old->full= NULL;
}
}
else {
+ oldscreen= CTX_wm_screen(C);
+
/* is there only 1 area? */
- if(C->screen->areabase.first==C->screen->areabase.last) return;
- if(C->area->spacetype==SPACE_INFO) return;
+ if(oldscreen->areabase.first==CTX_wm_screen(C)->areabase.last) return;
+ if(CTX_wm_area(C)->spacetype==SPACE_INFO) return;
- C->screen->full = SCREENFULL;
+ oldscreen->full = SCREENFULL;
- oldscreen= C->screen;
- sc= screen_add(C->window, "temp");
+ sc= screen_add(CTX_wm_window(C), "temp");
/* returns the top small area */
- newa= area_split(C->window, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
+ newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
area_newspace(C, newa, SPACE_INFO);
/* copy area */
newa= newa->prev;
- area_copy_data(newa, C->area, 1); /* 1 = swap spacelist */
+ area_copy_data(newa, CTX_wm_area(C), 1); /* 1 = swap spacelist */
- C->area->full= oldscreen;
+ CTX_wm_area(C)->full= oldscreen;
newa->full= oldscreen;
newa->next->full= oldscreen;
- C->screen= oldscreen;
ed_screen_set(C, sc);
}
/* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */
- C->area= sc->areabase.first;
+ CTX_wm_area_set(C, sc->areabase.first);
/* XXX retopo_force_update(); */
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_screen.h"
int ED_operator_areaactive(bContext *C)
{
- if(C->window==NULL) return 0;
- if(C->screen==NULL) return 0;
- if(C->area==NULL) return 0;
+ if(CTX_wm_window(C)==NULL) return 0;
+ if(CTX_wm_screen(C)==NULL) return 0;
+ if(CTX_wm_area(C)==NULL) return 0;
return 1;
}
int ED_operator_screenactive(bContext *C)
{
- if(C->window==NULL) return 0;
- if(C->screen==NULL) return 0;
+ if(CTX_wm_window(C)==NULL) return 0;
+ if(CTX_wm_screen(C)==NULL) return 0;
return 1;
}
/* when mouse is over area-edge */
int ED_operator_screen_mainwinactive(bContext *C)
{
- if(C->window==NULL) return 0;
- if(C->screen==NULL) return 0;
- if (C->screen->subwinactive!=C->screen->mainwin) return 0;
+ if(CTX_wm_window(C)==NULL) return 0;
+ if(CTX_wm_screen(C)==NULL) return 0;
+ if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0;
return 1;
}
static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- AZone *az= is_in_area_actionzone(C->area, event->x, event->y);
+ AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
sActionzoneData *sad;
/* quick escape */
/* ok we do the actionzone */
sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
- sad->sa1= C->area;
+ sad->sa1= CTX_wm_area(C);
sad->az= az;
sad->x= event->x; sad->y= event->y;
/* add modal handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
static void actionzone_apply(bContext *C, wmOperator *op)
{
wmEvent event;
+ wmWindow *win= CTX_wm_window(C);
- event= *(C->window->eventstate); /* XXX huh huh? make api call */
+ event= *(win->eventstate); /* XXX huh huh? make api call */
event.type= EVT_ACTIONZONE;
event.customdata= op->customdata;
event.customdatafree= TRUE;
op->customdata= NULL;
- wm_event_add(C->window, &event);
+ wm_event_add(win, &event);
}
static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
if(ABS(deltax) > 12 || ABS(deltay) > 12) {
/* second area, for join */
- sad->sa2= screen_areahascursor(C->screen, event->x, event->y);
+ sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
/* apply sends event */
actionzone_apply(C, op);
actionzone_exit(C, op);
conventions: 'atomic' and 'dont think for user' :) */
static int screen_area_rip_op(bContext *C, wmOperator *op)
{
- wmWindow *win;
- bScreen *newsc;
+ wmWindow *newwin, *win;
+ bScreen *newsc, *sc;
+ ScrArea *sa;
rcti rect;
+ win= CTX_wm_window(C);
+ sc= CTX_wm_screen(C);
+ sa= CTX_wm_area(C);
+
/* poll() checks area context, but we don't accept full-area windows */
- if(C->screen->full != SCREENNORMAL)
+ if(sc->full != SCREENNORMAL)
return OPERATOR_CANCELLED;
/* adds window to WM */
- rect= C->area->totrct;
- BLI_translate_rcti(&rect, C->window->posx, C->window->posy);
- win= WM_window_open(C, &rect);
+ rect= sa->totrct;
+ BLI_translate_rcti(&rect, win->posx, win->posy);
+ newwin= WM_window_open(C, &rect);
/* allocs new screen and adds to newly created window, using window size */
- newsc= screen_add(win, C->screen->id.name+2);
+ newsc= screen_add(newwin, sc->id.name+2);
win->screen= newsc;
/* copy area to new screen */
- area_copy_data((ScrArea *)newsc->areabase.first, C->area, 0);
+ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0);
/* screen, areas init */
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
/* return 0: init failed */
static int area_move_init (bContext *C, wmOperator *op)
{
+ bScreen *sc= CTX_wm_screen(C);
ScrEdge *actedge;
sAreaMoveData *md;
int x, y;
y= RNA_int_get(op->ptr, "y");
/* setup */
- actedge= screen_find_active_scredge(C->screen, x, y);
+ actedge= screen_find_active_scredge(sc, x, y);
if(actedge==NULL) return 0;
md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
if(md->dir=='h') md->origval= actedge->v1->vec.y;
else md->origval= actedge->v1->vec.x;
- select_connected_scredge(C->screen, actedge);
+ select_connected_scredge(sc, actedge);
/* now all vertices with 'flag==1' are the ones that can be moved. */
- area_move_set_limits(C->screen, md->dir, &md->bigger, &md->smaller);
+ area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller);
return 1;
}
/* moves selected screen edge amount of delta, used by split & move */
static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller)
{
+ wmWindow *win= CTX_wm_window(C);
+ bScreen *sc= CTX_wm_screen(C);
ScrVert *v1;
delta= CLAMPIS(delta, -smaller, bigger);
- for (v1= C->screen->vertbase.first; v1; v1= v1->next) {
+ for (v1= sc->vertbase.first; v1; v1= v1->next) {
if (v1->flag) {
/* that way a nice AREAGRID */
- if((dir=='v') && v1->vec.x>0 && v1->vec.x<C->window->sizex-1) {
+ if((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-1) {
v1->vec.x= origval + delta;
if(delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID);
}
- if((dir=='h') && v1->vec.y>0 && v1->vec.y<C->window->sizey-1) {
+ if((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) {
v1->vec.y= origval + delta;
v1->vec.y+= AREAGRID-1;
v1->vec.y-= (v1->vec.y % AREAGRID);
/* prevent too small top header */
- if(v1->vec.y > C->window->sizey-AREAMINY)
- v1->vec.y= C->window->sizey-AREAMINY;
+ if(v1->vec.y > win->sizey-AREAMINY)
+ v1->vec.y= win->sizey-AREAMINY;
}
}
}
op->customdata= NULL;
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scrverts(C->screen);
- removedouble_scredges(C->screen);
+ removedouble_scrverts(CTX_wm_screen(C));
+ removedouble_scredges(CTX_wm_screen(C));
}
static int area_move_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
/* generic init, no UI stuff here */
static int area_split_init(bContext *C, wmOperator *op)
{
+ ScrArea *sa= CTX_wm_area(C);
sAreaSplitData *sd;
int dir;
/* required context */
- if(C->area==NULL) return 0;
+ if(sa==NULL) return 0;
/* required properties */
dir= RNA_enum_get(op->ptr, "dir");
/* minimal size */
- if(dir=='v' && C->area->winx < 2*AREAMINX) return 0;
- if(dir=='h' && C->area->winy < 2*AREAMINY) return 0;
+ if(dir=='v' && sa->winx < 2*AREAMINX) return 0;
+ if(dir=='h' && sa->winy < 2*AREAMINY) return 0;
/* custom data */
sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split");
op->customdata= sd;
- sd->sarea= C->area;
- sd->origsize= dir=='v' ? C->area->winx:C->area->winy;
- sd->origmin = dir=='v' ? C->area->totrct.xmin:C->area->totrct.ymin;
+ sd->sarea= sa;
+ sd->origsize= dir=='v' ? sa->winx:sa->winy;
+ sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin;
return 1;
}
/* do the split, return success */
static int area_split_apply(bContext *C, wmOperator *op)
{
+ bScreen *sc= CTX_wm_screen(C);
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
float fac;
int dir;
fac= RNA_float_get(op->ptr, "fac");
dir= RNA_enum_get(op->ptr, "dir");
- sd->narea= area_split(C->window, C->screen, sd->sarea, dir, fac);
+ sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac);
if(sd->narea) {
ScrVert *sv;
- sd->nedge= area_findsharededge(C->screen, sd->sarea, sd->narea);
+ sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea);
/* select newly created edge, prepare for moving edge */
- for(sv= C->screen->vertbase.first; sv; sv= sv->next)
+ for(sv= sc->vertbase.first; sv; sv= sv->next)
sv->flag = 0;
sd->nedge->v1->flag= 1;
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scrverts(C->screen);
- removedouble_scredges(C->screen);
+ removedouble_scrverts(CTX_wm_screen(C));
+ removedouble_scredges(CTX_wm_screen(C));
}
return OPERATOR_PASS_THROUGH;
/* is this our *sad? if areas not equal it should be passed on */
- if(C->area!=sad->sa1 || sad->sa1!=sad->sa2)
+ if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2)
return OPERATOR_PASS_THROUGH;
/* prepare operator state vars */
/* do the split */
if(area_split_apply(C, op)) {
- area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller);
+ area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller);
/* add temp handler for edge move or cancel */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
{
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
- if (screen_area_join(C, C->screen, sd->sarea, sd->narea)) {
- if (C->area == sd->narea) {
- C->area = NULL;
+ if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) {
+ if (CTX_wm_area(C) == sd->narea) {
+ CTX_wm_area_set(C, NULL);
}
sd->narea = NULL;
}
delta = RNA_int_get(op->ptr, "delta");
- C->scene->r.cfra += delta;
+ CTX_data_scene(C)->r.cfra += delta;
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
/* function to be called outside UI context, or for redo */
static int screen_set_exec(bContext *C, wmOperator *op)
{
- bScreen *screen= C->screen;
+ bScreen *screen= CTX_wm_screen(C);
int delta= RNA_int_get(op->ptr, "delta");
/* this screen is 'fake', solve later XXX */
- if(C->area->full)
+ if(CTX_wm_area(C)->full)
return OPERATOR_CANCELLED;
if(delta==1) {
screen= screen->id.next;
- if(screen==NULL) screen= G.main->screen.first;
+ if(screen==NULL) screen= CTX_data_main(C)->screen.first;
}
else if(delta== -1) {
screen= screen->id.prev;
- if(screen==NULL) screen= G.main->screen.last;
+ if(screen==NULL) screen= CTX_data_main(C)->screen.last;
}
else {
screen= NULL;
x2= RNA_int_get(op->ptr, "x2");
y2= RNA_int_get(op->ptr, "y2");
- sa1 = screen_areahascursor(C->screen, x1, y1);
- sa2 = screen_areahascursor(C->screen, x2, y2);
+ sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1);
+ sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2);
if(sa1==NULL || sa2==NULL || sa1==sa2)
return 0;
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
if (!jd) return 0;
- if(!screen_area_join(C, C->screen, jd->sa1, jd->sa2)){
+ if(!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)){
return 0;
}
- if (C->area == jd->sa2) {
- C->area = NULL;
+ if (CTX_wm_area(C) == jd->sa2) {
+ CTX_wm_area_set(C, NULL);
}
return 1;
}
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scredges(C->screen);
- removenotused_scredges(C->screen);
- removenotused_scrverts(C->screen);
+ removedouble_scredges(CTX_wm_screen(C));
+ removenotused_scredges(CTX_wm_screen(C));
+ removenotused_scrverts(CTX_wm_screen(C));
}
static int area_join_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
/* modal callback while selecting area (space) that will be removed */
static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
{
+ bScreen *sc= CTX_wm_screen(C);
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
/* execute the events */
case MOUSEMOVE:
{
- ScrArea *sa = screen_areahascursor(C->screen, event->x, event->y);
+ ScrArea *sa = screen_areahascursor(sc, event->x, event->y);
int dir;
if (sa) {
if (jd->sa1 != sa) {
- dir = area_getorientation(C->screen, jd->sa1, sa);
+ dir = area_getorientation(sc, jd->sa1, sa);
if (dir >= 0) {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
we check if area has common border with the one marked for removal
in this case we can swap areas.
*/
- dir = area_getorientation(C->screen, sa, jd->sa2);
+ dir = area_getorientation(sc, sa, jd->sa2);
if (dir >= 0) {
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
- dir = area_getorientation(C->screen, jd->sa1, jd->sa2);
+ dir = area_getorientation(sc, jd->sa1, jd->sa2);
if (dir < 0) {
printf("oops, didn't expect that!\n");
}
}
else {
- dir = area_getorientation(C->screen, jd->sa1, sa);
+ dir = area_getorientation(sc, jd->sa1, sa);
if (dir >= 0) {
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
jd->sa2 = sa;
static int repeat_last_exec(bContext *C, wmOperator *op)
{
- wmOperator *lastop= C->wm->operators.last;
+ wmOperator *lastop= CTX_wm_manager(C)->operators.last;
if(lastop) {
printf("repeat %s\n", lastop->type->idname);
/* insert a region in the area region list */
static int region_split_exec(bContext *C, wmOperator *op)
{
- ARegion *newar= BKE_area_region_copy(C->region);
+ ScrArea *sa= CTX_wm_area(C);
+ ARegion *ar= CTX_wm_region(C);
+ ARegion *newar= BKE_area_region_copy(ar);
int dir= RNA_enum_get(op->ptr, "dir");
- BLI_insertlinkafter(&C->area->regionbase, C->region, newar);
+ BLI_insertlinkafter(&sa->regionbase, CTX_wm_region(C), newar);
- newar->alignment= C->region->alignment;
+ newar->alignment= ar->alignment;
if(dir=='h')
- C->region->alignment= RGN_ALIGN_HSPLIT;
+ ar->alignment= RGN_ALIGN_HSPLIT;
else
- C->region->alignment= RGN_ALIGN_VSPLIT;
+ ar->alignment= RGN_ALIGN_VSPLIT;
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
/* flip a region alignment */
static int region_flip_exec(bContext *C, wmOperator *op)
{
- if(C->region->alignment==RGN_ALIGN_TOP)
- C->region->alignment= RGN_ALIGN_BOTTOM;
- else if(C->region->alignment==RGN_ALIGN_BOTTOM)
- C->region->alignment= RGN_ALIGN_TOP;
- else if(C->region->alignment==RGN_ALIGN_LEFT)
- C->region->alignment= RGN_ALIGN_RIGHT;
- else if(C->region->alignment==RGN_ALIGN_RIGHT)
- C->region->alignment= RGN_ALIGN_LEFT;
+ ARegion *ar= CTX_wm_region(C);
+
+ if(ar->alignment==RGN_ALIGN_TOP)
+ ar->alignment= RGN_ALIGN_BOTTOM;
+ else if(ar->alignment==RGN_ALIGN_BOTTOM)
+ ar->alignment= RGN_ALIGN_TOP;
+ else if(ar->alignment==RGN_ALIGN_LEFT)
+ ar->alignment= RGN_ALIGN_RIGHT;
+ else if(ar->alignment==RGN_ALIGN_RIGHT)
+ ar->alignment= RGN_ALIGN_LEFT;
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void action_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void action_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceAction *saction= C->area->spacedata.first;
+ // SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
#include "DNA_windowmanager_types.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void buttons_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
- SpaceButs *sbuts= sa->spacedata.first;
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
uiBlockEndAlign(block);
xco+=XIC;
- uiDefButI(block, NUM, B_NEWFRAME, "", (xco+20),yco,60,YIC, &(C->scene->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change.");
+ uiDefButI(block, NUM, B_NEWFRAME, "", (xco+20),yco,60,YIC, &(CTX_data_scene(C)->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change.");
xco+= 80;
// XXX buttons_active_id(&id, &idfrom);
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void buttons_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceButs *sbuts= C->area->spacedata.first;
+ // SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3], fac;
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void file_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_storage_types.h"
#include "BLI_dynstr.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void file_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceFile *sfile= C->area->spacedata.first;
+ // SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void image_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void image_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceImage *simage= C->area->spacedata.first;
+ // SpaceImage *simage= (SpaceImage*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void info_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("File");
- uiDefPulldownBut(block, dummy_viewmenu, C->area, "File", xco, yco, xmax-3, 22, "");
+ uiDefPulldownBut(block, dummy_viewmenu, sa, "File", xco, yco, xmax-3, 22, "");
xco+= xmax;
xmax= GetButStringLength("Add");
- uiDefPulldownBut(block, dummy_viewmenu, C->area, "Add", xco, yco, xmax-3, 22, "");
+ uiDefPulldownBut(block, dummy_viewmenu, sa, "Add", xco, yco, xmax-3, 22, "");
xco+= xmax;
xmax= GetButStringLength("Timeline");
- uiDefPulldownBut(block, dummy_viewmenu, C->area, "Timeline", xco, yco, xmax-3, 22, "");
+ uiDefPulldownBut(block, dummy_viewmenu, sa, "Timeline", xco, yco, xmax-3, 22, "");
xco+= xmax;
xmax= GetButStringLength("Game");
- uiDefPulldownBut(block, dummy_viewmenu, C->area, "Game", xco, yco, xmax-3, 22, "");
+ uiDefPulldownBut(block, dummy_viewmenu, sa, "Game", xco, yco, xmax-3, 22, "");
xco+= xmax;
xmax= GetButStringLength("Render");
- uiDefPulldownBut(block, dummy_viewmenu, C->area, "Render", xco, yco, xmax-3, 22, "");
+ uiDefPulldownBut(block, dummy_viewmenu, sa, "Render", xco, yco, xmax-3, 22, "");
xco+= xmax;
xmax= GetButStringLength("Help");
#include "BLI_arithb.h"
#include "BLI_rand.h"
+#include "BKE_context.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void info_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceInfo *sinfo= C->area->spacedata.first;
+ // SpaceInfo *sinfo= (SpaceInfo*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void ipo_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
}
#include "BLI_arithb.h"
#include "BLI_rand.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
// XXX this should be defined in some general lib for anim editors...
static void draw_cfra(const bContext *C, SpaceIpo *sipo, View2D *v2d)
{
- Scene *scene= C->scene;
+ Scene *scene= CTX_data_scene(C);
float vec[2];
//vec[0] = get_ipo_cfra_from_cfra(sipo, scene->r.cfra);
#if 0
if(sipo->blocktype==ID_OB) {
- ob= (G.scene->basact) ? (G.scene->basact->object) : 0;
+ ob= (scene->basact) ? (scene->basact->object) : 0;
if (ob && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) {
vec[0]-= give_timeoffset(ob);
static void ipo_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- SpaceIpo *sipo= C->area->spacedata.first;
+ SpaceIpo *sipo= (SpaceIpo*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void nla_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void nla_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceNla *snla= C->area->spacedata.first;
+ // SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void node_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void node_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceNode *snode= C->area->spacedata.first;
+ // SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
//View2DGrid *grid;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void outliner_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
- SpaceOops *soutliner= sa->spacedata.first;
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
uiBlock *block;
int xco, yco= 3;
char *path;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco += xmax;
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
void UI_table_draw(const bContext *C, uiTable *table)
{
+ ARegion *ar= CTX_wm_region(C);
uiBlock *block;
View2D *v2d;
rcti *rct, cellrct;
int y, row, col;
- v2d= &C->region->v2d;
+ v2d= &ar->v2d;
rct= &table->rct;
- block= uiBeginBlock(C, C->region, "table outliner", UI_EMBOSST, UI_HELV);
+ block= uiBeginBlock(C, ar, "table outliner", UI_EMBOSST, UI_HELV);
for(y=rct->ymax, row=0; y>rct->ymin; y-=ROW_HEIGHT, row++) {
if(row%2 == 0) {
static void rna_back_cb(bContext *C, void *arg_unused, void *arg_unused2)
{
- SpaceOops *soutliner= C->area->spacedata.first;
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
char *newpath;
newpath= RNA_path_back(soutliner->rnapath);
static void rna_pointer_cb(bContext *C, void *arg_prop, void *arg_index)
{
- SpaceOops *soutliner= C->area->spacedata.first;
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
PropertyRNA *prop= arg_prop;
char *newpath;
int index= GET_INT_FROM_POINTER(arg_index);;
PointerRNA newptr;
float col[3];
int rows, cols, awidth, aheight, width, height;
- SpaceOops *soutliner= C->area->spacedata.first;
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
View2DScrollers *scrollers;
/* create table */
cell.space= soutliner;
cell.lastrow= -1;
- RNA_main_pointer_create(G.main, &cell.ptr);
+ RNA_main_pointer_create(CTX_data_main(C), &cell.ptr);
cell.prop= NULL;
/* solve RNA path or reset if fails */
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void script_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void script_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceScript *sscript= C->area->spacedata.first;
+ // SpaceScript *sscript= (SpaceScript*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void sequencer_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceSeq *sseq= C->area->spacedata.first;
+ // SpaceSeq *sseq= (SpaceSeq*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void sound_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void sound_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceSound *ssound= C->area->spacedata.first;
+ // SpaceSound *ssound= (SpaceSound*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_rand.h"
#include "BKE_colortools.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_space_api.h"
static void text_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- // SpaceText *stext= C->area->spacedata.first;
+ // SpaceText *stext= (SpaceText*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void text_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
xco+=XIC+xmax;
}
#include "BLI_blenlib.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
/* draws a current frame indicator for the TimeLine */
static void time_draw_cfra_time(const bContext *C, SpaceTime *stime, ARegion *ar)
{
- Scene *scene= C->scene;
+ Scene *scene= CTX_data_scene(C);
float vec[2];
vec[0]= scene->r.cfra*scene->r.framelen;
static void time_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- SpaceTime *stime= C->area->spacedata.first;
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
#include "BLI_blenlib.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
static void do_time_redrawmenu(bContext *C, void *arg, int event)
{
- SpaceTime *stime= C->area->spacedata.first;
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
if(event < 1001) {
}
else {
if(event==1001) {
-// button(&C->scene->r.frs_sec,1,120,"FPS:");
+// button(&CTX_data_scene(C)->r.frs_sec,1,120,"FPS:");
}
}
}
static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
- SpaceTime *stime= curarea->spacedata.first;
+ ScrArea *curarea= CTX_wm_area(C);
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
uiBlock *block;
short yco= 0, menuwidth=120, icon;
char str[32];
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- sprintf(str, "Set Frames/Sec (%d/%f)", C->scene->r.frs_sec, C->scene->r.frs_sec_base);
+ sprintf(str, "Set Frames/Sec (%d/%f)", scene->r.frs_sec, scene->r.frs_sec_base);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1001, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
static void do_time_viewmenu(bContext *C, void *arg, int event)
{
- ScrArea *curarea= C->area;
- SpaceTime *stime= curarea->spacedata.first;
+ ScrArea *curarea= CTX_wm_area(C);
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
View2D *v2d= UI_view2d_fromcontext_rwin(C);
+ Scene *scene= CTX_data_scene(C);
int first;
switch(event) {
break;
case 3: /* View All */
if(v2d) {
- first= C->scene->r.sfra;
- if(first >= C->scene->r.efra) first= C->scene->r.efra;
+ first= scene->r.sfra;
+ if(first >= scene->r.efra) first= scene->r.efra;
v2d->cur.xmin=v2d->tot.xmin= (float)first-2;
- v2d->cur.xmax=v2d->tot.xmax= (float)C->scene->r.efra+2;
+ v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2;
- ED_area_tag_redraw(C->area);
+ ED_area_tag_redraw(curarea);
}
break;
case 4: /* Maximize Window */
break;
case 5: /* show time or frames */
stime->flag ^= TIME_DRAWFRAMES;
- ED_area_tag_redraw(C->area);
+ ED_area_tag_redraw(curarea);
break;
case 6:
//nextprev_marker(1);
case 11:
if(v2d) {
v2d->flag ^= V2D_VIEWSYNC_X;
- UI_view2d_sync(C->screen, v2d, V2D_LOCK_SET);
+ UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_SET);
}
break;
case 12: /* only show keyframes from selected data */
stime->flag ^= TIME_ONLYACTSEL;
- ED_area_tag_redraw(C->area);
+ ED_area_tag_redraw(curarea);
break;
}
}
static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
- SpaceTime *stime= curarea->spacedata.first;
+ ScrArea *curarea= CTX_wm_area(C);
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
View2D *v2d= UI_view2d_fromcontext_rwin(C);
uiBlock *block;
short yco= 0, menuwidth=120;
static void do_time_framemenu(bContext *C, void *arg, int event)
{
+ Scene *scene= CTX_data_scene(C);
+
switch(event) {
case 1: /*Set as Start */
- if (C->scene->r.psfra) {
- if (C->scene->r.pefra < CFRA)
- C->scene->r.pefra= CFRA;
- C->scene->r.psfra= CFRA;
+ if (scene->r.psfra) {
+ if (scene->r.pefra < scene->r.cfra)
+ scene->r.pefra= scene->r.cfra;
+ scene->r.psfra= scene->r.cfra;
}
else
- C->scene->r.sfra = CFRA;
+ scene->r.sfra = scene->r.cfra;
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
break;
case 2: /* Set as End */
- if (C->scene->r.psfra) {
- if (CFRA < C->scene->r.psfra)
- C->scene->r.psfra= CFRA;
- C->scene->r.pefra= CFRA;
+ if (scene->r.psfra) {
+ if (scene->r.cfra < scene->r.psfra)
+ scene->r.psfra= scene->r.cfra;
+ scene->r.pefra= scene->r.cfra;
}
else
- C->scene->r.efra = CFRA;
+ scene->r.efra = scene->r.cfra;
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
break;
case 3: /* Rename Marker */
static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void do_time_buttons(bContext *C, void *arg, int event)
{
- SpaceTime *stime= C->area->spacedata.first;
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
switch(event) {
case B_REDRAWALL:
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
break;
case B_TL_REW:
- CFRA= PSFRA;
+ scene->r.cfra= PSFRA;
//update_for_newframe();
break;
case B_TL_PLAY:
break;
case B_TL_FF:
/* end frame */
- CFRA= PEFRA;
+ scene->r.cfra= PEFRA;
//update_for_newframe();
break;
case B_TL_PREVKEY:
break;
case B_TL_PREVIEWON:
- if (C->scene->r.psfra) {
+ if (scene->r.psfra) {
/* turn on preview range */
- C->scene->r.psfra= C->scene->r.sfra;
- C->scene->r.pefra= C->scene->r.efra;
+ scene->r.psfra= scene->r.sfra;
+ scene->r.pefra= scene->r.efra;
}
else {
/* turn off preview range */
- C->scene->r.psfra= 0;
- C->scene->r.pefra= 0;
+ scene->r.psfra= 0;
+ scene->r.pefra= 0;
}
//BIF_undo_push("Set anim-preview range");
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
void time_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
- SpaceTime *stime= sa->spacedata.first;
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, time_viewmenu, C->area,
+ uiDefPulldownBut(block, time_viewmenu, sa,
"View", xco, yco-2, xmax-3, 24, "");
xco+= xmax;
xmax= GetButStringLength("Frame");
- uiDefPulldownBut(block, time_framemenu, C->area,
+ uiDefPulldownBut(block, time_framemenu, sa,
"Frame", xco, yco-2, xmax-3, 24, "");
xco+= xmax;
xmax= GetButStringLength("Playback");
- uiDefPulldownBut(block, time_redrawmenu, C->area,
+ uiDefPulldownBut(block, time_redrawmenu, sa,
"Playback", xco, yco-2, xmax-3, 24, "");
xco+= xmax;
}
uiDefButI(block, TOG, B_TL_PREVIEWON,"Preview",
xco,yco, XIC, YIC,
- &C->scene->r.psfra,0, 1, 0, 0,
+ &scene->r.psfra,0, 1, 0, 0,
"Show settings for frame range of animation preview");
xco += XIC;
- if (C->scene->r.psfra) {
+ if (scene->r.psfra) {
uiDefButI(block, NUM, B_REDRAWALL,"Start:",
xco,yco, 4.5*XIC, YIC,
- &C->scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0,
+ &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0,
"The start frame of the animation preview (inclusive)");
xco += (short)(4.5*XIC);
uiDefButI(block, NUM, B_REDRAWALL,"End:",
xco,yco,4.5*XIC,YIC,
- &C->scene->r.pefra,PSFRA,MAXFRAMEF, 0, 0,
+ &scene->r.pefra,PSFRA,MAXFRAMEF, 0, 0,
"The end frame of the animation preview (inclusive)");
}
else {
uiDefButI(block, NUM, B_REDRAWALL,"Start:",
xco,yco, 4.5*XIC, YIC,
- &C->scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
+ &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
"The start frame of the animation (inclusive)");
xco += (short)(4.5*XIC);
uiDefButI(block, NUM, B_REDRAWALL,"End:",
xco,yco,4.5*XIC,YIC,
- &C->scene->r.efra,(float)SFRA,MAXFRAMEF, 0, 0,
+ &scene->r.efra,(float)SFRA,MAXFRAMEF, 0, 0,
"The end frame of the animation (inclusive)");
}
uiBlockEndAlign(block);
uiDefButI(block, NUM, B_NEWFRAME, "",
xco,yco,3.5*XIC,YIC,
- &(C->scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0,
+ &(scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0,
"Displays Current Frame of animation");
xco += (short)(3.5 * XIC + 16);
xco+= XIC+8;
uiDefIconButBitS(block, TOG, AUTOKEY_ON, REDRAWINFO, ICON_REC,
- xco, yco, XIC, YIC, &(C->scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
+ xco, yco, XIC, YIC, &(scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
xco+= XIC;
- if (C->scene->autokey_mode & AUTOKEY_ON) {
+ if (scene->autokey_mode & AUTOKEY_ON) {
uiDefButS(block, MENU, REDRAWINFO,
"Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5",
- xco, yco, 3.5*XIC, YIC, &(C->scene->autokey_mode), 0, 1, 0, 0,
+ xco, yco, 3.5*XIC, YIC, &(scene->autokey_mode), 0, 1, 0, 0,
"Mode of automatic keyframe insertion for Objects and Bones");
xco+= (4*XIC);
}
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_utildefines.h"
#include "UI_interface.h"
static int change_frame_init(bContext *C, wmOperator *op)
{
- SpaceTime *stime= C->area->spacedata.first;
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
stime->flag |= TIME_CFRA_NUM;
static void change_frame_apply(bContext *C, wmOperator *op)
{
+ Scene *scene= CTX_data_scene(C);
int cfra;
cfra= RNA_int_get(op->ptr, "frame");
else PIL_sleep_ms(30);
#endif
- if(cfra!=CFRA)
- CFRA= cfra;
+ if(cfra!=scene->r.cfra)
+ scene->r.cfra= cfra;
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
static void change_frame_exit(bContext *C, wmOperator *op)
{
- SpaceTime *stime= C->area->spacedata.first;
+ SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
stime->flag &= ~TIME_CFRA_NUM;
}
static int frame_from_event(bContext *C, wmEvent *event)
{
- ARegion *region= C->region;
+ ARegion *region= CTX_wm_region(C);
int x, y;
float viewx;
change_frame_apply(C, op);
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
{
SpaceTime *stime;
- if (ELEM(NULL, C->area, C->area->spacedata.first))
+ if (ELEM(NULL, CTX_wm_area(C), CTX_wm_space_data(C)))
return OPERATOR_CANCELLED;
/* simply toggle draw frames flag for now */
// XXX in past, this displayed menu to choose... (for later!)
- stime= C->area->spacedata.first;
+ stime= (SpaceTime*)CTX_wm_space_data(C);
stime->flag ^= TIME_DRAWFRAMES;
return OPERATOR_FINISHED;
#include "BLI_arithb.h"
#include "BLI_rand.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- ScrArea *curarea= C->area;
+ ScrArea *curarea= CTX_wm_area(C);
uiBlock *block;
short yco= 0, menuwidth=120;
void view3d_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= C->area;
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
int xco, yco= 3;
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, C->area,
+ uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
"View", xco, yco-2, xmax-3, 24, "");
}
#include "BLI_blenlib.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
else
#endif
- return &C->scene->markers;
+ return &CTX_data_scene(C)->markers;
}
/* ************* Marker Drawing ************ */
/* unselected markers are drawn at the first time */
for (marker= markers->first; marker; marker= marker->next) {
- if (!(marker->flag & SELECT)) draw_marker(v2d, marker, C->scene->r.cfra, flag);
+ if (!(marker->flag & SELECT)) draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag);
}
/* selected markers are drawn later */
for (marker= markers->first; marker; marker= marker->next) {
- if (marker->flag & SELECT) draw_marker(v2d, marker, C->scene->r.cfra, flag);
+ if (marker->flag & SELECT) draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag);
}
}
{
ListBase *markers= context_get_markers(C);
TimeMarker *marker;
- int frame= C->scene->r.cfra;
+ int frame= CTX_data_scene(C)->r.cfra;
/* two markers can't be at the same place */
for(marker= markers->first; marker; marker= marker->next)
if (totmark==0) return 0;
op->customdata= mm= MEM_callocN(sizeof(MarkerMove), "Markermove");
- mm->slink= C->area->spacedata.first;
+ mm->slink= CTX_wm_space_data(C);
mm->markers= markers;
mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe");
mm->event_type= evt->type;
/* add temp handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
/* reset frs delta */
RNA_int_set(op->ptr, "frs", 0);
/* ************************** selection ************************************/
/* select/deselect TimeMarker at current frame */
-static void select_timeline_marker_frame(int frame, unsigned char shift)
+static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift)
{
TimeMarker *marker;
int select=0;
- for(marker= G.scene->markers.first; marker; marker= marker->next) {
+ for(marker= markers->first; marker; marker= marker->next) {
/* if Shift is not set, then deselect Markers */
if(!shift) marker->flag &= ~SELECT;
/* this way a not-shift select will allways give 1 selected marker */
float viewx;
int x, y, cfra;
- x= evt->x - C->region->winrct.xmin;
- y= evt->y - C->region->winrct.ymin;
+ x= evt->x - CTX_wm_region(C)->winrct.xmin;
+ y= evt->y - CTX_wm_region(C)->winrct.ymin;
UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
cfra= find_nearest_marker_time(markers, viewx);
if (extend)
- select_timeline_marker_frame(cfra, 1);
+ select_timeline_marker_frame(markers, cfra, 1);
else
- select_timeline_marker_frame(cfra, 0);
+ select_timeline_marker_frame(markers, cfra, 0);
WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int type);
void WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
- /* Reporting information and errors */
-void WM_report(struct bContext *C, int type, const char *message);
-void WM_reportf(struct bContext *C, int type, const char *format, ...);
-
/* OpenGL wrappers, mimicing opengl syntax */
void wmLoadMatrix (wmWindow *win, float mat[][4]);
void wmGetMatrix (wmWindow *win, float mat[][4]);
#include "BLI_blenlib.h"
#include "BKE_blender.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_idprop.h"
void wm_check(bContext *C)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
/* wm context */
- if(C->wm==NULL) C->wm= G.main->wm.first;
- if(C->wm==NULL) return;
- if(C->wm->windows.first==NULL) return;
+ if(CTX_wm_manager(C)==NULL) {
+ wm= CTX_data_main(C)->wm.first;
+ CTX_wm_manager_set(C, wm);
+ }
+ if(wm==NULL) return;
+ if(wm->windows.first==NULL) return;
/* case: no open windows at all, for old file reads */
- wm_window_add_ghostwindows(C->wm);
+ wm_window_add_ghostwindows(wm);
/* case: fileread */
- if(C->wm->initialized==0) {
+ if(wm->initialized==0) {
- wm_window_keymap(C->wm);
- ED_spacetypes_keymap(C->wm);
+ wm_window_keymap(wm);
+ ED_spacetypes_keymap(wm);
- ED_screens_initialize(C->wm);
- C->wm->initialized= 1;
+ ED_screens_initialize(wm);
+ wm->initialized= 1;
}
}
/* on startup, it adds all data, for matching */
void wm_add_default(bContext *C)
{
- wmWindowManager *wm= alloc_libblock(&G.main->wm, ID_WM, "WinMan");
+ wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
wmWindow *win;
- C->wm= wm;
+ CTX_wm_manager_set(C, wm);
win= wm_window_new(C);
- win->screen= C->screen;
+ win->screen= CTX_wm_screen(C); /* XXX from window? */
wm->winactive= win;
wm_window_make_drawable(C, win);
}
{
wmWindow *win;
wmOperator *op;
- wmReport *report;
wmKeyMap *km;
wmKeymapItem *kmi;
wm_operator_free(op);
}
- while((report= wm->reports.first)) {
- BLI_remlink(&wm->reports, report);
- wm_report_free(report);
- }
-
while((km= wm->keymaps.first)) {
for(kmi=km->keymap.first; kmi; kmi=kmi->next) {
if(kmi->ptr)
BLI_freelistN(&wm->queue);
- if(C && C->wm==wm) C->wm= NULL;
+ if(C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL);
}
void wm_close_and_free_all(bContext *C, ListBase *wmlist)
#include "DNA_listBase.h"
#include "DNA_userdef_types.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "WM_api.h"
#include "wm_cursors.h"
#include "BLI_blenlib.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
{
wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
- BLI_addtail(&C->wm->queue, note);
+ BLI_addtail(&CTX_wm_manager(C)->queue, note);
- note->window= C->window;
- if(C->region)
- note->swinid= C->region->swinid;
+ note->window= CTX_wm_window(C);
+ if(CTX_wm_region(C))
+ note->swinid= CTX_wm_region(C)->swinid;
note->type= type;
note->value= value;
note->data= data;
/* called in mainloop */
void wm_event_do_notifiers(bContext *C)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
wmNotifier *note;
- while( (note=wm_notifier_next(C->wm)) ) {
+ while( (note=wm_notifier_next(wm)) ) {
wmWindow *win;
- for(win= C->wm->windows.first; win; win= win->next) {
+ for(win= wm->windows.first; win; win= win->next) {
ScrArea *sa;
ARegion *ar;
- C->window= win;
- C->screen= win->screen; /* XXX context in notifiers? */
+ /* XXX context in notifiers? */
+ CTX_wm_window_set(C, win);
/* printf("notifier win %d screen %s\n", win->winid, win->screen->id.name+2); */
ED_screen_do_listen(win, note);
}
}
- C->window= NULL;
- C->screen= NULL;
+ CTX_wm_window_set(C, NULL);
}
MEM_freeN(note);
static void wm_flush_draw_update(bContext *C)
{
ARegion *ar;
+ bScreen *screen= CTX_wm_screen(C);
/* flush redraws of screen regions (menus) down */
- for(ar= C->screen->regionbase.first; ar; ar= ar->next) {
+ for(ar= screen->regionbase.first; ar; ar= ar->next) {
if(ar->swinid && ar->do_draw) {
- wm_flush_regions(C->screen, &ar->winrct);
+ wm_flush_regions(screen, &ar->winrct);
}
}
void wm_draw_update(bContext *C)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win;
- for(win= C->wm->windows.first; win; win= win->next) {
+ for(win= wm->windows.first; win; win= win->next) {
if(wm_draw_update_test_window(win)) {
ScrArea *sa;
ARegion *ar;
- C->window= win;
- C->screen= win->screen;
+ CTX_wm_window_set(C, win);
/* sets context window+screen */
wm_window_make_drawable(C, win);
/* notifiers for screen redraw */
if(win->screen->do_refresh)
- ED_screen_refresh(C->wm, win);
+ ED_screen_refresh(wm, win);
/* flush draw updates for multiple layers */
wm_flush_draw_update(C);
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
- C->area= sa;
+ CTX_wm_area_set(C, sa);
for(ar=sa->regionbase.first; ar; ar= ar->next) {
- C->region= ar;
+ CTX_wm_region_set(C, ar);
if(ar->swinid && ar->do_draw)
ED_region_do_draw(C, ar);
- C->region= NULL;
+ CTX_wm_region_set(C, NULL);
}
- C->area = NULL;
+ CTX_wm_area_set(C, NULL);
}
/* move this here so we can do area 'overlay' drawing */
/* regions are menus here */
for(ar=win->screen->regionbase.first; ar; ar= ar->next) {
- C->region= ar;
+ CTX_wm_region_set(C, ar);
if(ar->swinid && ar->do_draw)
ED_region_do_draw(C, ar);
- C->region= NULL;
+ CTX_wm_region_set(C, NULL);
}
if(win->screen->do_gesture)
wm_window_swap_buffers(win);
- C->window= NULL;
- C->screen= NULL;
+ CTX_wm_window_set(C, NULL);
}
}
}
static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, IDProperty *properties)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
int retval= OPERATOR_PASS_THROUGH;
if(ot->poll==NULL || ot->poll(C)) {
BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME);
op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
- RNA_pointer_create(&RNA_WindowManager, &C->wm->id, ot->srna, &op->properties, op->ptr);
+ RNA_pointer_create(&RNA_WindowManager, &wm->id, ot->srna, &op->properties, op->ptr);
if(op->type->invoke)
retval= (*op->type->invoke)(C, op, event);
retval= op->type->exec(C, op);
if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
- wm_operator_register(C->wm, op);
+ wm_operator_register(wm, op);
}
else if(!(retval & OPERATOR_RUNNING_MODAL)) {
wm_operator_free(op);
int WM_operator_call(bContext *C, const char *opstring, int context, IDProperty *properties)
{
wmOperatorType *ot= WM_operatortype_find(opstring);
+ wmWindow *window= CTX_wm_window(C);
int retval;
/* dummie test */
- if(ot && C && C->window) {
+ if(ot && C && window) {
if(context == WM_OP_REGION_WIN) {
/* forces event to go to the region window, for header menus */
- ARegion *ar= C->region;
+ ARegion *ar= CTX_wm_region(C);
+ ScrArea *area= CTX_wm_area(C);
- if(C->area) {
- ARegion *ar1= C->area->regionbase.first;
+ if(area) {
+ ARegion *ar1= area->regionbase.first;
for(; ar1; ar1= ar1->next)
if(ar1->regiontype==RGN_TYPE_WINDOW)
break;
if(ar1)
- C->region= ar1;
+ CTX_wm_region_set(C, ar1);
}
- retval= wm_operator_invoke(C, ot, C->window->eventstate, properties);
+ retval= wm_operator_invoke(C, ot, window->eventstate, properties);
/* set region back */
- C->region= ar;
+ CTX_wm_region_set(C, ar);
return retval;
}
else if(context == WM_OP_AREA) {
/* remove region from context */
- ARegion *ar= C->region;
+ ARegion *ar= CTX_wm_region(C);
- C->region= NULL;
- retval= wm_operator_invoke(C, ot, C->window->eventstate, properties);
- C->region= ar;
+ CTX_wm_region_set(C, NULL);
+ retval= wm_operator_invoke(C, ot, window->eventstate, properties);
+ CTX_wm_region_set(C, ar);
return retval;
}
else if(context == WM_OP_SCREEN) {
/* remove region + area from context */
- ARegion *ar= C->region;
- ScrArea *area= C->area;
+ ARegion *ar= CTX_wm_region(C);
+ ScrArea *area= CTX_wm_area(C);
- C->region= NULL;
- C->area= NULL;
- retval= wm_operator_invoke(C, ot, C->window->eventstate, properties);
- C->region= ar;
- C->area= area;
+ CTX_wm_region_set(C, NULL);
+ CTX_wm_area_set(C, NULL);
+ retval= wm_operator_invoke(C, ot, window->eventstate, properties);
+ CTX_wm_region_set(C, ar);
+ CTX_wm_area_set(C, area);
return retval;
}
else
- return wm_operator_invoke(C, ot, C->window->eventstate, properties);
+ return wm_operator_invoke(C, ot, window->eventstate, properties);
}
return 0;
if(handler->op) {
if(handler->op->type->cancel) {
- ScrArea *area= C->area;
- ARegion *region= C->region;
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
- C->area= handler->op_area;
- C->region= handler->op_region;
+ CTX_wm_area_set(C, handler->op_area);
+ CTX_wm_region_set(C, handler->op_region);
handler->op->type->cancel(C, handler->op);
- C->area= area;
- C->region= region;
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
}
wm_operator_free(handler->op);
}
else if(handler->ui_remove) {
- ScrArea *area= C->area;
- ARegion *region= C->region;
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
- if(handler->ui_area) C->area= handler->ui_area;
- if(handler->ui_region) C->region= handler->ui_region;
+ if(handler->ui_area) CTX_wm_area_set(C, handler->ui_area);
+ if(handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
handler->ui_remove(C, handler->ui_userdata);
- C->area= area;
- C->region= region;
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
}
wm_event_free_handler(handler);
if(ot->modal) {
/* we set context to where modal handler came from */
- ScrArea *area= C->area;
- ARegion *region= C->region;
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
- C->area= handler->op_area;
- C->region= handler->op_region;
+ CTX_wm_area_set(C, handler->op_area);
+ CTX_wm_region_set(C, handler->op_region);
retval= ot->modal(C, op, event);
/* putting back screen context */
- C->area= area;
- C->region= region;
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
- wm_operator_register(C->wm, op);
+ wm_operator_register(CTX_wm_manager(C), op);
handler->op= NULL;
}
else if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *event)
{
- ScrArea *area= C->area;
- ARegion *region= C->region;
+ ScrArea *area= CTX_wm_area(C);
+ ARegion *region= CTX_wm_region(C);
int retval;
/* we set context to where ui handler came from */
- if(handler->ui_area) C->area= handler->ui_area;
- if(handler->ui_region) C->region= handler->ui_region;
+ if(handler->ui_area) CTX_wm_area_set(C, handler->ui_area);
+ if(handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
retval= handler->ui_handle(C, event, handler->ui_userdata);
/* putting back screen context */
- C->area= area;
- C->region= region;
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
if(retval == WM_UI_HANDLER_BREAK)
return WM_HANDLER_BREAK;
for(kmi= handler->keymap->first; kmi; kmi= kmi->next) {
if(wm_eventmatch(event, kmi)) {
if((G.f & G_DEBUG) && event->type!=MOUSEMOVE)
- printf("handle evt %d win %d op %s\n", event->type, C->window->winid, kmi->idname);
+ printf("handle evt %d win %d op %s\n", event->type, CTX_wm_window(C)->winid, kmi->idname);
event->keymap_idname= kmi->idname; /* weak, but allows interactive callback to not use rawkey */
static ScrArea *area_event_inside(bContext *C, wmEvent *event)
{
+ bScreen *screen= CTX_wm_screen(C);
ScrArea *sa;
- if(C->screen)
- for(sa= C->screen->areabase.first; sa; sa= sa->next)
+ if(screen)
+ for(sa= screen->areabase.first; sa; sa= sa->next)
if(BLI_in_rcti(&sa->totrct, event->x, event->y))
return sa;
return NULL;
static ARegion *region_event_inside(bContext *C, wmEvent *event)
{
+ bScreen *screen= CTX_wm_screen(C);
+ ScrArea *area= CTX_wm_area(C);
ARegion *ar;
- if(C->screen && C->area)
- for(ar= C->area->regionbase.first; ar; ar= ar->next)
+ if(screen && area)
+ for(ar= area->regionbase.first; ar; ar= ar->next)
if(BLI_in_rcti(&ar->winrct, event->x, event->y))
return ar;
return NULL;
{
wmWindow *win;
- for(win= C->wm->windows.first; win; win= win->next) {
+ for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
wmEvent *event;
if( win->screen==NULL )
while( (event=wm_event_next(win)) ) {
int action;
- C->window= win;
- C->screen= win->screen;
- C->area= area_event_inside(C, event);
- C->region= region_event_inside(C, event);
+ CTX_wm_window_set(C, win);
+ CTX_wm_area_set(C, area_event_inside(C, event));
+ CTX_wm_region_set(C, region_event_inside(C, event));
/* MVC demands to not draw in event handlers... for now we leave it */
wm_window_make_drawable(C, win);
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
if(wm_event_always_pass(event) || wm_event_prev_inside_i(event, &sa->totrct)) {
doit= 1;
- C->area= sa;
+ CTX_wm_area_set(C, sa);
action= wm_handlers_do(C, event, &sa->handlers);
if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
for(ar=sa->regionbase.first; ar; ar= ar->next) {
if(wm_event_always_pass(event) || wm_event_inside_i(event, &ar->winrct) || wm_event_prev_inside_i(event, &ar->winrct)) {
- C->region= ar;
+ CTX_wm_region_set(C, ar);
action= wm_handlers_do(C, event, &ar->handlers);
- C->region= NULL;
+ CTX_wm_region_set(C, NULL);
if(!wm_event_always_pass(event)) {
if(action==WM_HANDLER_BREAK)
}
}
- C->area= NULL;
+ CTX_wm_area_set(C, NULL);
/* NOTE: do not escape on WM_HANDLER_BREAK, mousemove needs handled for previous area */
}
}
/* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad?
doing it on ghost queue gives errors when mousemoves go over area borders */
if(doit) {
- C->window->eventstate->prevx= event->x;
- C->window->eventstate->prevy= event->y;
+ CTX_wm_window(C)->eventstate->prevx= event->x;
+ CTX_wm_window(C)->eventstate->prevy= event->y;
}
}
wm_event_free(event);
- C->window= NULL;
- C->screen= NULL;
+ CTX_wm_window_set(C, NULL);
}
}
}
{
wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event modal handler");
handler->op= op;
- handler->op_area= C->area; /* means frozen screen context for modal handlers! */
- handler->op_region= C->region;
+ handler->op_area= CTX_wm_area(C); /* means frozen screen context for modal handlers! */
+ handler->op_region= CTX_wm_region(C);
BLI_addhead(handlers, handler);
handler->ui_handle= func;
handler->ui_remove= remove;
handler->ui_userdata= userdata;
- handler->ui_area= (C)? C->area: NULL;
- handler->ui_region= (C)? C->region: NULL;
+ handler->ui_area= (C)? CTX_wm_area(C): NULL;
+ handler->ui_region= (C)? CTX_wm_region(C): NULL;
BLI_addhead(handlers, handler);
void WM_event_add_mousemove(bContext *C)
{
- wmEvent event= *(C->window->eventstate);
+ wmWindow *window= CTX_wm_window(C);
+ wmEvent event= *(window->eventstate);
event.type= MOUSEMOVE;
event.prevx= event.x;
event.prevy= event.y;
- wm_event_add(C->window, &event);
+ wm_event_add(window, &event);
}
/* ********************* ghost stuff *************** */
#include "DNA_windowmanager_types.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
#include "BKE_exotic.h"
#include "BKE_font.h"
/* we take apart the used screens from non-active window */
for(win= wm->windows.first; win; win= win->next) {
BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
- if(win!=C->wm->winactive) {
+ if(win!=wm->winactive) {
BLI_remlink(&G.main->screen, win->screen);
//BLI_addtail(screenbase, win->screen);
}
win->screen= (bScreen *)find_id("SR", win->screenname);
if(win->screen==NULL)
- win->screen= ED_screen_duplicate(win, C->screen); /* active screen */
+ win->screen= ED_screen_duplicate(win, CTX_wm_screen(C)); /* active screen */
if(win->screen->winid==0)
win->screen->winid= win->winid;
}
/* send the OnSave event */
-// XXX if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript(&C->scene->id, SCRIPT_ONSAVE);
+// XXX if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript(&CTX_data_scene(C)->id, SCRIPT_ONSAVE);
for (li= G.main->library.first; li; li= li->id.next) {
if (BLI_streq(li->name, target)) {
#include "BLI_blenlib.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_utildefines.h"
#include "WM_api.h"
wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
{
wmGesture *gesture= MEM_callocN(sizeof(wmGesture), "new gesture");
+ wmWindow *window= CTX_wm_window(C);
+ bScreen *screen= CTX_wm_screen(C);
int sx, sy;
- BLI_addtail(&C->window->gesture, gesture);
+ BLI_addtail(&window->gesture, gesture);
gesture->type= type;
gesture->event_type= event->type;
- gesture->swinid= C->screen->subwinactive; /* means only in area-region context! */
+ gesture->swinid= screen->subwinactive; /* means only in area-region context! */
- wm_subwindow_getorigin(C->window, gesture->swinid, &sx, &sy);
+ wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
if( ELEM3(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK)) {
rcti *rect= MEM_callocN(sizeof(rcti), "gesture rect new");
void WM_gesture_end(bContext *C, wmGesture *gesture)
{
- BLI_remlink(&C->window->gesture, gesture);
+ BLI_remlink(&CTX_wm_window(C)->gesture, gesture);
MEM_freeN(gesture->customdata);
MEM_freeN(gesture);
}
#include "DNA_windowmanager_types.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
/* first wrap up running stuff, we assume only the active WM is running */
/* modal handlers are on window level freed, others too? */
- if(C && C->wm) {
- for(win= C->wm->windows.first; win; win= win->next) {
+ if(C && CTX_wm_manager(C)) {
+ for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
- C->window= win; /* needed by operator close callbacks */
+ CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers);
ED_screen_exit(C, win, win->screen);
}
RNA_exit();
- MEM_freeN(C);
+ CTX_free(C);
if(MEM_get_memory_blocks_in_use()!=0) {
printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use());
#include "BLI_blenlib.h"
#include "BKE_blender.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
/* find right handler list based on specified context */
if(opcontext == WM_OP_REGION_WIN) {
- if(C->area) {
- ARegion *ar= C->area->regionbase.first;
+ if(CTX_wm_area(C)) {
+ ARegion *ar= CTX_wm_area(C)->regionbase.first;
for(; ar; ar= ar->next)
if(ar->regiontype==RGN_TYPE_WINDOW)
break;
}
}
else if(opcontext == WM_OP_AREA) {
- if(C->area)
- handlers= &C->area->handlers;
+ if(CTX_wm_area(C))
+ handlers= &CTX_wm_area(C)->handlers;
}
else if(opcontext == WM_OP_SCREEN) {
- if(C->window)
- handlers= &C->window->handlers;
+ if(CTX_wm_window(C))
+ handlers= &CTX_wm_window(C)->handlers;
}
else {
- if(C->region)
- handlers= &C->region->handlers;
+ if(CTX_wm_region(C))
+ handlers= &CTX_wm_region(C)->handlers;
}
if(!handlers)
#include "BLI_blenlib.h"
#include "BKE_blender.h"
-#include "BKE_global.h"
+#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_main.h"
int WM_operator_winactive(bContext *C)
{
- if(C->window==NULL) return 0;
+ if(CTX_wm_window(C)==NULL) return 0;
return 1;
}
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
- ED_area_tag_redraw(C->area);
+ ED_area_tag_redraw(CTX_wm_area(C));
}
op->customdata= WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT);
/* add modal handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
switch(event->type) {
case MOUSEMOVE:
- wm_subwindow_getorigin(C->window, gesture->swinid, &sx, &sy);
+ wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy);
if(gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) {
rect->xmin= rect->xmax= event->x - sx;
op->customdata= WM_gesture_new(C, event, WM_GESTURE_TWEAK);
/* add modal handler */
- WM_event_add_modal_handler(C, &C->window->handlers, op);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
- ED_area_tag_redraw(C->area);
+ ED_area_tag_redraw(CTX_wm_area(C));
}
static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event)
{
+ wmWindow *window= CTX_wm_window(C);
wmGesture *gesture= op->customdata;
rcti *rect= gesture->customdata;
int sx, sy, val;
switch(event->type) {
case MOUSEMOVE:
- wm_subwindow_getorigin(C->window, gesture->swinid, &sx, &sy);
+ wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
rect->xmax= event->x - sx;
rect->ymax= event->y - sy;
if((val= wm_gesture_evaluate(C, gesture))) {
wmEvent event;
- event= *(C->window->eventstate);
+ event= *(window->eventstate);
if(gesture->event_type==LEFTMOUSE)
event.type= EVT_TWEAK_L;
else if(gesture->event_type==RIGHTMOUSE)
event.type= EVT_TWEAK_M;
event.val= val;
/* mouse coords! */
- wm_event_add(C->window, &event);
+ wm_event_add(window, &event);
tweak_gesture_end(C, op);
return OPERATOR_FINISHED;
+++ /dev/null
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_windowmanager_types.h"
-
-#include "BLI_blenlib.h"
-
-#include "BKE_global.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef _WIN32
-#ifndef vsnprintf
-#define vsnprintf _vsnprintf
-#endif
-#endif
-
-static int wmReportLevel= WM_LOG_INFO;
-static int wmReportPrint= 0;
-
-static const char *wm_report_type_str(int type)
-{
- switch(type) {
- case WM_LOG_DEBUG: return "Debug";
- case WM_LOG_INFO: return "Info";
- case WM_LOG_WARNING: return "Warning";
- case WM_ERROR_UNDEFINED: return "Error";
- case WM_ERROR_INVALID_INPUT: return "Invalid Input Error";
- case WM_ERROR_INVALID_CONTEXT: return "Invalid Context Error";
- case WM_ERROR_OUT_OF_MEMORY: return "Out Of Memory Error";
- default: return "Undefined Type";
- }
-}
-
-static void wm_print_report(wmReport *report)
-{
- printf("%s: %s\n", report->typestr, report->message);
- fflush(stdout); /* this ensures the message is printed before a crash */
-}
-
-void WM_report(bContext *C, int type, const char *message)
-{
- wmReport *report;
- int len;
-
- if(!C->wm) {
- fprintf(stderr, "WM_report: can't report without windowmanager.\n");
- return;
- }
- if(type < wmReportLevel)
- return;
-
- report= MEM_callocN(sizeof(wmReport), "wmReport");
- report->type= type;
- report->typestr= wm_report_type_str(type);
-
- len= strlen(message);
- report->message= MEM_callocN(sizeof(char)*(len+1), "wmReportMessage");
- memcpy(report->message, message, sizeof(char)*(len+1));
-
- if(wmReportPrint)
- wm_print_report(report);
-
- BLI_addtail(&C->wm->reports, report);
-}
-
-void WM_reportf(bContext *C, int type, const char *format, ...)
-{
- wmReport *report;
- va_list args;
- char *message;
- int len= 256, maxlen= 65536, retval;
-
- if(!C->wm) {
- fprintf(stderr, "WM_report: can't report without windowmanager.\n");
- return;
- }
- if(type < wmReportLevel)
- return;
-
- while(1) {
- message= MEM_callocN(sizeof(char)*len+1, "wmReportMessage");
-
- va_start(args, format);
- retval= vsnprintf(message, len, format, args);
- va_end(args);
-
- if(retval == -1) {
- /* -1 means not enough space, but on windows it may also mean
- * there is a formatting error, so we impose a maximum length */
- MEM_freeN(message);
- message= NULL;
-
- len *= 2;
- if(len > maxlen) {
- fprintf(stderr, "WM_report message too long or format error.\n");
- break;
- }
- }
- else if(retval > len) {
- /* in C99 the actual length required is returned */
- MEM_freeN(message);
- message= NULL;
-
- len= retval;
- }
- else
- break;
- }
-
- if(message) {
- report= MEM_callocN(sizeof(wmReport), "wmReport");
- report->type= type;
- report->typestr= wm_report_type_str(type);
- report->message= message;
-
- if(wmReportPrint)
- wm_print_report(report);
-
- BLI_addtail(&C->wm->reports, report);
- }
-}
-
-void wm_report_free(wmReport *report)
-{
- MEM_freeN(report->message);
- MEM_freeN(report);
-}
-
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BIF_gl.h"
#include "BLI_blenlib.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
{
/* update context */
if(C) {
- if(C->wm->windrawable==win)
- C->wm->windrawable= NULL;
- if(C->wm->winactive==win)
- C->wm->winactive= NULL;
- if(C->window==win)
- C->window= NULL;
- if(C->screen==win->screen)
- C->screen= NULL;
+ wmWindowManager *wm= CTX_wm_manager(C);
+
+ if(wm->windrawable==win)
+ wm->windrawable= NULL;
+ if(wm->winactive==win)
+ wm->winactive= NULL;
+ if(CTX_wm_window(C)==win)
+ CTX_wm_window_set(C, NULL);
}
if(win->eventstate) MEM_freeN(win->eventstate);
/* dont change context itself */
wmWindow *wm_window_new(bContext *C)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= MEM_callocN(sizeof(wmWindow), "window");
- BLI_addtail(&C->wm->windows, win);
- win->winid= find_free_winid(C->wm);
+ BLI_addtail(&wm->windows, win);
+ win->winid= find_free_winid(wm);
return win;
}
/* this is event from ghost */
static void wm_window_close(bContext *C, wmWindow *win)
{
- BLI_remlink(&C->wm->windows, win);
+ wmWindowManager *wm= CTX_wm_manager(C);
+ BLI_remlink(&wm->windows, win);
ED_screen_exit(C, win, win->screen);
wm_window_free(C, win);
- if(C->wm->windows.first==NULL)
+ if(wm->windows.first==NULL)
WM_exit(C);
}
/* area-rip calls this */
wmWindow *WM_window_open(bContext *C, rcti *rect)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= wm_window_new(C);
win->posx= rect->xmin;
win->sizex= rect->xmax - rect->xmin;
win->sizey= rect->ymax - rect->ymin;
- wm_window_add_ghostwindow(C->wm, "Blender", win);
+ wm_window_add_ghostwindow(wm, "Blender", win);
return win;
}
/* operator callback */
int wm_window_duplicate_op(bContext *C, wmOperator *op)
{
- wm_window_copy(C, C->window);
+ wm_window_copy(C, CTX_wm_window(C));
wm_check(C);
return OPERATOR_FINISHED;
/* fullscreen operator callback */
int wm_window_fullscreen_toggle_op(bContext *C, wmOperator *op)
{
- GHOST_TWindowState state = GHOST_GetWindowState(C->window->ghostwin);
+ wmWindow *window= CTX_wm_window(C);
+ GHOST_TWindowState state = GHOST_GetWindowState(window->ghostwin);
if(state!=GHOST_kWindowStateFullScreen)
- GHOST_SetWindowState(C->window->ghostwin, GHOST_kWindowStateFullScreen);
+ GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
else
- GHOST_SetWindowState(C->window->ghostwin, GHOST_kWindowStateNormal);
+ GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
return OPERATOR_FINISHED;
/* exit blender */
int wm_exit_blender_op(bContext *C, wmOperator *op)
{
- wmWindow *win= C->wm->windows.first;
+ wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindow *win= wm->windows.first;
+
while(win) {
wm_window_close(C, win);
win= win->next;
void wm_window_make_drawable(bContext *C, wmWindow *win)
{
- if (win != C->wm->windrawable && win->ghostwin) {
+ wmWindowManager *wm= CTX_wm_manager(C);
+
+ if (win != wm->windrawable && win->ghostwin) {
// win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */
- C->wm->windrawable= win;
+ wm->windrawable= win;
if(G.f & G_DEBUG) printf("set drawable %d\n", win->winid);
GHOST_ActivateWindowDrawingContext(win->ghostwin);
}
GHOST_TEventKeyData kdata;
int cx, cy, wx, wy;
- C->wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */
+ CTX_wm_manager(C)->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active= 1;
// window_handle(win, INPUTCHANGE, win->active);
#include "BKE_utildefines.h"
#include "BKE_blender.h"
+#include "BKE_context.h"
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_main.h"
int main(int argc, char **argv)
{
SYS_SystemHandle syshandle;
- bContext *C= MEM_callocN(sizeof(bContext), "creator.c context");
+ bContext *C= CTX_create();
int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/;
#if defined(WIN32) || defined (__linux__)