popup menus behave poorly when they have not enough width for all their columns #39234

Closed
opened 2014-03-17 20:37:34 +01:00 by Alexandros Alexandrou · 20 comments

System Information
Ubuntu 12.04

Blender Version
Broken: 2.70 RC 2

Short description of error
When "Undo History" popup is filled, some items are not shown because of insufficient screen space. I don't think it is a bug, but just an inconsistency.

Probable solution
In case items need more space than screen can provide them, a slider or an arrow could be added, so remaining items can be seen and selected.

Exact steps for others to reproduce the error

  1. Set "Undo Steps" in "User Preferences" to 64.
  2. Make 64 steps, of which at least one has a long name (so the problem is visible).
  3. Go to "Undo History" and you will see the following. screen2.png
**System Information** Ubuntu 12.04 **Blender Version** Broken: 2.70 RC 2 **Short description of error** When "Undo History" popup is filled, some items are not shown because of insufficient screen space. I don't think it is a bug, but just an inconsistency. **Probable solution** In case items need more space than screen can provide them, a slider or an arrow could be added, so remaining items can be seen and selected. **Exact steps for others to reproduce the error** 1. Set "Undo Steps" in "User Preferences" to 64. 2. Make 64 steps, of which at least one has a long name (so the problem is visible). 3. Go to "Undo History" and you will see the following. ![screen2.png](https://archive.blender.org/developer/F81621/screen2.png)

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @alex1

Added subscriber: @alex1

Added subscriber: @mont29

Added subscriber: @mont29

Can’t reproduce such issue error here, I just get up/down arrows…

What is your screen definition? looks very small (I tried here with a Blender window less than 800*600 and still could show the four columns, even with a quite long op name).

Can’t reproduce such issue error here, I just get up/down arrows… What is your screen definition? looks *very* small (I tried here with a Blender window less than 800*600 and still could show the four columns, even with a quite long op name).

My screen resolution is 1280x800.

Sure, up/down arrows appear on menus with height exceeding Blender window height. But such arrows do not appear on "Undo History" popup, which was what I had pointed out. In fact, some items can't be accessed and an arrow or a slider is needed there.

My screen resolution is 1280x800. Sure, up/down arrows appear on menus with height exceeding Blender window height. But such arrows do not appear on "Undo History" popup, which was what I had pointed out. In fact, some items can't be accessed and an arrow or a slider is needed there.

Ok, could reproduce it by setting a much bigger DPI size… We might enhance behavior of that kind of popup in two ways, imho:

  • Do not set same width for all columns!
  • Reduce number of columns when there is not enough width.

Will have a look at what we can do here.

Ok, could reproduce it by setting a much bigger DPI size… We might enhance behavior of that kind of popup in two ways, imho: * Do not set same width for all columns! * Reduce number of columns when there is not enough width. Will have a look at what we can do here.
Bastien Montagne self-assigned this 2014-03-19 20:28:41 +01:00
Bastien Montagne changed title from When "Undo History" popup is filled, some items are hidden to popup menus behave poorly when they have not enough width for all their columns 2014-03-19 20:29:41 +01:00

Added subscriber: @brecht

Added subscriber: @brecht

Following patch "fixes" the issue by:

  • Not having constant width for all columns, but adapt each to its content's width;
  • Adapting undo' menu height to undo list length (so that we never have more than three columns).

It is still possible to get issues in extreme cases (small screen, high DPI size, long op names), but this should now be rare corner cases.

I also fixed a minor glitch with undo menu (first column had one item less than the others…).

@brecht would need your green light here before I commit, since column width change will also affect menus like modifiers or node sockets ones (imho it’s better now, wastes less space, but…). :)

