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:
authorCampbell Barton <ideasman42@gmail.com>2012-12-31 20:24:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-31 20:24:49 +0400
commitdd62a2c3756d4335479a561a52468a548f2f1d65 (patch)
tree2a4a40d8148cb3d14155e47e59b09e3305495be8 /source/blender/editors/space_text
parentf54b6eee45cf24450076d39c3fa3bd0d4e21f564 (diff)
text autocomplete
- make the popup box line up the X axis with the current word. - add poll function for the operator
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c10
-rw-r--r--source/blender/editors/space_text/text_draw.c24
-rw-r--r--source/blender/editors/space_text/text_intern.h3
-rw-r--r--source/blender/editors/space_text/text_ops.c2
4 files changed, 22 insertions, 17 deletions
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index 097174f2645..46e2f99d3fa 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -147,13 +147,7 @@ static GHash *text_autocomplete_build(Text *text)
/* first get the word we're at */
{
- int i = text->curc;
- while (i--) {
- if (!text_check_identifier(text->curl->line[i])) {
- break;
- }
- }
- i++;
+ const int i = text_find_identifier_start(text->curl->line, text->curc);
seek_len = text->curc - i;
seek = text->curl->line + i;
@@ -550,7 +544,7 @@ void TEXT_OT_autocomplete(wmOperatorType *ot)
ot->invoke = text_autocomplete_invoke;
ot->cancel = text_autocomplete_cancel;
ot->modal = text_autocomplete_modal;
- //ot->poll = ED_operator_view3d_active;
+ ot->poll = text_space_edit_poll;
/* flags */
ot->flag = OPTYPE_BLOCKING;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 6e33fc122b5..a26b4f56e02 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -958,8 +958,10 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
TextLine *tmp;
char str[SUGG_LIST_WIDTH + 1];
int w, boxw = 0, boxh, i, l, x, y, b, *top;
+ const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
+ const int margin_x = 2;
- if (!st || !st->text) return;
+ if (!st->text) return;
if (!texttool_text_is_active(st->text)) return;
first = texttool_suggest_first();
@@ -981,14 +983,20 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
else {
x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4;
}
- y = ar->winy - (st->lheight_dpi + TXT_LINE_SPACING) * l - 2;
+ /* offset back so the start of the text lines up with the suggestions,
+ * not essential but makes suggestions easier to follow */
+ x -= st->cwidth * (st->text->curc - text_find_identifier_start(st->text->curl->line, st->text->curc));
+ y = ar->winy - lheight * l - 2;
boxw = SUGG_LIST_WIDTH * st->cwidth + 20;
- boxh = SUGG_LIST_SIZE * st->lheight_dpi + 8;
+ boxh = SUGG_LIST_SIZE * lheight + 8;
+ /* not needed but stands out nicer */
+ uiDrawBoxShadow(220, x, y - boxh, x + boxw, y);
+
UI_ThemeColor(TH_SHADE1);
glRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1);
- UI_ThemeColor(TH_BACK);
+ UI_ThemeColorShade(TH_BACK, 16);
glRecti(x, y, x + boxw, y - boxh);
/* Set the top 'item' of the visible list */
@@ -996,7 +1004,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
- y -= st->lheight_dpi;
+ y -= lheight;
BLI_strncpy(str, item->name, SUGG_LIST_WIDTH);
@@ -1004,7 +1012,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
if (item == sel) {
UI_ThemeColor(TH_SHADE2);
- glRecti(x + 16, y - 3, x + 16 + w, y + st->lheight_dpi - 3);
+ glRecti(x + margin_x, y - 3, x + margin_x + w, y + lheight - 3);
}
b = 1; /* b=1 color block, text is default. b=0 no block, color text */
switch (item->type) {
@@ -1018,7 +1026,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
glRecti(x + 8, y + 2, x + 11, y + 5);
UI_ThemeColor(TH_TEXT);
}
- text_draw(st, str, 0, 0, 1, x + 16, y - 1, NULL);
+ text_draw(st, str, 0, 0, 1, x + margin_x, y - 1, NULL);
if (item == last) break;
}
@@ -1031,7 +1039,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
Text *text = st->text;
int vcurl, vcurc, vsell, vselc, hidden = 0;
int x, y, w, i;
- int lheight = st->lheight_dpi + TXT_LINE_SPACING;
+ const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
/* Draw the selection */
if (text->curl != text->sell || text->curc != text->selc) {
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index 8fa74a5c866..799bc49b624 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -143,6 +143,9 @@ void TEXT_OT_to_3d_object(struct wmOperatorType *ot);
void TEXT_OT_resolve_conflict(struct wmOperatorType *ot);
+int text_space_edit_poll(struct bContext *C);
+
+/* text_autocomplete.c */
void TEXT_OT_autocomplete(struct wmOperatorType *ot);
/* space_text.c */
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 01041c0e385..89cc396efbb 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -98,7 +98,7 @@ static int text_edit_poll(bContext *C)
return 1;
}
-static int text_space_edit_poll(bContext *C)
+int text_space_edit_poll(bContext *C)
{
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);