Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-03-04 23:30:17 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-03-04 23:32:37 +0300
commit6a662ffda8360f06888452cf43c44b5507f09164 (patch)
tree756d7de94b720bb08dda1292982a6fa080e311d2 /source/blender/editors/gpencil/gpencil_primitive.c
parent1668f883fbe555bebf992bc77fd1c78203b23b14 (diff)
GPencil: Implement Autokey button for Draw/Edit and Sculpt mode
Now, if the Autokey is not enabled, a new frame is not created and it is used the last active one. If no active frame, a message is displayed and the operation is canceled. This is a common request for 2D artists. Also, grease pencil was not working as Blender does in other areas. Reviewed By: pepeland Differential Revision: https://developer.blender.org/D10557
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 12d399f32ca..b29ef2e7ee2 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -71,6 +71,7 @@
#include "RNA_enum_types.h"
#include "ED_gpencil.h"
+#include "ED_keyframing.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_space_api.h"
@@ -1253,9 +1254,18 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
static int gpencil_primitive_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
+ Scene *scene = CTX_data_scene(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
tGPDprimitive *tgpi = NULL;
+ if (!IS_AUTOKEY_ON(scene)) {
+ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
+ if ((gpl == NULL) || (gpl->actframe == NULL)) {
+ BKE_report(op->reports, RPT_INFO, "No available frame for creating stroke");
+ return OPERATOR_CANCELLED;
+ }
+ }
+
/* initialize operator runtime data */
gpencil_primitive_init(C, op);
tgpi = op->customdata;
@@ -1310,11 +1320,16 @@ static void gpencil_primitive_interaction_end(bContext *C,
/* insert keyframes as required... */
short add_frame_mode;
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
- add_frame_mode = GP_GETFRAME_ADD_COPY;
+ if (IS_AUTOKEY_ON(tgpi->scene)) {
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
+ add_frame_mode = GP_GETFRAME_ADD_COPY;
+ }
+ else {
+ add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
}
else {
- add_frame_mode = GP_GETFRAME_ADD_NEW;
+ add_frame_mode = GP_GETFRAME_USE_PREV;
}
bool need_tag = tgpi->gpl->actframe == NULL;