Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_space.c
| Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "ED_buttons.h" | #include "ED_buttons.h" | ||||
| #include "ED_fileselect.h" | #include "ED_fileselect.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_transform.h" | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "ED_sequencer.h" | #include "ED_sequencer.h" | ||||
| #include "ED_clip.h" | #include "ED_clip.h" | ||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | ||||
| if (ar) { | if (ar) { | ||||
| bScreen *sc = (bScreen *)ptr->id.data; | bScreen *sc = (bScreen *)ptr->id.data; | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| UI_view2d_sync(sc, sa, v2d, V2D_LOCK_SET); | UI_view2d_sync(sc, sa, v2d, V2D_LOCK_SET); | ||||
| } | } | ||||
| } | } | ||||
| static void rna_SpaceView3D_transform_orientation_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) | static int rna_View3D_transform_orientation_get(PointerRNA *ptr) | ||||
| { | |||||
| const View3D *v3d = (View3D *)ptr->data; | |||||
| if (v3d->twmode == V3D_MANIP_CUSTOM) { | |||||
| int i = 0; | |||||
| for (TransformOrientation *orientation = v3d->custom_orientation; | |||||
| orientation->prev != NULL; | |||||
| orientation = orientation->prev, i++) | |||||
| { | |||||
| /* pass - just counting */ | |||||
| } | |||||
| return v3d->twmode + i; | |||||
| } | |||||
| return v3d->twmode; | |||||
| } | |||||
| void rna_View3D_transform_orientation_set(PointerRNA *ptr, int value) | |||||
| { | { | ||||
| View3D *v3d = (View3D *)ptr->data; | View3D *v3d = (View3D *)ptr->data; | ||||
| bScreen *screen = ptr->id.data; | |||||
| WorkSpace *workspace; | |||||
| v3d->custom_orientation = (v3d->twmode < V3D_MANIP_CUSTOM) ? | BKE_workspace_layout_find_global(G.main, screen, &workspace); | ||||
| NULL : BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM); | BIF_selectTransformOrientationValue(workspace, v3d, value); | ||||
| } | } | ||||
| static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) | static PointerRNA rna_View3D_current_orientation_get(PointerRNA *ptr) | ||||
| { | { | ||||
| Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data); | |||||
| View3D *v3d = (View3D *)ptr->data; | View3D *v3d = (View3D *)ptr->data; | ||||
| if (v3d->twmode < V3D_MANIP_CUSTOM) | BLI_assert((v3d->twmode >= V3D_MANIP_CUSTOM) || (v3d->custom_orientation == NULL)); | ||||
| return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, NULL); | return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, v3d->custom_orientation); | ||||
| else | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, | |||||
| BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM)); | |||||
| } | } | ||||
| EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) | EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) | ||||
| { | { | ||||
| Scene *scene = NULL; | WorkSpace *workspace; | ||||
| ListBase *transform_spaces; | ListBase *transform_orientations; | ||||
| TransformOrientation *ts = NULL; | |||||
| EnumPropertyItem tmp = {0, "", 0, "", ""}; | EnumPropertyItem tmp = {0, "", 0, "", ""}; | ||||
| EnumPropertyItem *item = NULL; | EnumPropertyItem *item = NULL; | ||||
| int i = V3D_MANIP_CUSTOM, totitem = 0; | int i = V3D_MANIP_CUSTOM, totitem = 0; | ||||
| RNA_enum_items_add(&item, &totitem, transform_orientation_items); | RNA_enum_items_add(&item, &totitem, transform_orientation_items); | ||||
| if (ptr->type == &RNA_SpaceView3D) | if (ptr->type == &RNA_SpaceView3D) { | ||||
| scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data); | bScreen *screen = ptr->id.data; | ||||
| else | BKE_workspace_layout_find_global(G.main, screen, &workspace); | ||||
| scene = CTX_data_scene(C); /* can't use scene from ptr->id.data because that enum is also used by operators */ | } | ||||
| else { | |||||
| if (scene) { | /* can't use scene from ptr->id.data because that enum is also used by operators */ | ||||
| transform_spaces = &scene->transform_spaces; | workspace = CTX_wm_workspace(C); | ||||
| ts = transform_spaces->first; | |||||
| } | } | ||||
| if (ts) { | transform_orientations = BKE_workspace_transform_orientations_get(workspace); | ||||
| if (BLI_listbase_is_empty(transform_orientations) == false) { | |||||
| RNA_enum_item_add_separator(&item, &totitem); | RNA_enum_item_add_separator(&item, &totitem); | ||||
| for (; ts; ts = ts->next) { | for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { | ||||
| tmp.identifier = ts->name; | tmp.identifier = ts->name; | ||||
| tmp.name = ts->name; | tmp.name = ts->name; | ||||
| tmp.value = i++; | tmp.value = i++; | ||||
| RNA_enum_item_add(&item, &totitem, &tmp); | RNA_enum_item_add(&item, &totitem, &tmp); | ||||
| } | } | ||||
| } | } | ||||
| RNA_enum_item_end(&item, &totitem); | RNA_enum_item_end(&item, &totitem); | ||||
| ▲ Show 20 Lines • Show All 2,208 Lines • ▼ Show 20 Lines | static void rna_def_space_view3d(BlenderRNA *brna) | ||||
| RNA_def_property_enum_items(prop, manipulators_items); | RNA_def_property_enum_items(prop, manipulators_items); | ||||
| RNA_def_property_flag(prop, PROP_ENUM_FLAG); | RNA_def_property_flag(prop, PROP_ENUM_FLAG); | ||||
| RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators"); | RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators"); | ||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | ||||
| prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "twmode"); | RNA_def_property_enum_sdna(prop, NULL, "twmode"); | ||||
| RNA_def_property_enum_items(prop, transform_orientation_items); | RNA_def_property_enum_items(prop, transform_orientation_items); | ||||
| RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TransformOrientation_itemf"); | RNA_def_property_enum_funcs(prop, "rna_View3D_transform_orientation_get", "rna_View3D_transform_orientation_set", | ||||
| "rna_TransformOrientation_itemf"); | |||||
| RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); | RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); | ||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_transform_orientation_update"); | RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | ||||
| prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "TransformOrientation"); | RNA_def_property_struct_type(prop, "TransformOrientation"); | ||||
| RNA_def_property_pointer_funcs(prop, "rna_CurrentOrientation_get", NULL, NULL, NULL); | RNA_def_property_pointer_funcs(prop, "rna_View3D_current_orientation_get", NULL, NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); | RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); | ||||
| prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1); | RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1); | ||||
| RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set"); | RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set"); | ||||
| RNA_def_property_ui_text(prop, "Lock Camera and Layers", | RNA_def_property_ui_text(prop, "Lock Camera and Layers", | ||||
| "Use the scene's active camera and layers in this view, rather than local layers"); | "Use the scene's active camera and layers in this view, rather than local layers"); | ||||
| RNA_def_property_ui_icon(prop, ICON_LOCKVIEW_OFF, 1); | RNA_def_property_ui_icon(prop, ICON_LOCKVIEW_OFF, 1); | ||||
| ▲ Show 20 Lines • Show All 2,137 Lines • Show Last 20 Lines | |||||