diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-02-08 12:57:51 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-02-08 12:57:51 +0300 |
commit | 71ec3f03fbff0b3d21e7f33c86b08870810ec2b3 (patch) | |
tree | cd82d0285348a23d5167e169630a245acba484e0 /source | |
parent | 37f55ec1947be503e8452e81b4ebc48be3d3d540 (diff) |
Text Editor Bugfixes:
The poll() callbacks used in the Text Editor for scrolling and text-
block unlinking operators were too restrictive when the text block was
lib-data.
- Scrolling lib-linked texts is useful for just checking out parts of
the linked-in file that aren't visible on screen already. For example,
checking the specific rig that some UI panels script will work on, or
reading a "README.txt" linked in with notes on which layers various
controls are on. It should be fine that this temporarily modifies the
linked text-block (but for view-settings which will can be reset
later/on file load without any real consequences).
- Unlink operator should be able to be run, otherwise it would be very
difficult to remove linked files from a file (?)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index efb0b173559..bfec734dad6 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -124,7 +124,6 @@ static int text_region_edit_poll(bContext *C) return 1; } - /********************** updates *********************/ void text_update_line_edited(TextLine *line) @@ -342,6 +341,12 @@ void TEXT_OT_reload(wmOperatorType *ot) /******************* delete operator *********************/ +static int text_unlink_poll(bContext *C) +{ + /* it should be possible to unlink texts if they're lib-linked in... */ + return CTX_data_edit_text(C) != NULL; +} + static int unlink_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); @@ -381,7 +386,7 @@ void TEXT_OT_unlink(wmOperatorType *ot) /* api callbacks */ ot->exec= unlink_exec; ot->invoke= WM_operator_confirm; - ot->poll= text_edit_poll; + ot->poll= text_unlink_poll; /* flags */ ot->flag= OPTYPE_UNDO; @@ -2019,6 +2024,12 @@ typedef struct TextScroll { int zone; } TextScroll; +static int text_scroll_poll(bContext *C) +{ + /* it should be possible to still scroll linked texts to read them, even if they can't be edited... */ + return CTX_data_edit_text(C) != NULL; +} + static int scroll_exec(bContext *C, wmOperator *op) { SpaceText *st= CTX_wm_space_text(C); @@ -2183,7 +2194,7 @@ void TEXT_OT_scroll(wmOperatorType *ot) ot->invoke= scroll_invoke; ot->modal= scroll_modal; ot->cancel= scroll_cancel; - ot->poll= text_space_edit_poll; + ot->poll= text_scroll_poll; /* flags */ ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; @@ -2194,6 +2205,22 @@ void TEXT_OT_scroll(wmOperatorType *ot) /******************** scroll bar operator *******************/ +static int text_region_scroll_poll(bContext *C) +{ + /* same as text_region_edit_poll except it works on libdata too */ + SpaceText *st= CTX_wm_space_text(C); + Text *text= CTX_data_edit_text(C); + ARegion *ar= CTX_wm_region(C); + + if(!st || !text) + return 0; + + if(!ar || ar->regiontype != RGN_TYPE_WINDOW) + return 0; + + return 1; +} + static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceText *st= CTX_wm_space_text(C); @@ -2249,7 +2276,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) ot->invoke= scroll_bar_invoke; ot->modal= scroll_modal; ot->cancel= scroll_cancel; - ot->poll= text_region_edit_poll; + ot->poll= text_region_scroll_poll; /* flags */ ot->flag= OPTYPE_BLOCKING; |