diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-09-04 22:49:07 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-09-04 22:49:07 +0400 |
commit | 90b464d3728d9ed8ec26fdf59058d236b99dbcd9 (patch) | |
tree | e88cab4fb1358e962b19f658064ca8c9f8d29f5b /source/blender/editors/interface/interface_regions.c | |
parent | 08d02dd04d836976b25793bb1d4c6a86b3f924c7 (diff) | |
parent | b0b787ef38f9947b3176642556f5282eb3518f69 (diff) |
COLLADA branch: merge from trunk -r 28015:31610.soc-2009-chingachgook
Diffstat (limited to 'source/blender/editors/interface/interface_regions.c')
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 75 |
1 files changed, 47 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 35add45b10a..50b85360196 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -38,11 +38,7 @@ #include "BLI_ghash.h" #include "BKE_context.h" -#include "BKE_icons.h" -#include "BKE_report.h" #include "BKE_screen.h" -#include "BKE_texture.h" -#include "BKE_utildefines.h" #include "WM_api.h" #include "WM_types.h" @@ -453,10 +449,10 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->fstyle.align= UI_STYLE_TEXT_CENTER; uiStyleFontSet(&data->fstyle); - h= BLF_height(data->lines[0]); + h= BLF_height(data->fstyle.uifont_id, data->lines[0]); for(a=0, fontw=0, fonth=0; a<data->totline; a++) { - w= BLF_width(data->lines[a]); + w= BLF_width(data->fstyle.uifont_id, data->lines[a]); fontw= MAX2(fontw, w); fonth += (a == 0)? h: h+5; } @@ -1559,12 +1555,21 @@ void ui_set_but_hsv(uiBut *but) } /* also used by small picker, be careful with name checks below... */ -void ui_update_block_buts_rgb(uiBlock *block, float *rgb) +void ui_update_block_buts_rgb(uiBlock *block, float *rgb, float *rhsv) { uiBut *bt; float hsv[3]; - rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + /* this is to keep the H and S value when V is equal to zero + * and we are working in HSV mode, of course! + */ + if (rhsv) { + hsv[0]= rhsv[0]; + hsv[1]= rhsv[1]; + hsv[2]= rhsv[2]; + } + else + rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); // this updates button strings, is hackish... but button pointers are on stack of caller function for(bt= block->buttons.first; bt; bt= bt->next) { @@ -1591,7 +1596,7 @@ void ui_update_block_buts_rgb(uiBlock *block, float *rgb) if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart); if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart); - sprintf(col, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0)); + sprintf(col, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2])); strcpy(bt->poin, col); } @@ -1630,7 +1635,7 @@ static void do_picker_rna_cb(bContext *C, void *bt1, void *unused) if (prop) { RNA_property_float_get_array(&ptr, prop, rgb); - ui_update_block_buts_rgb(but->block, rgb); + ui_update_block_buts_rgb(but->block, rgb, NULL); } if(popup) @@ -1646,7 +1651,7 @@ static void do_hsv_rna_cb(bContext *C, void *bt1, void *hsv_arg) hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); - ui_update_block_buts_rgb(but->block, rgb); + ui_update_block_buts_rgb(but->block, rgb, hsv); if(popup) popup->menuretval= UI_RETURN_UPDATE; @@ -1667,7 +1672,7 @@ static void do_hex_rna_cb(bContext *C, void *bt1, void *hexcl) srgb_to_linearrgb_v3_v3(rgb, rgb); } - ui_update_block_buts_rgb(but->block, rgb); + ui_update_block_buts_rgb(but->block, rgb, NULL); if(popup) popup->menuretval= UI_RETURN_UPDATE; @@ -1736,11 +1741,11 @@ static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname) uiBut *bt; /* HS circle */ - bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1751,11 +1756,11 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname, int bartype = type + 3; /* HS square */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1770,6 +1775,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR static float hsv[3]; static char hexcol[128]; float rgb_gamma[3]; + float min, max, step, precision; const char *propname = RNA_property_identifier(prop); width= PICKER_TOTAL_W; @@ -1785,6 +1791,10 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR linearrgb_to_srgb_v3_v3(rgb_gamma, rgb); } + /* sneaky way to check for alpha */ + rgb[3]= FLT_MAX; + + RNA_property_float_ui_range(ptr, prop, &min, &max, &step, &precision); RNA_property_float_get_array(ptr, prop, rgb); rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); @@ -1818,28 +1828,37 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR /* RGB values */ uiBlockBeginAlign(block); - bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 3, "Red"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 3, "Green"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 3, "Blue"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); + // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", 0); // but need to use uiButSetFunc for updating other fake buttons /* HSV values */ uiBlockBeginAlign(block); - bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "Hue"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); - bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, "Saturation"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); - bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, 1.0, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, max, 10, 3, "Value"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); uiBlockEndAlign(block); - + + if(rgb[3] != FLT_MAX) { + bt= uiDefButR(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, propname, 3, 0.0, 0.0, 0, 0, "Alpha"); + uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); + } + else { + rgb[3]= 1.0f; + } + rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); - - sprintf(hexcol, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0)); + + sprintf(hexcol, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2])); bt= uiDefBut(block, TEX, 0, "Hex: ", 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, "Hex triplet for color (#RRGGBB)"); uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol); @@ -1874,7 +1893,7 @@ static int ui_picker_small_wheel(const bContext *C, uiBlock *block, wmEvent *eve ui_set_but_vectorf(but, col); - ui_update_block_buts_rgb(block, col); + ui_update_block_buts_rgb(block, col, NULL); if(popup) popup->menuretval= UI_RETURN_UPDATE; @@ -2095,13 +2114,13 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut pup->mx= window->eventstate->x; pup->my= window->eventstate->y; pup->popup= 1; + pup->block->flag |= UI_BLOCK_NO_FLIP; } if(str) { /* menu is created from a string */ pup->menu_func= ui_block_func_MENUSTR; pup->menu_arg= str; - // XXX pup->block->flag |= UI_BLOCK_NO_FLIP; } else { /* menu is created from a callback */ @@ -2305,7 +2324,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports) ds= BLI_dynstr_new(); for(report=reports->list.first; report; report=report->next) { - if(report->type <= reports->printlevel) + if(report->type < reports->printlevel) ; /* pass */ else if(report->type >= RPT_ERROR) BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message); |