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:
authorTon Roosendaal <ton@blender.org>2005-11-20 13:04:45 +0300
committerTon Roosendaal <ton@blender.org>2005-11-20 13:04:45 +0300
commit77332fa698fb79cc1d0c1539161e0e85c93b68f7 (patch)
treeb02b7ce3c8245c51ff96eb4f45d4532846e8ff78 /source/blender/src/interface_draw.c
parenta86b0af575c6dad58b8c6ef223d20f5e76a055ed (diff)
Patch by Matt Ebb: upgraded usablitiy of text button.
Textbuttons now allow a selection too (like any textbutton in other UIs). By default, on activating a textbutton, the entire button text is selected when you enter the button. A single arrowkey or LMB click reveils the cursor then. Here's more user notes: LMB click: If inside the button, places the text cursor at the clicked position. If outside the button, confirms/finishes editing LMB drag: Selects the text between the start and end point of the drag. Backspace: Deletes selected text, or backspaces a character Shift Backspace: Deletes all, as before. Delete: Deletes selected text or forward deletes a character Shift LeftArrow: Extends the selection left Shift RightArrow: Extends the selection right LeftArrow: If there's a selection, move the cursor to the left edge of the selection, otherwise move the cursor left a character. RightArrow: If there's a selection, move the cursor to the right edge of the selection, otherwise move the cursor right a character. UpArrow/Home: Move the cursor to the beginning of the line DownArrow/End: Move the cursor to the end of the line Ctrl Left arrow and Ctrl Right arrow to jump between directory separators
Diffstat (limited to 'source/blender/src/interface_draw.c')
-rw-r--r--source/blender/src/interface_draw.c62
1 files changed, 46 insertions, 16 deletions
diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c
index 966d402a009..e0e09e36aac 100644
--- a/source/blender/src/interface_draw.c
+++ b/source/blender/src/interface_draw.c
@@ -1452,6 +1452,8 @@ static void ui_draw_text_icon(uiBut *but)
float x;
int len;
char *cpoin;
+ short t, pos, ch;
+ short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
/* check for button text label */
if (but->type == ICONTEXTROW) {
@@ -1459,25 +1461,53 @@ static void ui_draw_text_icon(uiBut *but)
}
else {
- // text button cursor
+ /* text button selection and cursor */
if(but->pos != -1) {
- short t, pos, ch;
-
- pos= but->pos+strlen(but->str);
- if(pos >= but->ofs) {
- if(but->drawstr[0]!=0) {
- ch= but->drawstr[pos];
- but->drawstr[pos]= 0;
- t= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & USER_TR_BUTTONS)) + 3;
-
- but->drawstr[pos]= ch;
+ if (SELWIDTH > 0) {
+ /* text button selection */
+ selsta_tmp = but->selsta + strlen(but->str);
+ selend_tmp = but->selend + strlen(but->str);
+ if (but->ofs >= strlen(but->str))
+ selsta_tmp += (but->ofs - strlen(but->str));
+
+ if(but->drawstr[0]!=0) {
+ ch= but->drawstr[selsta_tmp];
+ but->drawstr[selsta_tmp]= 0;
+
+ selsta_draw = but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & USER_TR_BUTTONS)) + 3;
+
+ but->drawstr[selsta_tmp]= ch;
+
+
+ ch= but->drawstr[selend_tmp];
+ but->drawstr[selend_tmp]= 0;
+
+ selwidth_draw = but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & USER_TR_BUTTONS)) + 3;
+
+ but->drawstr[selend_tmp]= ch;
+
+ BIF_ThemeColor(TH_BUT_TEXTFIELD_HI);
+ glRects(but->x1+selsta_draw+1, but->y1+2, but->x1+selwidth_draw+1, but->y2-2);
}
- else t= 3;
-
- glColor3ub(255,0,0);
- glRects(but->x1+t, but->y1+2, but->x1+t+3, but->y2-2);
- }
+ } else {
+ /* text cursor */
+ pos= but->pos+strlen(but->str);
+ if(pos >= but->ofs) {
+ if(but->drawstr[0]!=0) {
+ ch= but->drawstr[pos];
+ but->drawstr[pos]= 0;
+
+ t= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, (U.transopts & USER_TR_BUTTONS)) + 3;
+
+ but->drawstr[pos]= ch;
+ }
+ else t= 3;
+
+ glColor3ub(255,0,0);
+ glRects(but->x1+t, but->y1+2, but->x1+t+2, but->y2-2);
+ }
+ }
}
if(but->drawstr[0]!=0) {
int transopts;