Here's a patch; either one is probably fine.
On Wed, May 4, 2011 at 2:02 PM, joe <[email protected]> wrote:
> It should still confirm on simple click without release_confirm on,
> though. The two are separate features; one releases on mouse up in
> edge slide itself, while the other allows you to quickly add loopcuts
> without having to cancel out of edgeslide every time (but you might
> not want release_confirm on).
>
> Still, the patch is certainly a lot simpler and less intrusive. If I
> keep the OPERATOR_ABORT_MACRO flag, I can probably get rid of the
> timer and launch_event thing (and of course that extraneous user pref)
> and do everything in loopcut. How's that?
>
> Joe
>
> On Wed, May 4, 2011 at 11:17 AM, Campbell Barton <[email protected]> wrote:
>> Heres a patch on r36449 (before this commit) which uses existing
>> transform release preference and from what I can tell works ok. (no
>> timer, no new preferences, no macro abort option).
>>
>> Patch:
>> http://www.graphicall.org/ftp/ideasman42/click_release_loopcut_36449.py
>>
>> If its acceptable Ill add an RNA function RNA_property_unset() and do
>> the ID property adjustment there.
>>
>> Joe, Martin - what do you think?
>>
>> On Tue, May 3, 2011 at 6:50 PM, joe <[email protected]> wrote:
>>> On Mon, May 2, 2011 at 9:24 PM, Martin Poirier <[email protected]> wrote:
>>>>
>>>> Yes and I happen to think I know those parts of the code (macro,
>>>> transform) as well if not better than you do.
>>>
>>> :P
>>>
>>>>
>>>> This isn't a nice way at all to solve this problem.
>>>>
>>>
>>> I saw the nasty hack for manipulators, which lead me to think I *was*
>>> doing a "nice" solution, short of rewriting the entire release_confirm
>>> functionality.
>>>
>>>> Martin
>>>> _______________________________________________
>>>
>>> Joe
>>> _______________________________________________
>>> Bf-committers mailing list
>>> [email protected]
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>
>>
>>
>>
>> --
>> - Campbell
>> _______________________________________________
>> Bf-committers mailing list
>> [email protected]
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>
Index: release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- release/scripts/startup/bl_ui/space_userpref.py (revision 36489)
+++ release/scripts/startup/bl_ui/space_userpref.py (working copy)
@@ -795,9 +795,6 @@
sub.separator()
- sub.label(text="Loop Cut:")
- sub.prop(inputs, "loopcut_finish_on_release")
-
sub.label(text="Orbit Style:")
sub.row().prop(inputs, "view_rotate_method", expand=True)
Index: source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- source/blender/makesdna/DNA_userdef_types.h (revision 36489)
+++ source/blender/makesdna/DNA_userdef_types.h (working copy)
@@ -383,13 +383,13 @@
short autokey_mode; /* autokeying mode */
short autokey_flag; /* flags for autokeying */
- short text_render, dsm_maxmem; /*options for text rendering*/
+ short text_render, pad9; /*options for text rendering*/
float pad10;
struct ColorBand coba_weight; /* from texture.h */
float sculpt_paint_overlay_col[3];
- int loopcut_finish_on_release;
+ int pad3;
char author[80]; /* author name for file formats supporting it */
} UserDef;
Index: source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- source/blender/makesrna/intern/rna_userdef.c (revision 36489)
+++ source/blender/makesrna/intern/rna_userdef.c (working copy)
@@ -2676,10 +2676,6 @@
RNA_def_property_enum_items(prop, view_zoom_axes);
RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
- prop= RNA_def_property(srna, "loopcut_finish_on_release", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "loopcut_finish_on_release", 1);
- RNA_def_property_ui_text(prop, "End Loopcut Slide On Release", "End Loopcut Slide On Mouse Release, a 'click-drag-and-hold' workflow");
-
prop= RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");
Index: source/blender/editors/transform/transform.c
===================================================================
--- source/blender/editors/transform/transform.c (revision 36489)
+++ source/blender/editors/transform/transform.c (working copy)
@@ -1521,9 +1521,7 @@
t->mode = mode;
t->launch_event = event ? event->type : -1;
- if (RNA_property_is_set(op->ptr, "launch_event"))
- t->launch_event = RNA_int_get(op->ptr, "launch_event");
-
+
if (t->launch_event == EVT_TWEAK_R)
{
t->launch_event = RIGHTMOUSE;
Index: source/blender/editors/transform/transform_ops.c
===================================================================
--- source/blender/editors/transform/transform_ops.c (revision 36489)
+++ source/blender/editors/transform/transform_ops.c (working copy)
@@ -495,11 +495,10 @@
{
RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Object data texture space", "");
}
-
+
// Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
//RNA_def_property_flag(prop, PROP_HIDDEN);
- RNA_def_int(ot->srna, "launch_event", 0, 0, INT_MAX, "Launch Event", "", 0, INT_MAX);
}
void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@@ -743,7 +742,7 @@
ot->poll = ED_operator_editmesh;
RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
-
+
Transform_Properties(ot, P_MIRROR|P_SNAP);
}
Index: source/blender/editors/mesh/loopcut.c
===================================================================
--- source/blender/editors/mesh/loopcut.c (revision 36489)
+++ source/blender/editors/mesh/loopcut.c (working copy)
@@ -99,8 +99,8 @@
EditEdge *eed;
int extend;
- int do_cut;
- wmTimer *timer;
+ int do_cut, mdown;
+ short mdown_mval[2];
} tringselOpData;
/* modal loop selection drawing callback */
@@ -316,13 +316,10 @@
}
/* called when modal loop selection is done... */
-static void ringsel_exit(bContext *C, wmOperator *op)
+static void ringsel_exit(wmOperator *op)
{
tringselOpData *lcd= op->customdata;
- if (lcd->timer)
- WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), lcd->timer);
-
/* deactivate the extra drawing stuff in 3D-View */
ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
@@ -358,10 +355,10 @@
return 1;
}
-static int ringcut_cancel (bContext *C, wmOperator *op)
+static int ringcut_cancel (bContext *UNUSED(C), wmOperator *op)
{
/* this is just a wrapper around exit() */
- ringsel_exit(C, op);
+ ringsel_exit(op);
return OPERATOR_CANCELLED;
}
@@ -379,7 +376,7 @@
lcd = op->customdata;
if (lcd->em->selectmode == SCE_SELECT_FACE) {
- ringsel_exit(C, op);
+ ringsel_exit(op);
WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, NULL);
return OPERATOR_CANCELLED;
}
@@ -389,7 +386,7 @@
edge = findnearestedge(&lcd->vc, &dist);
if(!edge) {
- ringsel_exit(C, op);
+ ringsel_exit(op);
return OPERATOR_CANCELLED;
}
@@ -397,7 +394,7 @@
ringsel_find_edge(lcd, 1);
ringsel_finish(C, op);
- ringsel_exit(C, op);
+ ringsel_exit(op);
return OPERATOR_FINISHED;
}
@@ -408,11 +405,7 @@
tringselOpData *lcd;
EditEdge *edge;
int dist = 75;
-
- /*if we're in the cut-n-slide macro, set release_confirm based on user pref*/
- if (op->opm)
- RNA_boolean_set(op->next->ptr, "release_confirm", U.loopcut_finish_on_release);
-
+
if(modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display");
@@ -442,37 +435,29 @@
{
int cuts= RNA_int_get(op->ptr,"number_cuts");
tringselOpData *lcd= op->customdata;
-
+ int abortflag = (U.flag & USER_RELEASECONFIRM) ? 0 : OPERATOR_ABORT_MACRO;
+
view3d_operator_needs_opengl(C);
switch (event->type) {
case LEFTMOUSE: /* confirm */ // XXX hardcoded
- if (event->val == KM_RELEASE) {
+ if (event->val == KM_PRESS && abortflag) {
+ lcd->mdown = 1;
+ lcd->mdown_mval[0] = event->mval[0];
+ lcd->mdown_mval[1] = event->mval[1];
+ } else {
/* finish */
ED_region_tag_redraw(lcd->ar);
ringsel_finish(C, op);
- ringsel_exit(C, op);
+ ringsel_exit(op);
ED_area_headerprint(CTX_wm_area(C), NULL);
- return OPERATOR_FINISHED|OPERATOR_ABORT_MACRO;
- }else {
- lcd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER2, 0.12);
+ return OPERATOR_FINISHED|abortflag;
}
ED_region_tag_redraw(lcd->ar);
break;
-
- case TIMER2:
- /* finish */
- ED_region_tag_redraw(lcd->ar);
-
- ringsel_finish(C, op);
- ringsel_exit(C, op);
-
- ED_area_headerprint(CTX_wm_area(C), NULL);
-
- return OPERATOR_FINISHED;
case RIGHTMOUSE: /* abort */ // XXX hardcoded
case ESCKEY:
if (event->val == KM_RELEASE) {
@@ -506,20 +491,33 @@
}
break;
case MOUSEMOVE: { /* mouse moved somewhere to select another loop */
- int dist = 75;
EditEdge *edge;
-
- lcd->vc.mval[0] = event->mval[0];
- lcd->vc.mval[1] = event->mval[1];
- edge = findnearestedge(&lcd->vc, &dist);
-
- if (edge != lcd->eed) {
- lcd->eed = edge;
- ringsel_find_edge(lcd, cuts);
+ int dist = 75;
+
+ if (lcd->mdown) {
+ if (ABS((lcd->mdown_mval[0]-event->mval[0])+(lcd->mdown_mval[1]-event->mval[1])) > 3) {
+ /* finish */
+ ED_region_tag_redraw(lcd->ar);
+
+ ringsel_finish(C, op);
+ ringsel_exit(op);
+ ED_area_headerprint(CTX_wm_area(C), NULL);
+
+ return OPERATOR_FINISHED;
+ }
+ } else {
+ lcd->vc.mval[0] = event->mval[0];
+ lcd->vc.mval[1] = event->mval[1];
+ edge = findnearestedge(&lcd->vc, &dist);
+
+ if (edge != lcd->eed) {
+ lcd->eed = edge;
+ ringsel_find_edge(lcd, cuts);
+ }
+
+ ED_region_tag_redraw(lcd->ar);
+ break;
}
-
- ED_region_tag_redraw(lcd->ar);
- break;
}
}
Index: source/blender/editors/mesh/mesh_ops.c
===================================================================
--- source/blender/editors/mesh/mesh_ops.c (revision 36489)
+++ source/blender/editors/mesh/mesh_ops.c (working copy)
@@ -54,7 +54,10 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "BKE_idprop.h"
+#include "MEM_guardedalloc.h"
+
#include "mesh_intern.h"
/**************************** registration **********************************/
@@ -176,9 +179,18 @@
ot->description = "Cut mesh loop and slide it";
WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
- RNA_boolean_set(otmacro->ptr, "release_confirm", 1);
- RNA_int_set(otmacro->ptr, "launch_event", LEFTMOUSE);
-
+ /* remove the property so the user preference is used instead */
+ /* can be moved into a function eg: RNA_property_unset() */
+ {
+ IDProperty *idprop= otmacro->ptr->data;
+ IDProperty *pkey = IDP_GetPropertyFromGroup(idprop, "release_confirm");
+ if (pkey) {
+ IDP_RemFromGroup(idprop, pkey);
+ IDP_FreeProperty(pkey);
+ MEM_freeN(pkey);
+ }
+ }
+
ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
ot->description = "Duplicate mesh and move";
WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers