Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_manipulator_camera.c
| Show All 39 Lines | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | |||||
| #include "view3d_intern.h" /* own include */ | #include "view3d_intern.h" /* own include */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Camera Manipulators | /** \name Camera Manipulators | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | if (true) { | ||||
| WM_manipulator_set_matrix_offset_location(widget, offset); | WM_manipulator_set_matrix_offset_location(widget, offset); | ||||
| /* need to set property here for undo. TODO would prefer to do this in _init */ | /* need to set property here for undo. TODO would prefer to do this in _init */ | ||||
| WM_manipulator_target_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1); | WM_manipulator_target_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1); | ||||
| WM_manipulator_target_property_def_rna(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1); | WM_manipulator_target_property_def_rna(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1); | ||||
| } | } | ||||
| } | } | ||||
| static void WIDGETGROUP_camera_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) | |||||
| { | |||||
| struct CameraWidgetGroup *camgroup = mgroup->customdata; | |||||
| ARegion *ar = CTX_wm_region(C); | |||||
| Object *ob = CTX_data_active_object(C); | |||||
| Camera *ca = ob->data; | |||||
| const bool is_ortho = (ca->type == CAM_ORTHO); | |||||
| wmManipulator *mpr = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; | |||||
| /* explicit property use */ | |||||
| { | |||||
| extern PropertyRNA rna_Camera_ortho_scale; | |||||
| extern PropertyRNA rna_Camera_draw_size; | |||||
| extern PropertyRNA rna_Camera_shift_x; | |||||
| extern PropertyRNA rna_Camera_shift_y; | |||||
| extern PropertyRNA rna_Camera_dof_distance; | |||||
| extern PropertyRNA rna_Camera_type; | |||||
| const PropertyRNA *props[] = { | |||||
| &rna_Camera_ortho_scale, | |||||
| &rna_Camera_draw_size, | |||||
| &rna_Camera_shift_x, | |||||
| &rna_Camera_shift_y, | |||||
| &rna_Camera_dof_distance, | |||||
| &rna_Camera_type, | |||||
| }; | |||||
| PointerRNA idptr; | |||||
| RNA_id_pointer_create(&ca->id, &idptr); | |||||
| struct wmMsgBus *mbus = CTX_wm_message_bus(C); | |||||
| for (int i = 0; i < ARRAY_SIZE(props); i++) { | |||||
| WM_msg_subscribe_rna( | |||||
| mbus, &idptr, props[i], | |||||
| &(const wmMsgSubscribeValue){ | |||||
| .owner = ar, | |||||
| .user_data = mpr->parent_mgroup->parent_mmap, | |||||
| .notify = WM_manipulator_do_msg_notify_tag_refresh, | |||||
| }); | |||||
| } | |||||
| } | |||||
| } | |||||
| void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) | void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) | ||||
| { | { | ||||
| wgt->name = "Camera Widgets"; | wgt->name = "Camera Widgets"; | ||||
| wgt->idname = "VIEW3D_WGT_camera"; | wgt->idname = "VIEW3D_WGT_camera"; | ||||
| wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | | wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | | ||||
| WM_MANIPULATORGROUPTYPE_3D | | WM_MANIPULATORGROUPTYPE_3D | | ||||
| WM_MANIPULATORGROUPTYPE_DEPTH_3D); | WM_MANIPULATORGROUPTYPE_DEPTH_3D); | ||||
| wgt->poll = WIDGETGROUP_camera_poll; | wgt->poll = WIDGETGROUP_camera_poll; | ||||
| wgt->setup = WIDGETGROUP_camera_setup; | wgt->setup = WIDGETGROUP_camera_setup; | ||||
| wgt->refresh = WIDGETGROUP_camera_refresh; | wgt->refresh = WIDGETGROUP_camera_refresh; | ||||
| wgt->draw_prepare = WIDGETGROUP_camera_draw_prepare; | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name CameraView Manipulators | /** \name CameraView Manipulators | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||