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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-11 21:31:32 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-11 21:31:32 +0300
commit78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (patch)
tree48258a995237f8eb4e222784bf27ec41973ab6c2 /source/blender/editors/interface/resources.c
parent44f94f7927a2becf40e50a105b4c18f0a36f5341 (diff)
Port of part of the Interface code to 2.50.
This is based on the current trunk version, so these files should not need merges. There's two things (clipboard and intptr_t) that are missing in 2.50 and commented out with XXX 2.48, these can be enabled again once trunk is merged into this branch. Further this is not all interface code, there are many parts commented out: * interface.c: nearly all button types, missing: links, chartab, keyevent. * interface_draw.c: almost all code, with some small exceptions. * interface_ops.c: this replaces ui_do_but and uiDoBlocks with two operators, making it non-blocking. * interface_regions: this is a part of interface.c, split off, contains code to create regions for tooltips, menus, pupmenu (that one is crashing currently), color chooser, basically regions with buttons which is fairly independent of core interface code. * interface_panel.c and interface_icons.c: not ported over, so no panels and icons yet. Panels should probably become (free floating) regions? * text.c: (formerly language.c) for drawing text and translation. this works but is using bad globals still and could be cleaned up. Header Files: * ED_datafiles.h now has declarations for datatoc_ files, so those extern declarations can be #included instead of repeated. * The user interface code is in UI_interface.h and other UI_* files. Core: * The API for creating blocks, buttons, etc is nearly the same still. Blocks are now created per region instead of per area. * The code was made non-blocking, which means that any changes and redraws should be possible while editing a button. That means though that we need some sort of persistence even though the blender model is to recreate buttons for each redraw. So when a new block is created, some matching happens to find out which buttons correspond to buttons in the previously created block, and for activated buttons some data is then copied over to the new button. * Added UI_init/UI_init_userdef/UI_exit functions that should initialize code in this module, instead of multiple function calls in the windowmanager. * Removed most static/globals from interface.c. * Removed UIafterfunc_ I don't think it's needed anymore, and not sure how it would integrate here? * Currently only full window redraws are used, this should become per region and maybe per button later. Operators: * Events are currently handled through two operators: button activate and menu handle. Operators may not be the best way to implement this, since there are currently some issues with events being missed, but they can become a special handler type instead, this should not be a big change. * The button activate operator runs as long as a button is active, and will handle all interaction with that button until the button is not activated anymore. This means clicking, text editing, number dragging, opening menu blocks, etc. * Since this operator has to be non-blocking, the ui_do_but code needed to made non-blocking. That means variables that were previously on the stack, now need to be stored away in a struct such that they can be accessed again when the operator receives more events. * Additionally the place in the ui_do_but code indicated the state, now that needs to be set explicit in order to handle the right events in the right state. So an activated button can be in one of these states: init, highlight, wait_flash, wait_release, wait_key_event, num_editing, text_editing, text_selecting, block_open, exit. * For each button type an ui_apply_but_* function has also been separated out from ui_do_but. This makes it possible to continuously apply the button as text is being typed for example, and there is an option in the code to enable this. Since the code non-blocking and can deal with the button being deleted even, it should be safe to do this. * When editing text, dragging numbers, etc, the actual data (but->poin) is not being edited, since that would mean data is being edited without correct updates happening, while some other part of blender may be accessing that data in the meantime. So data values, strings, vectors are written to a temporary location and only flush in the apply function. Regions: * Menus, color chooser, tooltips etc all create screen level regions. Such menu blocks give a handle to the button that creates it, which will contain the results of the menu block once a MESSAGE event is received from that menu block. * For this type of menu block the coordinates used to be in window space. They are still created that way and ui_positionblock still works with window coordinates, but after that the block and buttons are brought back to region coordinates since these are now contained in a region. * The flush/overdraw frontbuffer drawing code was removed, the windowmanager should have enough information with these screen level regions to have full control over what gets drawn when and to then do correct compositing. Testing: * The header in the time space currently has some buttons to test the UI code.
Diffstat (limited to 'source/blender/editors/interface/resources.c')
-rw-r--r--source/blender/editors/interface/resources.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 4bbf2a64b53..bfb2d39fbb5 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -51,8 +51,9 @@
#include "BKE_utildefines.h"
#include "BIF_gl.h"
-#include "BIF_resources.h"
-#include "BIF_interface_icons.h"
+
+#include "UI_resources.h"
+//#include "UI_icons.h"
#include "BLI_blenlib.h"
@@ -63,14 +64,14 @@ static bTheme *theme_active=NULL;
static int theme_spacetype= SPACE_VIEW3D;
-void BIF_resources_init(void)
+void ui_resources_init(void)
{
- BIF_icons_init(BIFICONID_LAST+1);
+ // XXX 2.50 missing UI_icons_init(BIFICONID_LAST+1);
}
-void BIF_resources_free(void)
+void ui_resources_free(void)
{
- BIF_icons_free();
+ // XXX 2.50 missing UI_icons_free();
}
@@ -78,7 +79,7 @@ void BIF_resources_free(void)
/* THEMES */
/* ******************************************************** */
-char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
+char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
{
ThemeSpace *ts= NULL;
static char error[4]={240, 0, 240, 255};
@@ -328,7 +329,7 @@ char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
Note: when you add new colors, created & saved themes need initialized
in usiblender.c, search for "versionfile"
*/
-void BIF_InitTheme(void)
+void ui_theme_init_userdef(void)
{
bTheme *btheme= U.themes.first;
@@ -343,7 +344,7 @@ void BIF_InitTheme(void)
strcpy(btheme->name, "Default");
}
- BIF_SetTheme(NULL); // make sure the global used in this file is set
+ UI_SetTheme(NULL); // make sure the global used in this file is set
/* UI buttons (todo) */
SETCOL(btheme->tui.outline, 0xA0,0xA0,0xA0, 255);
@@ -542,7 +543,7 @@ void BIF_InitTheme(void)
}
-char *BIF_ThemeColorsPup(int spacetype)
+char *UI_ThemeColorsPup(int spacetype)
{
char *cp= MEM_callocN(32*32, "theme pup");
char *str = cp;
@@ -713,7 +714,7 @@ char *BIF_ThemeColorsPup(int spacetype)
return cp;
}
-void BIF_SetTheme(ScrArea *sa)
+void UI_SetTheme(ScrArea *sa)
{
if(sa==NULL) { // called for safety, when delete themes
theme_active= U.themes.first;
@@ -728,32 +729,32 @@ void BIF_SetTheme(ScrArea *sa)
}
// for space windows only
-void BIF_ThemeColor(int colorid)
+void UI_ThemeColor(int colorid)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor3ub(cp[0], cp[1], cp[2]);
}
// plus alpha
-void BIF_ThemeColor4(int colorid)
+void UI_ThemeColor4(int colorid)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor4ub(cp[0], cp[1], cp[2], cp[3]);
}
// set the color with offset for shades
-void BIF_ThemeColorShade(int colorid, int offset)
+void UI_ThemeColorShade(int colorid, int offset)
{
int r, g, b;
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r= offset + (int) cp[0];
CLAMP(r, 0, 255);
g= offset + (int) cp[1];
@@ -763,12 +764,12 @@ void BIF_ThemeColorShade(int colorid, int offset)
//glColor3ub(r, g, b);
glColor4ub(r, g, b, cp[3]);
}
-void BIF_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
+void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
{
int r, g, b, a;
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r= coloffset + (int) cp[0];
CLAMP(r, 0, 255);
g= coloffset + (int) cp[1];
@@ -781,13 +782,13 @@ void BIF_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
}
// blend between to theme colors, and set it
-void BIF_ThemeColorBlend(int colorid1, int colorid2, float fac)
+void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
{
int r, g, b;
char *cp1, *cp2;
- cp1= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
- cp2= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+ cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
r= floor((1.0-fac)*cp1[0] + fac*cp2[0]);
@@ -798,13 +799,13 @@ void BIF_ThemeColorBlend(int colorid1, int colorid2, float fac)
}
// blend between to theme colors, shade it, and set it
-void BIF_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
+void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
int r, g, b;
char *cp1, *cp2;
- cp1= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
- cp2= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+ cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
@@ -819,65 +820,65 @@ void BIF_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
}
// get individual values, not scaled
-float BIF_GetThemeValuef(int colorid)
+float UI_GetThemeValuef(int colorid)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((float)cp[0]);
}
// get individual values, not scaled
-int BIF_GetThemeValue(int colorid)
+int UI_GetThemeValue(int colorid)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((int) cp[0]);
}
// get the color, range 0.0-1.0
-void BIF_GetThemeColor3fv(int colorid, float *col)
+void UI_GetThemeColor3fv(int colorid, float *col)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= ((float)cp[0])/255.0;
col[1]= ((float)cp[1])/255.0;
col[2]= ((float)cp[2])/255.0;
}
// get the color, in char pointer
-void BIF_GetThemeColor3ubv(int colorid, char *col)
+void UI_GetThemeColor3ubv(int colorid, char *col)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= cp[0];
col[1]= cp[1];
col[2]= cp[2];
}
// get the color, in char pointer
-void BIF_GetThemeColor4ubv(int colorid, char *col)
+void UI_GetThemeColor4ubv(int colorid, char *col)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= cp[0];
col[1]= cp[1];
col[2]= cp[2];
col[3]= cp[3];
}
-void BIF_GetThemeColorType4ubv(int colorid, int spacetype, char *col)
+void UI_GetThemeColorType4ubv(int colorid, int spacetype, char *col)
{
char *cp;
- cp= BIF_ThemeGetColorPtr(theme_active, spacetype, colorid);
+ cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
col[0]= cp[0];
col[1]= cp[1];
col[2]= cp[2];
@@ -885,7 +886,7 @@ void BIF_GetThemeColorType4ubv(int colorid, int spacetype, char *col)
}
// blends and shades between two char color pointers
-void BIF_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset)
+void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset)
{
int r, g, b;
@@ -902,7 +903,7 @@ void BIF_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset)
}
// get a 3 byte color, blended and shaded between two other char color pointers
-void BIF_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset)
+void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset)
{
int r, g, b;
@@ -919,3 +920,4 @@ void BIF_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, i
col[1] = g;
col[2] = b;
}
+