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>2009-05-15 15:19:59 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-05-15 15:19:59 +0400
commitb4d46e5dedfa88951558a4f941d987a171594a0a (patch)
tree4de559356ab0ac6135f5a1abbbdb60eb1134ffca /source/blender/editors/screen/area.c
parent2df94626c483c9b522e347ecc792c634fdec420a (diff)
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed. This means the layout engine now works at button level, and makes it easier to write templates. Otherwise you had to store all info and create the buttons later. * Added interface_templates.c as a separate file to put templates in. These can contain regular buttons, and can be put in a Free layout, which means you can specify manual coordinates, but still get nested correct inside other layouts. * API was changed to allow better nesting. Previously items were added in the last added layout specifier, i.e. one level up in the layout hierarchy. This doesn't work well in always, so now when creating things like rows or columns it always returns a layout which you have to add the items in. All py scripts were updated to follow this. * Computing the layout now goes in two passes, first estimating the required width/height of all nested layouts, and then in the second pass using the results of that to decide on the actual locations. * Enum and array buttons now follow the direction of the layout, i.e. they are vertical or horizontal depending if they are in a column or row. * Color properties now get a color picker, and only get the additional RGB sliders with Expand=True. * File/directory string properties now get a button next to them for opening the file browse, though this is not implemented yet. * Layout items can now be aligned, set align=True when creating a column, row, etc. * Buttons now get a minimum width of one icon (avoids squashing icon buttons). * Moved some more space variables into Style.
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r--source/blender/editors/screen/area.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 6b7b7a914f4..e344a177517 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -31,6 +31,9 @@
#include "MEM_guardedalloc.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_rand.h"
@@ -955,3 +958,128 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
return xco;
}
+/************************ standard UI regions ************************/
+
+void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context)
+{
+ uiStyle *style= U.uistyles.first;
+ uiBlock *block;
+ PanelType *pt;
+ Panel *panel;
+ float col[3];
+ int xco, yco, x, y, w, em, header;
+
+ header= 20; // XXX
+ x= style->panelouter;
+ y= -(header + style->panelouter);
+
+ /* clear */
+ UI_GetThemeColor3fv(TH_BACK, col);
+ glClearColor(col[0], col[1], col[2], 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* set view2d view matrix for scrolling (without scrollers) */
+ UI_view2d_view_ortho(C, &ar->v2d);
+
+ /* create panels */
+ uiBeginPanels(C, ar);
+
+ for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
+ /* verify context */
+ if(context)
+ if(!pt->context || strcmp(context, pt->context) != 0)
+ continue;
+
+ /* draw panel */
+ if(pt->draw && (!pt->poll || pt->poll(C, pt))) {
+ block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
+ panel= uiBeginPanel(ar, block, pt);
+
+ if(panel) {
+ if(vertical) {
+ w= (ar->type->minsizex)? ar->type->minsizex-12: uiBlockAspect(block)*ar->winx-12;
+ em= (ar->type->minsizex)? 10: 20;
+ }
+ else {
+ w= (ar->type->minsizex)? ar->type->minsizex-12: UI_PANEL_WIDTH-12;
+ em= (ar->type->minsizex)? 10: 20;
+ }
+
+ panel->type= pt;
+ panel->layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
+ style->panelspace, 0, w-2*style->panelspace, em, style);
+
+ pt->draw(C, panel);
+
+ uiBlockLayoutResolve(C, block, &xco, &yco);
+ uiEndPanel(block, w, -yco + 12);
+ panel->layout= NULL;
+ }
+ else {
+ w= header;
+ yco= header;
+ }
+
+ uiEndBlock(C, block);
+
+ if(vertical)
+ y += yco+style->panelouter;
+ else
+ x += w+style->panelouter;
+ }
+ }
+
+ uiEndPanels(C, ar);
+
+ /* restore view matrix? */
+ UI_view2d_view_restore(C);
+}
+
+void ED_region_header(const bContext *C, ARegion *ar)
+{
+ uiStyle *style= U.uistyles.first;
+ uiBlock *block;
+ uiLayout *layout;
+ HeaderType *ht;
+ Header header = {0};
+ float col[3];
+ int xco, yco;
+
+ /* clear */
+ if(ED_screen_area_active(C))
+ UI_GetThemeColor3fv(TH_HEADER, col);
+ else
+ UI_GetThemeColor3fv(TH_HEADERDESEL, col);
+
+ glClearColor(col[0], col[1], col[2], 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* set view2d view matrix for scrolling (without scrollers) */
+ UI_view2d_view_ortho(C, &ar->v2d);
+
+ xco= 8;
+ yco= HEADERY-3;
+
+ /* draw all headers types */
+ for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
+ block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
+ layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, HEADERY-6, 1, style);
+
+ if(ht->draw) {
+ header.type= ht;
+ header.layout= layout;
+ ht->draw(C, &header);
+ }
+
+ uiBlockLayoutResolve(C, block, &xco, &yco);
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+ }
+
+ /* always as last */
+ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
+
+ /* restore view matrix? */
+ UI_view2d_view_restore(C);
+}
+