- brought back hilites in buttons when mouse-over
- automatic pulldown opening can now be controlled ( user setting?) it has two thresholds: - when no menu was opened before, it waits A milliseconds - when (in the same block a menu was opened, it waits B millisec. Currently A= 0.4 sec, B= 0.1 (or so) - 3d window header; brought back old drawtype menu (test, compare!) - another test: the old menubutton doesnt work anymore with hold-mouse only, you can also use it as the other popups (old method still works) - proposal; all buttons that pop up a block, get special drawtype (arrows)
This commit is contained in:
@@ -268,6 +268,7 @@ typedef enum {
|
||||
COLORSHADE_HILITE,
|
||||
COLORSHADE_LIGHT,
|
||||
COLORSHADE_WHITE,
|
||||
|
||||
#define BIFCOLORSHADE_LAST (COLORSHADE_WHITE)
|
||||
#define BIFNCOLORSHADES (BIFCOLORSHADE_LAST-BIFCOLORSHADE_FIRST + 1)
|
||||
} BIFColorShade;
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
#define UI_EMBOSSTABM 8
|
||||
#define UI_EMBOSSTABR 9
|
||||
#define UI_EMBOSST 10
|
||||
#define UI_EMBOSSMB 11 /* emboss menu button */
|
||||
|
||||
/* uiBlock->direction */
|
||||
#define UI_TOP 0
|
||||
|
||||
@@ -93,7 +93,7 @@ typedef struct SpaceButs {
|
||||
struct ScrArea *area;
|
||||
|
||||
short cursens, curact;
|
||||
short align, pad2; /* align for panels */
|
||||
short align, tabo; /* align for panels, tab is old tab */
|
||||
View2D v2d;
|
||||
|
||||
short mainb, menunr; /* texnr and menunr have to remain shorts */
|
||||
|
||||
@@ -336,7 +336,7 @@ void do_butspace(unsigned short event)
|
||||
//do_latticebuts(event);
|
||||
}
|
||||
else if(event<=B_GAMEBUTS) {
|
||||
//do_gamebuts(event);
|
||||
do_gamebuts(event); // editsca.c
|
||||
}
|
||||
else if(event<=B_FPAINTBUTS) {
|
||||
//do_fpaintbuts(event);
|
||||
|
||||
@@ -910,7 +910,7 @@ static BIFColorID get_col_sensor(int type)
|
||||
static void set_col_sensor(int type, int medium)
|
||||
{
|
||||
BIFColorID col= get_col_sensor(type);
|
||||
BIF_set_color(col, medium?COLORSHADE_MEDIUM:COLORSHADE_GREY);
|
||||
BIF_set_color(col, medium?COLORSHADE_LIGHT:COLORSHADE_MEDIUM);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2172,6 +2172,7 @@ static uiBlock *sensor_menu(void *arg_unused)
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win);
|
||||
uiBlockSetButmFunc(block, do_sensor_menu, NULL);
|
||||
uiBlockSetCol(block, MENUCOL);
|
||||
|
||||
uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
@@ -2220,6 +2221,7 @@ static uiBlock *controller_menu(void *arg_unused)
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win);
|
||||
uiBlockSetButmFunc(block, do_controller_menu, NULL);
|
||||
uiBlockSetCol(block, MENUCOL);
|
||||
|
||||
uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefBut(block, BUTM, 1, "Hide Objects", 0,(short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
@@ -2268,6 +2270,7 @@ static uiBlock *actuator_menu(void *arg_unused)
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->win);
|
||||
uiBlockSetButmFunc(block, do_actuator_menu, NULL);
|
||||
uiBlockSetCol(block, MENUCOL);
|
||||
|
||||
uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
|
||||
@@ -6600,18 +6600,17 @@ void view3d_buttons(void)
|
||||
uiDefIconTextButS(block, MENU, B_MODESELECT, (G.vd->modeselect),view3d_modeselect_pup() ,
|
||||
xco,0,120,20, &(G.vd->modeselect), 0, 0, 0, 0, "Mode:");
|
||||
|
||||
xco+= 120;
|
||||
xco +=14;
|
||||
xco+= 130;
|
||||
|
||||
//uiDefIconTextButS(block, MENU, REDRAWVIEW3D, (ICON_BBOX+G.vd->drawtype-1), "Viewport Shading%t|Bounding Box %x1|Wireframe %x2|Solid %x3|Shaded %x4|Textured %x5",
|
||||
// xco,0,124,20, &(G.vd->drawtype), 0, 0, 0, 0, "Viewport Shading");
|
||||
/* DRAWTYPE */
|
||||
uiDefIconButS(block, ICONROW, B_REDR, ICON_BBOX, xco,0,XIC,YIC, &(G.vd->drawtype), 1.0, 5.0, 0, 0, "Drawtype: boundbox/wire/solid/shaded (ZKEY, SHIFT+Z)");
|
||||
|
||||
// uiDefIconTextButS(block, MENU, REDRAWVIEW3D, (ICON_BBOX+G.vd->drawtype-1), "Viewport Shading%t|Bounding Box %x1|Wireframe %x2|Solid %x3|Shaded %x4|Textured %x5",
|
||||
// xco,0,124,20, &(G.vd->drawtype), 0, 0, 0, 0, "Viewport Shading");
|
||||
// uiDefButS(block, MENU, REDRAWVIEW3D, "Viewport Shading%t|Bounding Box %x1|Wireframe %x2|Solid %x3|Shaded %x4|Textured %x5",
|
||||
// xco,0,110,20, &(G.vd->drawtype), 0, 0, 0, 0, "Viewport Shading");
|
||||
|
||||
uiDefButS(block, MENU, REDRAWVIEW3D, "Viewport Shading%t|Bounding Box %x1|Wireframe %x2|Solid %x3|Shaded %x4|Textured %x5",
|
||||
xco,0,110,20, &(G.vd->drawtype), 0, 0, 0, 0, "Viewport Shading");
|
||||
|
||||
xco+=110;
|
||||
|
||||
xco+= 14;
|
||||
xco+= XIC+10;
|
||||
/* LAYERS */
|
||||
if(G.vd->localview==0) {
|
||||
|
||||
@@ -6630,10 +6629,11 @@ void view3d_buttons(void)
|
||||
else xco+= (10+1)*(XIC/2)+10+4;
|
||||
|
||||
/* VIEWMOVE */
|
||||
|
||||
/*
|
||||
uiDefIconButI(block, TOG, B_VIEWTRANS, ICON_VIEWMOVE, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Translates view (SHIFT+MiddleMouse)");
|
||||
uiDefIconButI(block, TOG, B_VIEWZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zooms view (CTRL+MiddleMouse)");
|
||||
|
||||
*/
|
||||
|
||||
/* around */
|
||||
xco+= XIC/2;
|
||||
uiDefIconButS(block, ROW, 1, ICON_ROTATE, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 0.0, 0, 0, "Enables Rotation or Scaling around boundbox center (COMMAKEY)");
|
||||
@@ -6641,9 +6641,6 @@ void view3d_buttons(void)
|
||||
uiDefIconButS(block, ROW, 1, ICON_CURSOR, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 1.0, 0, 0, "Enables Rotation or Scaling around cursor (DOTKEY)");
|
||||
uiDefIconButS(block, ROW, 1, ICON_ROTATECOLLECTION, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 2.0, 0, 0, "Enables Rotation or Scaling around individual object centers");
|
||||
|
||||
|
||||
|
||||
|
||||
if(G.vd->bgpic) {
|
||||
xco+= XIC/2;
|
||||
uiDefIconButS(block, TOG|BIT|1, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Displays a Background picture");
|
||||
@@ -7034,11 +7031,11 @@ void buttons_active_id(ID **id, ID **idfrom)
|
||||
else if(tab==TAB_SHADING_TEX) {
|
||||
MTex *mtex;
|
||||
|
||||
// if(G.buts->mainbo != G.buts->mainb) {
|
||||
// if(G.buts->mainbo==BUTS_LAMP) G.buts->texfrom= 2;
|
||||
// else if(G.buts->mainbo==BUTS_WORLD) G.buts->texfrom= 1;
|
||||
// else if(G.buts->mainbo==BUTS_MAT) G.buts->texfrom= 0;
|
||||
// }
|
||||
if(G.buts->mainbo==G.buts->mainb && G.buts->tabo!=tab) {
|
||||
if(G.buts->tabo==TAB_SHADING_LAMP) G.buts->texfrom= 2;
|
||||
else if(G.buts->tabo==TAB_SHADING_WORLD) G.buts->texfrom= 1;
|
||||
else if(G.buts->tabo==TAB_SHADING_MAT) G.buts->texfrom= 0;
|
||||
}
|
||||
|
||||
if(G.buts->texfrom==0) {
|
||||
if(ob && ob->type<OB_LAMP && ob->type) {
|
||||
@@ -7228,14 +7225,14 @@ void buts_buttons(void)
|
||||
/* mainb menu */
|
||||
/* (this could be done later with a dynamic tree and branches, also for python) */
|
||||
uiBlockSetCol(block, MIDGREY);
|
||||
uiBlockSetEmboss(block, UI_EMBOSST);
|
||||
uiBlockSetEmboss(block, UI_EMBOSSMB); // menu but
|
||||
|
||||
{
|
||||
char mainbname[8][12]= {" Scene", " Object", " Types", " Shading", " Editing", " Script", " Logic"};
|
||||
char mainbicon[8]= {ICON_SCENE_DEHLT, ICON_OBJECT, ICON_BBOX, ICON_MATERIAL_DEHLT, ICON_EDIT, ICON_SCRIPT, ICON_GAME};
|
||||
uiBut *but= uiDefIconTextBlockBut(block, sbuts_context_menu, NULL, mainbicon[G.buts->mainb], mainbname[G.buts->mainb], xco, 0, 80, YIC, "Set main context for button panels");
|
||||
uiBut *but= uiDefIconTextBlockBut(block, sbuts_context_menu, NULL, mainbicon[G.buts->mainb], mainbname[G.buts->mainb], xco, 0, 90, YIC, "Set main context for button panels");
|
||||
uiButClearFlag(but, UI_ICON_RIGHT); // this type has both flags set, and draws icon right.. uhh
|
||||
xco+= 80-XIC+10;
|
||||
xco+= 90-XIC+10;
|
||||
}
|
||||
|
||||
/* select the context to be drawn, per contex/tab the actual context is tested */
|
||||
@@ -7447,7 +7444,9 @@ void buts_buttons(void)
|
||||
xco+= 80;
|
||||
#endif
|
||||
|
||||
// memory for finding which texture you'd like to see
|
||||
G.buts->mainbo= G.buts->mainb;
|
||||
G.buts->tabo= G.buts->tab[G.buts->mainb];
|
||||
|
||||
/* always do as last */
|
||||
uiDrawBlock(block);
|
||||
|
||||
@@ -209,7 +209,7 @@ struct uiBlock {
|
||||
int afterval;
|
||||
void *curfont;
|
||||
|
||||
short autofill, flag, win, winq, direction, dt, frontbuf; //frontbuf see below
|
||||
short autofill, flag, win, winq, direction, dt, frontbuf, auto_open; //frontbuf see below
|
||||
void *saveunder;
|
||||
|
||||
float xofs, yofs; // offset to parent button
|
||||
@@ -541,11 +541,11 @@ static void ui_emboss_X(BIFColorID bc, float asp, float x1, float y1, float x2,
|
||||
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
else BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
}
|
||||
|
||||
@@ -553,11 +553,11 @@ static void ui_emboss_X(BIFColorID bc, float asp, float x1, float y1, float x2,
|
||||
glVertex2f(x2,y1);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_GREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
else BIF_set_color(bc, COLORSHADE_GREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_WHITE);
|
||||
BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
}
|
||||
|
||||
@@ -570,20 +570,21 @@ static void ui_emboss_X(BIFColorID bc, float asp, float x1, float y1, float x2,
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_GREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
else BIF_set_color(bc, COLORSHADE_GREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_WHITE);
|
||||
BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
}
|
||||
|
||||
|
||||
glVertex2f(x1,(y2-(y2-y1)/3));
|
||||
glVertex2f(x2,(y2-(y2-y1)/3));
|
||||
glVertex2f(x2,y2);
|
||||
glVertex2f(x1,y2);
|
||||
|
||||
glEnd();
|
||||
|
||||
/* END SHADED BUTTON */
|
||||
|
||||
/* OUTER SUNKEN EFFECT */
|
||||
@@ -707,11 +708,11 @@ static void ui_emboss_TEX(BIFColorID bc, float asp, float x1, float y1, float x2
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
else BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
}
|
||||
|
||||
@@ -789,11 +790,11 @@ static void ui_emboss_NUM(BIFColorID bc, float asp, float x1, float y1, float x2
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
else BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
}
|
||||
|
||||
@@ -911,11 +912,11 @@ static void ui_emboss_MENU(BIFColorID bc, float asp, float x1, float y1, float x
|
||||
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
else BIF_set_color(bc, COLORSHADE_HILITE);
|
||||
}
|
||||
|
||||
@@ -923,11 +924,11 @@ static void ui_emboss_MENU(BIFColorID bc, float asp, float x1, float y1, float x
|
||||
glVertex2f(x2,y1);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_GREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
else BIF_set_color(bc, COLORSHADE_GREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_WHITE);
|
||||
BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
}
|
||||
|
||||
@@ -940,11 +941,11 @@ static void ui_emboss_MENU(BIFColorID bc, float asp, float x1, float y1, float x
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_GREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
else BIF_set_color(bc, COLORSHADE_GREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_WHITE);
|
||||
BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
}
|
||||
|
||||
@@ -1106,11 +1107,11 @@ static void ui_emboss_TABL(BIFColorID bc, float asp, float x1, float y1, float x
|
||||
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LMEDIUM);
|
||||
else BIF_set_color(bc, COLORSHADE_MEDIUM);
|
||||
}
|
||||
|
||||
@@ -1121,11 +1122,11 @@ static void ui_emboss_TABL(BIFColorID bc, float asp, float x1, float y1, float x
|
||||
glVertex2f(x2,y1);
|
||||
|
||||
if(flag & UI_SELECT) {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_GREY);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LGREY);
|
||||
else BIF_set_color(bc, COLORSHADE_GREY);
|
||||
}
|
||||
else {
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
if(flag & UI_ACTIVE) BIF_set_color(bc, COLORSHADE_WHITE);
|
||||
BIF_set_color(bc, COLORSHADE_LIGHT);
|
||||
}
|
||||
|
||||
@@ -1432,12 +1433,19 @@ static void ui_emboss_slider(uiBut *but, float fac)
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
BIF_set_color(BUTGREY, COLORSHADE_MEDIUM);
|
||||
|
||||
if(but->flag & UI_ACTIVE)
|
||||
BIF_set_color(BUTGREY, COLORSHADE_LMEDIUM);
|
||||
else
|
||||
BIF_set_color(BUTGREY, COLORSHADE_MEDIUM);
|
||||
|
||||
|
||||
glVertex2f(x1,y1-4);
|
||||
glVertex2f(x2-h,y1-4);
|
||||
|
||||
BIF_set_color(BUTGREY, COLORSHADE_HILITE);
|
||||
if(but->flag & UI_ACTIVE)
|
||||
BIF_set_color(BUTGREY, COLORSHADE_LIGHT);
|
||||
else
|
||||
BIF_set_color(BUTGREY, COLORSHADE_HILITE);
|
||||
|
||||
glVertex2f(x2-h,y2+2);
|
||||
glVertex2f(x1,y2+2);
|
||||
@@ -2095,6 +2103,14 @@ static int roundboxtype= 15;
|
||||
void uiSetRoundBox(int type)
|
||||
{
|
||||
roundboxtype= type;
|
||||
|
||||
/* flags to set which corners will become rounded:
|
||||
|
||||
1------2
|
||||
| |
|
||||
8------4
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void gl_round_box_topshade(float minx, float miny, float maxx, float maxy, float rad)
|
||||
@@ -2800,7 +2816,7 @@ static void ui_warp_pointer(short x, short y)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ui_do_but_MENU(uiBut *but)
|
||||
static int ui_do_but_MENUo(uiBut *but)
|
||||
{
|
||||
uiBlock *block;
|
||||
ListBase listb={NULL, NULL};
|
||||
@@ -2941,6 +2957,110 @@ static int ui_do_but_MENU(uiBut *but)
|
||||
return event;
|
||||
}
|
||||
|
||||
static int ui_do_but_MENU(uiBut *but)
|
||||
{
|
||||
uiBlock *block;
|
||||
ListBase listb={NULL, NULL};
|
||||
double fvalue;
|
||||
int width, height, a, xmax, starty;
|
||||
short startx;
|
||||
int columns=1, rows=0, boxh, event;
|
||||
short x1, y1;
|
||||
short mval[2];
|
||||
MenuData *md;
|
||||
|
||||
but->flag |= UI_SELECT;
|
||||
ui_draw_but(but);
|
||||
|
||||
block= uiNewBlock(&listb, "menu", UI_EMBOSSP, UI_HELV, but->win);
|
||||
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
|
||||
uiBlockSetCol(block, MENUCOL);
|
||||
|
||||
md= decompose_menu_string(but->str);
|
||||
|
||||
/* columns and row calculation */
|
||||
columns= (md->nitems+20)/20;
|
||||
if (columns<1) columns= 1;
|
||||
|
||||
rows= (int) md->nitems/columns;
|
||||
if (rows<1) rows= 1;
|
||||
|
||||
while (rows*columns<md->nitems) rows++;
|
||||
|
||||
/* size and location */
|
||||
if(md->title)
|
||||
width= 2*strlen(md->title)+BIF_GetStringWidth(block->curfont, md->title, (U.transopts & TR_MENUS));
|
||||
else
|
||||
width= 0;
|
||||
|
||||
for(a=0; a<md->nitems; a++) {
|
||||
xmax= BIF_GetStringWidth(block->curfont, md->items[a].str, (U.transopts & TR_MENUS));
|
||||
if(xmax>width) width= xmax;
|
||||
}
|
||||
|
||||
width+= 10;
|
||||
if (width<50) width=50;
|
||||
|
||||
boxh= TBOXH;
|
||||
|
||||
height= rows*boxh;
|
||||
if (md->title) height+= boxh;
|
||||
|
||||
getmouseco_sc(mval);
|
||||
|
||||
/* find active item */
|
||||
fvalue= ui_get_but_val(but);
|
||||
for(a=0; a<md->nitems; a++) {
|
||||
if( md->items[a].retval== (int)fvalue ) break;
|
||||
}
|
||||
/* no active item? */
|
||||
if(a==md->nitems) {
|
||||
if(md->title) a= -1;
|
||||
else a= 0;
|
||||
}
|
||||
|
||||
/* here we go! */
|
||||
startx= but->x1;
|
||||
starty= but->y1;
|
||||
|
||||
if(md->title) {
|
||||
uiBut *bt;
|
||||
uiSetCurFont(block, block->font+1);
|
||||
bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiSetCurFont(block, block->font);
|
||||
bt->flag= UI_TEXT_LEFT;
|
||||
}
|
||||
|
||||
for(a=0; a<md->nitems; a++) {
|
||||
|
||||
x1= but->x1 + width*((int)a/rows);
|
||||
y1= but->y1 - boxh*(a%rows) + (rows-1)*boxh;
|
||||
|
||||
if (strcmp(md->items[a].str, "%l")==0) {
|
||||
uiDefBut(block, SEPR, B_NOP, "", x1, y1,(short)(width-(rows>1)), (short)(boxh-1), NULL, 0.0, 0.0, 0, 0, "");
|
||||
}
|
||||
else {
|
||||
uiDefBut(block, BUTM|but->pointype, but->retval, md->items[a].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), but->poin, (float) md->items[a].retval, 0.0, 0, 0, "");
|
||||
}
|
||||
}
|
||||
|
||||
ui_positionblock(block, but);
|
||||
block->win= G.curscreen->mainwin;
|
||||
event= uiDoBlocks(&listb, 0);
|
||||
|
||||
menudata_free(md);
|
||||
|
||||
but->flag &= ~UI_SELECT;
|
||||
ui_check_but(but);
|
||||
ui_draw_but(but);
|
||||
|
||||
uibut_do_func(but);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************* EVENTS ************* */
|
||||
|
||||
void uiGetMouse(int win, short *adr)
|
||||
@@ -4215,7 +4335,10 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent)
|
||||
break;
|
||||
|
||||
case BLOCK:
|
||||
if(uevent->val) retval= ui_do_but_BLOCK(but);
|
||||
if(uevent->val) {
|
||||
retval= ui_do_but_BLOCK(but);
|
||||
block->auto_open= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTM:
|
||||
@@ -4606,11 +4729,15 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
|
||||
but->flag &= ~UI_ACTIVE;
|
||||
if(but->type != LABEL && but->embossfunc != ui_emboss_N) ui_draw_but(but);
|
||||
}
|
||||
else if(but->type==BLOCK ) { // automatic opens block button (pulldown)
|
||||
else if(but->type==BLOCK || but->type==MENU) { // automatic opens block button (pulldown)
|
||||
int time;
|
||||
for (time= 0; time<10; time++) {
|
||||
|
||||
if(block->auto_open) time= 7;
|
||||
else time= 0;
|
||||
|
||||
for (; time<10; time++) {
|
||||
if (anyqtest()) break;
|
||||
else PIL_sleep_ms(20);
|
||||
else PIL_sleep_ms(40);
|
||||
}
|
||||
if(time==10) ui_do_button(block, but, uevent);
|
||||
}
|
||||
@@ -4908,7 +5035,8 @@ int uiDoBlocks(ListBase *lb, int event)
|
||||
if(block==NULL || (block->flag & UI_BLOCK_LOOP)==0) cont= 0;
|
||||
|
||||
while( (block= lb->first) && (block->flag & UI_BLOCK_LOOP)) {
|
||||
|
||||
block->auto_open= 1;
|
||||
|
||||
/* this here, for menu buts */
|
||||
if(block->flag & UI_BLOCK_REDRAW) {
|
||||
|
||||
@@ -5421,6 +5549,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
|
||||
else if(block->dt==UI_EMBOSSTABL) but->embossfunc= ui_emboss_TABL;
|
||||
else if(block->dt==UI_EMBOSSTABM) but->embossfunc= ui_emboss_TABM;
|
||||
else if(block->dt==UI_EMBOSSTABR) but->embossfunc= ui_emboss_TABR;
|
||||
else if(block->dt==UI_EMBOSSMB) but->embossfunc= ui_emboss_MENU;
|
||||
else but->embossfunc= ui_emboss_N;
|
||||
|
||||
but->pos= -1; /* cursor invisible */
|
||||
|
||||
@@ -124,7 +124,8 @@ static unsigned char *get_color(BIFColorID colorid, BIFColorShade shade)
|
||||
{
|
||||
int coloridx= colorid-BIFCOLORID_FIRST;
|
||||
int shadeidx= shade-BIFCOLORSHADE_FIRST;
|
||||
if (coloridx>=0 && coloridx<BIFNCOLORIDS && shadeidx>=0&& shadeidx<BIFNCOLORSHADES) {
|
||||
|
||||
if (coloridx>=0 && coloridx<BIFNCOLORIDS && shadeidx>=0 && shadeidx<BIFNCOLORSHADES) {
|
||||
return common_colors_arr[coloridx].cols[shadeidx];
|
||||
} else {
|
||||
static unsigned char errorcol[3]= {0xFF, 0x33, 0x33};
|
||||
@@ -143,6 +144,7 @@ static void rgbaCCol_addNT(unsigned char *t, unsigned char *a, int N)
|
||||
t[0]= colclamp(a[0]+N);
|
||||
t[1]= colclamp(a[1]+N);
|
||||
t[2]= colclamp(a[2]+N);
|
||||
|
||||
}
|
||||
static void def_col(BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
@@ -151,9 +153,9 @@ static void def_col(BIFColorID colorid, unsigned char r, unsigned char g, unsign
|
||||
unsigned char col[3];
|
||||
|
||||
col[0]= r, col[1]= g, col[2]= b;
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_WHITE), col, 60);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_LIGHT), col, 35);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_HILITE), col, 20);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_WHITE), col, 70);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_LIGHT), col, 45);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_HILITE), col, 25);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_LMEDIUM), col, 10);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_MEDIUM), col, 0);
|
||||
rgbaCCol_addNT(get_color(colorid, COLORSHADE_LGREY), col, -20);
|
||||
|
||||
Reference in New Issue
Block a user