P37: Fix #39234

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7e6e00b..5622288 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -207,43 +207,41 @@ void ui_block_translate(uiBlock *block, int x, int y)
 static void ui_text_bounds_block(uiBlock *block, float offset)
 {
        uiStyle *style = UI_GetStyle();
-       uiBut *bt;
-       int i = 0, j, x1addval = offset, nextcol;
-       int lastcol = 0, col = 0;
-       
+       uiBut *bt, *init_col_bt, *col_bt;
+       int i = 0, j, x1addval = offset;
+
        uiStyleFontSet(&style->widget);
-       
-       for (bt = block->buttons.first; bt; bt = bt->next) {
+
+       for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) {
                if (!ELEM(bt->type, SEPR, SEPRLINE)) {
                        j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
 
-                       if (j > i) i = j;
+                       if (j > i)
+                               i = j;
                }
 
-               if (bt->next && bt->rect.xmin < bt->next->rect.xmin)
-                       lastcol++;
-       }
+               if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
+                       /* End of this column, and it’s not the last one. */
+                       for (col_bt = init_col_bt; col_bt->prev != bt; col_bt = col_bt->next) {
+                               col_bt->rect.xmin = x1addval;
+                               col_bt->rect.xmax = x1addval + i + block->bounds;
 
-       /* cope with multi collumns */
-       bt = block->buttons.first;
-       while (bt) {
-               nextcol = (bt->next && bt->rect.xmin < bt->next->rect.xmin);
-               
-               bt->rect.xmin = x1addval;
-               bt->rect.xmax = bt->rect.xmin + i + block->bounds;
-               
-               if (col == lastcol) {
-                       bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds);
-               }
+                               ui_check_but(col_bt);  /* clips text again */
+                       }
 
-               ui_check_but(bt);  /* clips text again */
-               
-               if (nextcol) {
+                       /* And we prepare next column. */
                        x1addval += i + block->bounds;
-                       col++;
+                       i = 0;
+                       init_col_bt = col_bt;
                }
-               
-               bt = bt->next;
+       }
+
+       /* Last column. */
+       for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) {
+               col_bt->rect.xmin = x1addval;
+               col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds);
+
+               ui_check_but(col_bt);  /* clips text again */
        }
 }
 
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 434f1e3..733b45f 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -533,14 +533,20 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
                        uiLayout *layout = uiPupMenuLayout(pup);
                        uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
                        uiLayout *column = NULL;
+                       const int col_size = 20 + totitem / 12;
                        int i, c;
+                       bool add_col = true;
                        
