[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34714] trunk/blender/source/blender/ editors/space_text/text_ops.c: Text Editor Bugfixes:
Joshua Leung
aligorith at gmail.com
Tue Feb 8 10:57:51 CET 2011
Revision: 34714
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34714
Author: aligorith
Date: 2011-02-08 09:57:51 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
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 (?)
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_text/text_ops.c
Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c 2011-02-08 09:14:18 UTC (rev 34713)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c 2011-02-08 09:57:51 UTC (rev 34714)
@@ -124,7 +124,6 @@
return 1;
}
-
/********************** updates *********************/
void text_update_line_edited(TextLine *line)
@@ -342,6 +341,12 @@
/******************* 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 @@
/* 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 @@
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 @@
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 @@
/******************** 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 @@
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;
More information about the Bf-blender-cvs
mailing list