Cleanup: use enum for CTX_data_mode_enum
Exposes errors in some cases when compared against incompatible values.
This commit is contained in:
@@ -254,10 +254,10 @@ struct RenderEngineType *CTX_data_engine_type(const bContext *C);
|
||||
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
|
||||
|
||||
const char *CTX_data_mode_string(const bContext *C);
|
||||
int CTX_data_mode_enum_ex(
|
||||
enum eContextObjectMode CTX_data_mode_enum_ex(
|
||||
const struct Object *obedit, const struct Object *ob,
|
||||
const eObjectMode object_mode);
|
||||
int CTX_data_mode_enum(const bContext *C);
|
||||
enum eContextObjectMode CTX_data_mode_enum(const bContext *C);
|
||||
|
||||
void CTX_data_main_set(bContext *C, struct Main *bmain);
|
||||
void CTX_data_scene_set(bContext *C, struct Scene *bmain);
|
||||
|
||||
@@ -975,7 +975,7 @@ Collection *CTX_data_collection(const bContext *C)
|
||||
return BKE_collection_master(scene);
|
||||
}
|
||||
|
||||
int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
|
||||
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
|
||||
{
|
||||
// Object *obedit = CTX_data_edit_object(C);
|
||||
if (obedit) {
|
||||
@@ -1015,7 +1015,7 @@ int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectM
|
||||
return CTX_MODE_OBJECT;
|
||||
}
|
||||
|
||||
int CTX_data_mode_enum(const bContext *C)
|
||||
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Object *obact = obedit ? NULL : CTX_data_active_object(C);
|
||||
|
||||
@@ -3750,7 +3750,8 @@ void drw_batch_cache_generate_requested(Object *ob)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const ToolSettings *ts = draw_ctx->scene->toolsettings;
|
||||
const int mode = CTX_data_mode_enum_ex(draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
|
||||
const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
|
||||
draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
|
||||
const bool is_paint_mode = ELEM(mode, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
|
||||
const bool use_hide = (
|
||||
(ob->type == OB_MESH) &&
|
||||
|
||||
@@ -1307,7 +1307,8 @@ static void drw_engines_enable_basic(void)
|
||||
static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_type)
|
||||
{
|
||||
Object *obact = OBACT(view_layer);
|
||||
const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
|
||||
const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
|
||||
DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
|
||||
View3D *v3d = DST.draw_ctx.v3d;
|
||||
const int drawtype = v3d->shading.type;
|
||||
const bool use_xray = XRAY_ENABLED(v3d);
|
||||
|
||||
@@ -201,7 +201,7 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceProper
|
||||
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
|
||||
{
|
||||
const WorkSpace *workspace = CTX_wm_workspace(C);
|
||||
const int mode = CTX_data_mode_enum(C);
|
||||
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
|
||||
|
||||
const char *contexts_base[5] = {NULL};
|
||||
contexts_base[0] = ".active_tool";
|
||||
@@ -260,6 +260,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
|
||||
case CTX_MODE_WEIGHT_GPENCIL:
|
||||
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (workspace->tools_space_type == SPACE_IMAGE) {
|
||||
@@ -295,6 +297,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
|
||||
case CTX_MODE_EDIT_GPENCIL:
|
||||
ARRAY_SET_ITEMS(contexts, ".greasepencil_edit");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -258,6 +258,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
case OB_MODE_EDIT:
|
||||
km = WM_keymap_find_all(C, "UV Sculpt", 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (STRPREFIX(opname, "MBALL_OT")) {
|
||||
@@ -293,6 +295,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
case OB_MODE_TEXTURE_PAINT:
|
||||
km = WM_keymap_find_all(C, "Image Paint", 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Image Editor */
|
||||
|
||||
Reference in New Issue
Block a user