Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_draw.c
| Context not available. | |||||
| #include "BKE_text.h" | #include "BKE_text.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "ED_text.h" | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
Severin: Should be removed, but maybe it's useful to leave this as a debug option | |||||
Not Done Inline ActionsTo be removed? see comment below. mont29: To be removed? see comment below. | |||||
Not Done Inline ActionsDo not really see the point to have intermediate vars here, would just do: i = txt_get_span(text->lines.first, text->curl); st->text_cursor_pos[0] = (text->curc - st->left) * st->cwidth; st->text_cursor_pos[1] = sa->winy - ((i - st->top) * st->lheight); … and remove the debug print in final version too, we do not want that on by default even in debug build. ;) mont29: Do not really see the point to have intermediate vars here, would just do:
i = txt_get_span… | |||||
Not Done Inline Actionstsst… needless blank lines. :P mont29: tsst… needless blank lines. :P | |||||
Not Done Inline Actionssa is no more available here in master (since 10/11), ar->winy maybe? mont29: sa is no more available here in master (since 10/11), ar->winy maybe? | |||||
Not Done Inline Actionsthis is a reasonably expensive function. Calling it each time on the offchange someone might want to access text_cursor_pos is unnecessary. campbellbarton: this is a reasonably expensive function.
Calling it each time on the offchange someone might… | |||||
| Context not available. | |||||
| text_scroll_to_cursor__area(st, sa, true); | text_scroll_to_cursor__area(st, sa, true); | ||||
| } | } | ||||
| bool ED_text_line_char_to_pixel_space(SpaceText *st, ARegion* ar, const int line_char[2], int screen_pos[2]) | |||||
| { | |||||
| TextLine* line = NULL; | |||||
| if (st && st->text) { | |||||
| /*ensure line, char are valid text positions (hmm, why... does it matter here?) */ | |||||
| if (line_char[0] < 0) { | |||||
| screen_pos[0] = screen_pos[1] = -1; | |||||
| return false; | |||||
| } | |||||
| else { | |||||
| line = BLI_findlink(&st->text->lines, line_char[0]); | |||||
| if (!line || (line_char[1] < 0) || (line_char[1] > line->len)) { | |||||
| screen_pos[0] = screen_pos[1] = -1; | |||||
| return false; | |||||
| } | |||||
| else { | |||||
| int offl = 0, offc = 0; | |||||
| if (st->wordwrap) { | |||||
| wrap_offset(st, ar, line, line_char[1], &offl, &offc); | |||||
| } | |||||
| screen_pos[0] = (line_char[1] + offc - st->left) * st->cwidth; | |||||
| screen_pos[1] = (line_char[0] + offl - st->top) * (st->lheight_dpi + TXT_LINE_SPACING); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| screen_pos[0] = screen_pos[1] = -1; | |||||
| return false; | |||||
| } | |||||
| } | |||||
| Context not available. | |||||
Should be removed, but maybe it's useful to leave this as a debug option