-                       for (c = 0, i = totitem - 1; i >= 0; i--, c++) {
-                               if ( (c % 20) == 0)
+                       for (c = 0, i = totitem; i--;) {
+                               if (add_col && !(c % col_size)) {
                                        column = uiLayoutColumn(split, false);
-                               if (item- [x].identifier)
+                                       add_col = false;
+                               }
+                               if (item- [x].identifier) {
                                        uiItemIntO(column, item- [x].name, item- [x].icon, op->type->idname, "item", item- [x].value);
-                               
+                                       ++c;
+                                       add_col = true;
+                               }
                        }
                        
                        MEM_freeN(item);

Following patch "fixes" the issue by: * Not having constant width for all columns, but adapt each to its content's width; * Adapting undo' menu height to undo list length (so that we never have more than three columns). It is still possible to get issues in extreme cases (small screen, high DPI size, long op names), but this should now be rare corner cases. I also fixed a minor glitch with undo menu (first column had one item less than the others…). @brecht would need your green light here before I commit, since column width change will also affect menus like modifiers or node sockets ones (imho it’s better now, wastes less space, but…). :) [P37: Fix #39234](https://archive.blender.org/developer/P37.txt) ```diff diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7e6e00b..5622288 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -207,43 +207,41 @@ void ui_block_translate(uiBlock *block, int x, int y) static void ui_text_bounds_block(uiBlock *block, float offset) { uiStyle *style = UI_GetStyle(); - uiBut *bt; - int i = 0, j, x1addval = offset, nextcol; - int lastcol = 0, col = 0; - + uiBut *bt, *init_col_bt, *col_bt; + int i = 0, j, x1addval = offset; + uiStyleFontSet(&style->widget); - - for (bt = block->buttons.first; bt; bt = bt->next) { + + for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) { if (!ELEM(bt->type, SEPR, SEPRLINE)) { j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr)); - if (j > i) i = j; + if (j > i) + i = j; } - if (bt->next && bt->rect.xmin < bt->next->rect.xmin) - lastcol++; - } + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) { + /* End of this column, and it’s not the last one. */ + for (col_bt = init_col_bt; col_bt->prev != bt; col_bt = col_bt->next) { + col_bt->rect.xmin = x1addval; + col_bt->rect.xmax = x1addval + i + block->bounds; - /* cope with multi collumns */ - bt = block->buttons.first; - while (bt) { - nextcol = (bt->next && bt->rect.xmin < bt->next->rect.xmin); - - bt->rect.xmin = x1addval; - bt->rect.xmax = bt->rect.xmin + i + block->bounds; - - if (col == lastcol) { - bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds); - } + ui_check_but(col_bt); /* clips text again */ + } - ui_check_but(bt); /* clips text again */ - - if (nextcol) { + /* And we prepare next column. */ x1addval += i + block->bounds; - col++; + i = 0; + init_col_bt = col_bt; } - - bt = bt->next; + } + + /* Last column. */ + for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) { + col_bt->rect.xmin = x1addval; + col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds); + + ui_check_but(col_bt); /* clips text again */ } } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 434f1e3..733b45f 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -533,14 +533,20 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE uiLayout *layout = uiPupMenuLayout(pup); uiLayout *split = uiLayoutSplit(layout, 0.0f, false); uiLayout *column = NULL; + const int col_size = 20 + totitem / 12; int i, c; + bool add_col = true; - for (c = 0, i = totitem - 1; i >= 0; i--, c++) { - if ( (c % 20) == 0) + for (c = 0, i = totitem; i--;) { + if (add_col && !(c % col_size)) { column = uiLayoutColumn(split, false); - if (item- [x].identifier) + add_col = false; + } + if (item- [x].identifier) { uiItemIntO(column, item- [x].name, item- [x].icon, op->type->idname, "item", item- [x].value); - + ++c; + add_col = true; + } } MEM_freeN(item); ```

This patch doesn't apply here, it has spaces instead of tabs and in a way that makes it difficult to search and replace them.

The code looks ok to me though, just not sure how the result looks.

This patch doesn't apply here, it has spaces instead of tabs and in a way that makes it difficult to search and replace them. The code looks ok to me though, just not sure how the result looks.

@brecht ack, sorry, copy/paste directly from terminal is not a good idea, after all… :/

This one should be OK:

P38: Fix #39234

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7e6e00b..5622288 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -207,43 +207,41 @@ void ui_block_translate(uiBlock *block, int x, int y)
 static void ui_text_bounds_block(uiBlock *block, float offset)
 {
 	uiStyle *style = UI_GetStyle();
-	uiBut *bt;
-	int i = 0, j, x1addval = offset, nextcol;
-	int lastcol = 0, col = 0;
-	
+	uiBut *bt, *init_col_bt, *col_bt;
+	int i = 0, j, x1addval = offset;
+
 	uiStyleFontSet(&style->widget);
-	
-	for (bt = block->buttons.first; bt; bt = bt->next) {
+
+	for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) {
 		if (!ELEM(bt->type, SEPR, SEPRLINE)) {
 			j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
 
-			if (j > i) i = j;
+			if (j > i)
+				i = j;
 		}
 
-		if (bt->next && bt->rect.xmin < bt->next->rect.xmin)
-			lastcol++;
-	}
+		if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
+			/* End of this column, and it’s not the last one. */
+			for (col_bt = init_col_bt; col_bt->prev != bt; col_bt = col_bt->next) {
+				col_bt->rect.xmin = x1addval;
+				col_bt->rect.xmax = x1addval + i + block->bounds;
 
-	/* cope with multi collumns */
-	bt = block->buttons.first;
-	while (bt) {
-		nextcol = (bt->next && bt->rect.xmin < bt->next->rect.xmin);
-		
-		bt->rect.xmin = x1addval;
-		bt->rect.xmax = bt->rect.xmin + i + block->bounds;
-		
-		if (col == lastcol) {
-			bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds);
-		}
+				ui_check_but(col_bt);  /* clips text again */
+			}
 
-		ui_check_but(bt);  /* clips text again */
-		
-		if (nextcol) {
+			/* And we prepare next column. */
 			x1addval += i + block->bounds;
-			col++;
+			i = 0;
+			init_col_bt = col_bt;
 		}
-		
-		bt = bt->next;
+	}
+
+	/* Last column. */
+	for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) {
+		col_bt->rect.xmin = x1addval;
+		col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds);
+
+		ui_check_but(col_bt);  /* clips text again */
 	}
 }
 
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 434f1e3..733b45f 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -533,14 +533,20 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
 			uiLayout *layout = uiPupMenuLayout(pup);
 			uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
 			uiLayout *column = NULL;
+			const int col_size = 20 + totitem / 12;
 			int i, c;
+			bool add_col = true;
 			
