From 38410b63a60a70faf0b82b6b2ec4172013dd2af1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Feb 2009 19:55:20 +0000 Subject: 2.5: Text edit mode operators back. Took me a while getting them nicely repeatable, and splitting up the big edit_text operator into individual operator so it's all nicely scriptable, documented, configurable, etc.. * Insert Text, Line Break, Insert Lorem * Toggle Case, Set Case, Toggle Style, Set Style, Set Material * Copy Text, Cut Text, Paste Text, Paste File, Paste Buffer * Move, Move Select, Delete * Change Spacing, Change Character Notes * Text (datablock) to Object doesn't work yet, will need to implement text editor context for that. * Some shortcut keys don't work because screen/wm overrides them, ctrl+x, ctrl+left/right. That override goes top down which works well for some cases, but here we need to override in the other direction. * There's no unicode support in RNA, or the user interface code for that matter, but text strings can contain these characters. At the moment it stores a UTF-8 string in char arrays, which is supposed to be nicely compatible with ascii. Seems reasonable to add support for UTF-8 in the interface code, python bindings, .. eventually? --- .../blender/editors/interface/interface_regions.c | 41 ++++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/interface/interface_regions.c') diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 5bca01ef16d..5365c3e09f0 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1661,17 +1661,18 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, /* type, internal */ #define MENU_ITEM_TITLE 0 #define MENU_ITEM_ITEM 1 -#define MENU_ITEM_OPNAME 2 -#define MENU_ITEM_OPNAME_BOOL 3 -#define MENU_ITEM_OPNAME_ENUM 4 -#define MENU_ITEM_OPNAME_INT 5 -#define MENU_ITEM_OPNAME_FLOAT 6 -#define MENU_ITEM_RNA_BOOL 7 -#define MENU_ITEM_RNA_ENUM 8 -#define MENU_ITEM_LEVEL 9 -#define MENU_ITEM_LEVEL_OPNAME_ENUM 10 -#define MENU_ITEM_LEVEL_RNA_ENUM 11 -#define MENU_ITEM_SEPARATOR 12 +#define MENU_ITEM_SEPARATOR 2 +#define MENU_ITEM_OPNAME 10 +#define MENU_ITEM_OPNAME_BOOL 11 +#define MENU_ITEM_OPNAME_ENUM 12 +#define MENU_ITEM_OPNAME_INT 13 +#define MENU_ITEM_OPNAME_FLOAT 14 +#define MENU_ITEM_OPNAME_STRING 15 +#define MENU_ITEM_RNA_BOOL 20 +#define MENU_ITEM_RNA_ENUM 21 +#define MENU_ITEM_LEVEL 30 +#define MENU_ITEM_LEVEL_OPNAME_ENUM 31 +#define MENU_ITEM_LEVEL_RNA_ENUM 32 struct uiMenuItem { struct uiMenuItem *next, *prev; @@ -1685,6 +1686,7 @@ struct uiMenuItem { int retval, enumval, boolval, intval; float fltval; + char *strval; int opcontext; uiMenuHandleFunc eventfunc; void *argv; @@ -1878,6 +1880,12 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, y1 -= MENU_BUTTON_HEIGHT; } + else if(item->type==MENU_ITEM_OPNAME_STRING) { + but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, ""); + RNA_string_set(uiButGetOperatorPtrRNA(but), item->propname, item->strval); + + y1 -= MENU_BUTTON_HEIGHT; + } else if(item->type==MENU_ITEM_OPNAME) { uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, NULL, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, NULL); y1 -= MENU_BUTTON_HEIGHT; @@ -2074,6 +2082,17 @@ void uiMenuItemBooleanO(uiMenuItem *head, const char *name, int icon, char *opna item->type = MENU_ITEM_OPNAME_BOOL; } +/* single operator item with property */ +void uiMenuItemStringO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, char *value) +{ + uiMenuItem *item= ui_menu_add_item(head, name, icon, 0); + + item->opname= opname; // static! + item->propname= propname; // static! + item->strval= value; + item->type = MENU_ITEM_OPNAME_STRING; +} + /* add all operator items with property */ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname) { -- cgit v1.2.3