[Bf-blender-cvs] [ffc77a4e67c] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

Joshua Leung noreply at git.blender.org
Thu Feb 8 15:26:01 CET 2018


Commit: ffc77a4e67c0d18369bfba951854baa65ba30601
Author: Joshua Leung
Date:   Thu Feb 8 23:47:09 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rBffc77a4e67c0d18369bfba951854baa65ba30601

Merge branch 'blender2.8' into greasepencil-object

===================================================================



===================================================================

diff --cc source/blender/editors/object/object_edit.c
index 51060d72c7b,b9956876cb3..56fd67977f6
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@@ -1591,48 -1586,24 +1590,48 @@@ static int object_mode_set_exec(bContex
  	Object *ob = CTX_data_active_object(C);
  	bGPdata *gpd = CTX_data_gpencil_data(C);
  	eObjectMode mode = RNA_enum_get(op->ptr, "mode");
- 	eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
+ 	eObjectMode restore_mode = workspace->object_mode;
  	const bool toggle = RNA_boolean_get(op->ptr, "toggle");
 -	
 -	if (gpd) {
 -		/* GP Mode is not bound to a specific object. Therefore,
 -		 * we don't want it to be actually saved on any objects,
 -		 * as weirdness can happen if you select other objects,
 -		 * or load old files.
 -		 *
 -		 * Instead, we use the following 2 rules to ensure that
 -		 * the mode selector works as expected:
 -		 *  1) If there's no object, we want to enter editmode.
 -		 *     (i.e. with no object, we're in object mode)
 -		 *  2) Otherwise, exit stroke editmode, so that we can
 -		 *     enter another mode...
 -		 */
 -		if (!ob || (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
 -			WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +
 +	/* if type is OB_GPENCIL, select mode for grease pencil strokes */	
 +	if ((ob) && (ob->type == OB_GPENCIL)) {
 +		if ((ob->data) && (ob->data == gpd)) {
 +			if (ELEM(mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_POSE)) {
 +				ob->restore_mode = OB_MODE_OBJECT;
 +				if (ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_GPENCIL_EDIT)) {
 +					WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_PAINT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_SCULPT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_WEIGHT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_EDIT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_PAINT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_SCULPT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_WEIGHT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
  		}
  	}



More information about the Bf-blender-cvs mailing list