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>2011-11-20 18:31:01 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-20 18:31:01 +0400
commitd4c400b940f862f28d7af5bd7e59ce7f14025735 (patch)
tree545a9d68173a99dceaf6d783dd51db064f428b7a
parent17b113c784aa30cf7ea06f0970a4427620fef4dc (diff)
UI: fix issue with part of panels going offscreen after recent commit.
The code here was tricky, with ED_region_panels trying to match the complex logic in uiAlignPanelStep, now refactored the code so it's avoided.
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface_panel.c39
-rw-r--r--source/blender/editors/screen/area.c42
3 files changed, 48 insertions, 36 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 01273b291a2..a0b477413e4 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -592,7 +592,8 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname);
* not clear yet so we postpone that. */
void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
-void uiEndPanels(const struct bContext *C, struct ARegion *ar);
+void uiEndPanels(const struct bContext *C, struct ARegion *ar, int *x, int *y);
+void uiDrawPanels(const struct bContext *C, struct ARegion *ar);
struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
void uiEndPanel(uiBlock *block, int width, int height);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index ad79e550575..d66e6852f1d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -779,6 +779,35 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
return done;
}
+static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
+{
+ Panel *pa;
+ int align= panel_aligned(sa, ar);
+ int sizex = UI_PANEL_WIDTH;
+ int sizey = UI_PANEL_WIDTH;
+
+ /* compute size taken up by panels, for setting in view2d */
+ for(pa= ar->panels.first; pa; pa= pa->next) {
+ if(pa->runtime_flag & PNL_ACTIVE) {
+ int pa_sizex, pa_sizey;
+
+ if(align==BUT_VERTICAL) {
+ pa_sizex= pa->ofsx + pa->sizex;
+ pa_sizey= get_panel_real_ofsy(pa);
+ }
+ else {
+ pa_sizex= get_panel_real_ofsx(pa) + pa->sizex;
+ pa_sizey= pa->ofsy + get_panel_size_y(pa);
+ }
+
+ sizex= MAX2(sizex, pa_sizex);
+ sizey= MIN2(sizey, pa_sizey);
+ }
+ }
+
+ *x= sizex;
+ *y= sizey;
+}
static void ui_do_animate(const bContext *C, Panel *panel)
{
@@ -818,7 +847,7 @@ void uiBeginPanels(const bContext *UNUSED(C), ARegion *ar)
}
/* only draws blocks with panels */
-void uiEndPanels(const bContext *C, ARegion *ar)
+void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
{
ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
@@ -871,6 +900,14 @@ void uiEndPanels(const bContext *C, ARegion *ar)
if(firstpa)
firstpa->runtime_flag |= PNL_FIRST;
+
+ /* compute size taken up by panel */
+ ui_panels_size(sa, ar, x, y);
+}
+
+void uiDrawPanels(const bContext *C, ARegion *ar)
+{
+ uiBlock *block;
UI_ThemeClearColor(TH_BACK);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4a06ee6d0ae..f3d087d6986 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1559,7 +1559,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
Panel *panel;
View2D *v2d= &ar->v2d;
View2DScrollers *scrollers;
- int xco, yco, x, y, miny=0, w, em, header, triangle, open, newcontext= 0;
+ int x, y, xco, yco, w, em, triangle, open, newcontext= 0;
if(contextnr >= 0)
newcontext= UI_view2d_tab_set(v2d, contextnr);
@@ -1573,9 +1573,6 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y;
}
- x= 0;
- y= 0;
-
/* create panels */
uiBeginPanels(C, ar);
@@ -1594,16 +1591,12 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
panel= uiBeginPanel(sa, ar, block, pt, &open);
/* bad fixed values */
- header= (pt->flag & PNL_NO_HEADER)? 0: UI_UNIT_Y;
triangle= (int)(UI_UNIT_Y * 1.1f);
- if(vertical)
- y -= header;
-
- if(pt->draw_header && header && (open || vertical)) {
+ if(pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
/* for enabled buttons */
panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
- triangle, header+style->panelspace, header, 1, style);
+ triangle, UI_UNIT_Y+style->panelspace, UI_UNIT_Y, 1, style);
pt->draw_header(C, panel);
@@ -1641,30 +1634,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
}
uiEndBlock(C, block);
-
- if(vertical) {
- if(pt->flag & PNL_NO_HEADER)
- y += yco;
- else
- y += yco;
- }
- else {
- x += w;
- miny= MIN2(y, yco-header);
- }
}
}
- if(vertical)
- x += w;
- else
- y= miny;
-
- /* in case there are no panels */
- if(x == 0 || y == 0) {
- x= UI_PANEL_WIDTH;
- y= UI_PANEL_WIDTH;
- }
+ /* align panels and return size */
+ uiEndPanels(C, ar, &x, &y);
/* clear */
UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW)?TH_PREVIEW_BACK:TH_BACK);
@@ -1706,9 +1680,9 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
/* set the view */
UI_view2d_view_ortho(v2d);
- /* this does the actual drawing! */
- uiEndPanels(C, ar);
-
+ /* draw panels */
+ uiDrawPanels(C, ar);
+
/* restore view matrix */
UI_view2d_view_restore(C);