1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 #pragma once 17 18 /** \file 19 * \ingroup wm 20 */ 21 22 /* dna-savable wmStructs here */ 23 #include "BLI_compiler_attrs.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 struct IDProperty; 30 struct Main; 31 struct PointerRNA; 32 struct ScrArea; 33 struct StructRNA; 34 struct WorkSpace; 35 struct bContext; 36 struct bToolRef_Runtime; 37 struct wmMsgSubscribeKey; 38 struct wmMsgSubscribeValue; 39 struct wmOperatorType; 40 41 /* wm_toolsystem.c */ 42 43 #define WM_TOOLSYSTEM_SPACE_MASK \ 44 ((1 << SPACE_IMAGE) | (1 << SPACE_NODE) | (1 << SPACE_VIEW3D) | (1 << SPACE_SEQ)) 45 /* Values that define a categoey of active tool. */ 46 typedef struct bToolKey { 47 int space_type; 48 int mode; 49 } bToolKey; 50 51 struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C); 52 struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bToolKey *tkey); 53 bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, 54 const bToolKey *tkey, 55 struct bToolRef **r_tref); 56 57 struct bToolRef *WM_toolsystem_ref_set_by_id_ex(struct bContext *C, 58 struct WorkSpace *workspace, 59 const bToolKey *tkey, 60 const char *name, 61 bool cycle); 62 struct bToolRef *WM_toolsystem_ref_set_by_id(struct bContext *C, const char *name); 63 64 struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C); 65 struct bToolRef_Runtime *WM_toolsystem_runtime_find(struct WorkSpace *workspace, 66 const bToolKey *tkey); 67 68 void WM_toolsystem_unlink(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey); 69 void WM_toolsystem_refresh(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey); 70 void WM_toolsystem_reinit(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey); 71 72 void WM_toolsystem_unlink_all(struct bContext *C, struct WorkSpace *workspace); 73 void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace); 74 void WM_toolsystem_reinit_all(struct bContext *C, struct wmWindow *win); 75 76 void WM_toolsystem_ref_set_from_runtime(struct bContext *C, 77 struct WorkSpace *workspace, 78 struct bToolRef *tref, 79 const struct bToolRef_Runtime *tref_rt, 80 const char *idname); 81 82 void WM_toolsystem_ref_sync_from_context(struct Main *bmain, 83 struct WorkSpace *workspace, 84 struct bToolRef *tref); 85 86 void WM_toolsystem_init(struct bContext *C); 87 88 int WM_toolsystem_mode_from_spacetype(struct ViewLayer *view_layer, 89 struct ScrArea *area, 90 int space_type); 91 bool WM_toolsystem_key_from_context(struct ViewLayer *view_layer, 92 struct ScrArea *area, 93 bToolKey *tkey); 94 95 void WM_toolsystem_update_from_context_view3d(struct bContext *C); 96 void WM_toolsystem_update_from_context(struct bContext *C, 97 struct WorkSpace *workspace, 98 struct ViewLayer *view_layer, 99 struct ScrArea *area); 100 101 bool WM_toolsystem_active_tool_is_brush(const struct bContext *C); 102 103 void WM_toolsystem_do_msg_notify_tag_refresh(struct bContext *C, 104 struct wmMsgSubscribeKey *msg_key, 105 struct wmMsgSubscribeValue *msg_val); 106 107 struct IDProperty *WM_toolsystem_ref_properties_ensure_idprops(struct bToolRef *tref); 108 void WM_toolsystem_ref_properties_ensure_ex(struct bToolRef *tref, 109 const char *idname, 110 struct StructRNA *type, 111 struct PointerRNA *r_ptr); 112 113 #define WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, r_ptr) \ 114 WM_toolsystem_ref_properties_ensure_ex(tref, (ot)->idname, (ot)->srna, r_ptr) 115 #define WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgroup, r_ptr) \ 116 WM_toolsystem_ref_properties_ensure_ex(tref, (gzgroup)->idname, (gzgroup)->srna, r_ptr) 117 118 bool WM_toolsystem_ref_properties_get_ex(struct bToolRef *tref, 119 const char *idname, 120 struct StructRNA *type, 121 struct PointerRNA *r_ptr); 122 #define WM_toolsystem_ref_properties_get_from_operator(tref, ot, r_ptr) \ 123 WM_toolsystem_ref_properties_get_ex(tref, (ot)->idname, (ot)->srna, r_ptr) 124 #define WM_toolsystem_ref_properties_get_from_gizmo_group(tref, gzgroup, r_ptr) \ 125 WM_toolsystem_ref_properties_get_ex(tref, (gzgroup)->idname, (gzgroup)->srna, r_ptr) 126 127 void WM_toolsystem_ref_properties_init_for_keymap(struct bToolRef *tref, 128 struct PointerRNA *dst_ptr, 129 struct PointerRNA *src_ptr, 130 struct wmOperatorType *ot); 131 132 void WM_toolsystem_refresh_active(struct bContext *C); 133 134 void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, 135 struct ViewLayer *view_layer, 136 struct ScrArea *area); 137 void WM_toolsystem_refresh_screen_all(struct Main *bmain); 138 139 #ifdef __cplusplus 140 } 141 #endif 142