Blender V4.3
bpy_rna_context.cc File Reference
#include <Python.h>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "BKE_main.hh"
#include "BKE_screen.hh"
#include "BKE_workspace.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "bpy_rna_context.hh"
#include "../generic/python_compat.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.hh"

Go to the source code of this file.

Classes

struct  ContextStore
 
struct  BPyContextTempOverride
 

Functions

Private Utility Functions
static void bpy_rna_context_temp_set_screen_for_window (bContext *C, wmWindow *win, bScreen *screen)
 
static bool wm_check_screen_switch_supported (const bScreen *screen)
 
static bool wm_check_window_exists (const Main *bmain, const wmWindow *win)
 
static bool wm_check_screen_exists (const Main *bmain, const bScreen *screen)
 
static bool wm_check_area_exists (const wmWindow *win, const bScreen *screen, const ScrArea *area)
 
static bool wm_check_region_exists (const bScreen *screen, const ScrArea *area, const ARegion *region)
 
Context Temporary Override Method
static PyObject * bpy_context_temp_override_extract_known_args (const char *const *kwds_static, PyObject *kwds)
 
 PyDoc_STRVAR (bpy_context_temp_override_doc, ".. method:: temp_override(*, window=None, area=None, region=None, **keywords)\n" "\n" " Context manager to temporarily override members in the context.\n" "\n" " :arg window: Window override or None.\n" " :type window: :class:`bpy.types.Window`\n" " :arg screen: Screen override or None.\n" "\n" " .. note:: Switching to or away from full-screen areas & temporary screens " "isn't supported. Passing in these screens will raise an exception, " "actions that leave the context such screens won't restore the prior screen.\n" "\n" " .. note:: Changing the screen has wider implications " "than other arguments as it will also change the works-space " "and potentially the scene (when pinned).\n" "\n" " :type screen: :class:`bpy.types.Screen`\n" " :arg area: Area override or None.\n" " :type area: :class:`bpy.types.Area`\n" " :arg region: Region override or None.\n" " :type region: :class:`bpy.types.Region`\n" " :arg keywords: Additional keywords override context members.\n" " :return: The context manager .\n" " :rtype: ContextTempOverride\n")
 
static PyObject * bpy_context_temp_override (PyObject *self, PyObject *args, PyObject *kwds)
 

Temporary Context Override (Python Context Manager)

static PyMethodDef bpy_rna_context_temp_override__tp_methods []
 
static PyTypeObject BPyContextTempOverride_Type
 
static void bpy_rna_context_temp_override__tp_dealloc (BPyContextTempOverride *self)
 
static PyObject * bpy_rna_context_temp_override_enter (BPyContextTempOverride *self)
 
static PyObject * bpy_rna_context_temp_override_exit (BPyContextTempOverride *self, PyObject *)
 

Public Type Definition

PyMethodDef BPY_rna_context_temp_override_method_def
 
void bpy_rna_context_types_init ()
 

Detailed Description

This file adds some helper methods to the context, that cannot fit well in RNA itself.

Definition in file bpy_rna_context.cc.

Function Documentation

◆ bpy_context_temp_override()

◆ bpy_context_temp_override_extract_known_args()

static PyObject * bpy_context_temp_override_extract_known_args ( const char *const * kwds_static,
PyObject * kwds )
static

Definition at line 551 of file bpy_rna_context.cc.

References BLI_assert_unreachable.

Referenced by bpy_context_temp_override().

◆ bpy_rna_context_temp_override__tp_dealloc()

static void bpy_rna_context_temp_override__tp_dealloc ( BPyContextTempOverride * self)
static

Definition at line 154 of file bpy_rna_context.cc.

References self.

◆ bpy_rna_context_temp_override_enter()

◆ bpy_rna_context_temp_override_exit()

◆ bpy_rna_context_temp_set_screen_for_window()

◆ bpy_rna_context_types_init()

void bpy_rna_context_types_init ( void )

Definition at line 734 of file bpy_rna_context.cc.

References BLI_assert_unreachable, and BPyContextTempOverride_Type.

Referenced by BPY_rna_types_extend_capi().

◆ PyDoc_STRVAR()

PyDoc_STRVAR ( bpy_context_temp_override_doc ,
".. method:: temp_override(*, window=None, area=None, region=None, **keywords)\n" "\n" " Context manager to temporarily override members in the context.\n" "\n" " :arg window: Window override or None.\n" " :type window: :class:`bpy.types.Window`\n" " :arg screen: Screen override or None.\n" "\n" " .. note:: Switching to or away from full-screen areas & temporary screens " "isn't supported. Passing in these screens will raise an exception,
" "actions that leave the context such screens won 't restore the prior screen.\n" "\n" " .. note::Changing the screen has wider implications " "than other arguments as it will also change the works-space " "and potentially the scene(when pinned).\n" "\n" " :type screen::class:`bpy.types.Screen`\n" " :arg area:Area override or None.\n" " :type area::class:`bpy.types.Area`\n" " :arg region:Region override or None.\n" " :type region::class:`bpy.types.Region`\n" " :arg keywords:Additional keywords override context members.\n" " :return:The context manager .\n" " :rtype:ContextTempOverride\n"  )

◆ wm_check_area_exists()

static bool wm_check_area_exists ( const wmWindow * win,
const bScreen * screen,
const ScrArea * area )
static

◆ wm_check_region_exists()

static bool wm_check_region_exists ( const bScreen * screen,
const ScrArea * area,
const ARegion * region )
static

◆ wm_check_screen_exists()

static bool wm_check_screen_exists ( const Main * bmain,
const bScreen * screen )
static

◆ wm_check_screen_switch_supported()

static bool wm_check_screen_switch_supported ( const bScreen * screen)
static

Switching to or away from this screen is not supported.

Definition at line 56 of file bpy_rna_context.cc.

References BKE_screen_is_fullscreen_area().

Referenced by bpy_rna_context_temp_override_enter(), and bpy_rna_context_temp_override_exit().

◆ wm_check_window_exists()

static bool wm_check_window_exists ( const Main * bmain,
const wmWindow * win )
static

Variable Documentation

◆ bpy_rna_context_temp_override__tp_methods

PyMethodDef bpy_rna_context_temp_override__tp_methods[]
static
Initial value:
= {
{"__enter__", (PyCFunction)bpy_rna_context_temp_override_enter, METH_NOARGS},
{"__exit__", (PyCFunction)bpy_rna_context_temp_override_exit, METH_VARARGS},
{nullptr},
}
static PyObject * bpy_rna_context_temp_override_enter(BPyContextTempOverride *self)
static PyObject * bpy_rna_context_temp_override_exit(BPyContextTempOverride *self, PyObject *)

Definition at line 483 of file bpy_rna_context.cc.

◆ BPY_rna_context_temp_override_method_def

PyMethodDef BPY_rna_context_temp_override_method_def
Initial value:
= {
"temp_override",
METH_VARARGS | METH_KEYWORDS,
bpy_context_temp_override_doc,
}
static PyObject * bpy_context_temp_override(PyObject *self, PyObject *args, PyObject *kwds)

Definition at line 723 of file bpy_rna_context.cc.

Referenced by BPY_rna_types_extend_capi().

◆ BPyContextTempOverride_Type

PyTypeObject BPyContextTempOverride_Type
static

Definition at line 493 of file bpy_rna_context.cc.

Referenced by bpy_context_temp_override(), and bpy_rna_context_types_init().