diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-02-18 17:55:42 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-02-18 17:55:42 +0300 |
commit | 0f661b154fe7ab0f18abc66f09fc1c580623253e (patch) | |
tree | 8b5dccfaf524dc801d49d81f4a08c8999a008adf | |
parent | 71e80f606c06f76bc425098b70116e21fe032c30 (diff) |
Text space fixes:
- Bring back cursor set to PRESS event - block selection wouldn't
have correct start position;
- Undo stack push was missed in cursor_set operator;
- Remove unneeded cursor moving at set_selection operator;
- Fixed bug with scroll bar - it shouldn't use EVT_TWEAK;
There could be still small issues with selecting single character by
mouse (due to EVT_TWEAK threashold), but this operator is for block
selection, not single char. So shouldn't be big pain here.
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 29 |
2 files changed, 15 insertions, 18 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 3a9b8924eed..6607a401919 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -344,9 +344,9 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_scroll", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll", MOUSEPAN, 0, 0, 0); - WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", EVT_TWEAK_L, KM_ANY, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_selection_set", EVT_TWEAK_L, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_CLICK, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_selection_set", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select", 1); RNA_int_set(WM_keymap_add_item(keymap, "TEXT_OT_scroll", WHEELUPMOUSE, KM_PRESS, 0, 0)->ptr, "lines", -1); RNA_int_set(WM_keymap_add_item(keymap, "TEXT_OT_scroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0)->ptr, "lines", 1); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 55f560e6b3d..d8cbe93012d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2546,7 +2546,6 @@ static void set_cursor_exit(bContext *C, wmOperator *op) static int set_selection_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceText *st= CTX_wm_space_text(C); - ARegion *ar= CTX_wm_region(C); SetSelection *ssel; op->customdata= MEM_callocN(sizeof(SetSelection), "SetCursor"); @@ -2556,20 +2555,6 @@ static int set_selection_invoke(bContext *C, wmOperator *op, wmEvent *event) ssel->old[0]= event->mval[0]; ssel->old[1]= event->mval[1]; - if(!ssel->selecting) { - int curl= txt_get_span(st->text->lines.first, st->text->curl); - int curc= st->text->curc; - int linep2, charp2; - - set_cursor_to_pos(st, ar, event->mval[0], event->mval[1], 0); - - linep2= txt_get_span(st->text->lines.first, st->text->curl); - charp2= st->text->selc; - - if(curl!=linep2 || curc!=charp2) - txt_undo_add_toop(st->text, UNDO_CTO, curl, curc, linep2, charp2); - } - ssel->sell= txt_get_span(st->text->lines.first, st->text->sell); ssel->selc= st->text->selc; @@ -2624,20 +2609,32 @@ void TEXT_OT_selection_set(wmOperatorType *ot) static int set_cursor_exec(bContext *C, wmOperator *op) { SpaceText *st= CTX_wm_space_text(C); + Text *text= st->text; ARegion *ar= CTX_wm_region(C); int x= RNA_int_get(op->ptr, "x"); int y= RNA_int_get(op->ptr, "y"); + int oldl, oldc; + + oldl= txt_get_span(text->lines.first, text->curl); + oldc= text->curc; set_cursor_to_pos(st, ar, x, y, 0); + txt_undo_add_toop(text, UNDO_CTO, oldl, oldc, txt_get_span(text->lines.first, text->curl), text->curc); + text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text); - return OPERATOR_FINISHED; + return OPERATOR_PASS_THROUGH; } static int set_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceText *st= CTX_wm_space_text(C); + + if(event->mval[0]>=st->txtbar.xmin) + return OPERATOR_PASS_THROUGH; + RNA_int_set(op->ptr, "x", event->mval[0]); RNA_int_set(op->ptr, "y", event->mval[1]); |