-			for (c = 0, i = totitem - 1; i >= 0; i--, c++) {
-				if ( (c % 20) == 0)
+			for (c = 0, i = totitem; i--;) {
+				if (add_col && !(c % col_size)) {
 					column = uiLayoutColumn(split, false);
-				if (item- [x].identifier)
+					add_col = false;
+				}
+				if (item- [x].identifier) {
 					uiItemIntO(column, item- [x].name, item- [x].icon, op->type->idname, "item", item- [x].value);
-				
+					++c;
+					add_col = true;
+				}
 			}
 			
 			MEM_freeN(item);

@brecht ack, sorry, copy/paste directly from terminal is not a good idea, after all… :/ This one should be OK: [P38: Fix #39234](https://archive.blender.org/developer/P38.txt) ```diff diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7e6e00b..5622288 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -207,43 +207,41 @@ void ui_block_translate(uiBlock *block, int x, int y) static void ui_text_bounds_block(uiBlock *block, float offset) { uiStyle *style = UI_GetStyle(); - uiBut *bt; - int i = 0, j, x1addval = offset, nextcol; - int lastcol = 0, col = 0; - + uiBut *bt, *init_col_bt, *col_bt; + int i = 0, j, x1addval = offset; + uiStyleFontSet(&style->widget); - - for (bt = block->buttons.first; bt; bt = bt->next) { + + for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) { if (!ELEM(bt->type, SEPR, SEPRLINE)) { j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr)); - if (j > i) i = j; + if (j > i) + i = j; } - if (bt->next && bt->rect.xmin < bt->next->rect.xmin) - lastcol++; - } + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) { + /* End of this column, and it’s not the last one. */ + for (col_bt = init_col_bt; col_bt->prev != bt; col_bt = col_bt->next) { + col_bt->rect.xmin = x1addval; + col_bt->rect.xmax = x1addval + i + block->bounds; - /* cope with multi collumns */ - bt = block->buttons.first; - while (bt) { - nextcol = (bt->next && bt->rect.xmin < bt->next->rect.xmin); - - bt->rect.xmin = x1addval; - bt->rect.xmax = bt->rect.xmin + i + block->bounds; - - if (col == lastcol) { - bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds); - } + ui_check_but(col_bt); /* clips text again */ + } - ui_check_but(bt); /* clips text again */ - - if (nextcol) { + /* And we prepare next column. */ x1addval += i + block->bounds; - col++; + i = 0; + init_col_bt = col_bt; } - - bt = bt->next; + } + + /* Last column. */ + for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) { + col_bt->rect.xmin = x1addval; + col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds); + + ui_check_but(col_bt); /* clips text again */ } } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 434f1e3..733b45f 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -533,14 +533,20 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE uiLayout *layout = uiPupMenuLayout(pup); uiLayout *split = uiLayoutSplit(layout, 0.0f, false); uiLayout *column = NULL; + const int col_size = 20 + totitem / 12; int i, c; + bool add_col = true; - for (c = 0, i = totitem - 1; i >= 0; i--, c++) { - if ( (c % 20) == 0) + for (c = 0, i = totitem; i--;) { + if (add_col && !(c % col_size)) { column = uiLayoutColumn(split, false); - if (item- [x].identifier) + add_col = false; + } + if (item- [x].identifier) { uiItemIntO(column, item- [x].name, item- [x].icon, op->type->idname, "item", item- [x].value); - + ++c; + add_col = true; + } } MEM_freeN(item); ```

Thanks, looks good to me.

Thanks, looks good to me.

This issue was referenced by blender/blender-addons-contrib@09e5aa5156

This issue was referenced by blender/blender-addons-contrib@09e5aa5156486585b3d23f52f927db744fb9a055

This issue was referenced by 09e5aa5156

This issue was referenced by 09e5aa5156486585b3d23f52f927db744fb9a055

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 09e5aa5156.

Closed by commit 09e5aa5156.

Added subscriber: @ecv

Added subscriber: @ecv

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

Hello, this is still broken in 2.77a

I tried to reproduce it on purpose a number of times and I couldn't get it. However after working for a while it will eventually mess up.

My setup: Windows 7, two monitors both at 1024x768

Feel free to ask for any other specifics or actions.

Cheers,
Eneko

Hello, this is still broken in 2.77a I tried to reproduce it on purpose a number of times and I couldn't get it. However after working for a while it will eventually mess up. My setup: Windows 7, two monitors both at 1024x768 Feel free to ask for any other specifics or actions. Cheers, Eneko

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Please do not resurrect mummified reports like that… If you believe this is still valid, then open a new report and optionally add a link/reference to this one in it (typing #39234 would be enough).

Further more, as explained in closing commit, we cannot tackle all possible corner cases, Blender is not exactly designed to be used on a smartphone screen e.g.

Please do not resurrect mummified reports like that… If you believe this is still valid, then open a new report and optionally add a link/reference to this one in it (typing #39234 would be enough). Further more, as explained in closing commit, we cannot tackle all possible corner cases, Blender is not exactly designed to be used on a smartphone screen e.g.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#39234
No description provided.