Bug 122458 - Legend size is incorret with no entries
Summary: Legend size is incorret with no entries
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 02:04 UTC by Andrew Walker
Modified: 2006-02-22 19:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed patch (1.49 KB, patch)
2006-02-22 02:05 UTC, Andrew Walker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2006-02-22 02:04:31 UTC
Version:           HEAD (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
OS:                Linux

STEPS TO REPRODUCE:
Start kst
Create a plot with a single curve
make the legend visible
Edit the legend and empty the Display objects list
Hit Apply

RESULTS:
In vertical mode height of legend extends beyond plot
In horizontal mode legend has no width

EXPECTED RESULTS:
A reasonable default size for each case
Comment 1 Andrew Walker 2006-02-22 02:05:15 UTC
Created attachment 14804 [details]
Proposed patch
Comment 2 Netterfield 2006-02-22 07:44:54 UTC
The patch looks good.  Please apply.
Comment 3 Andrew Walker 2006-02-22 19:12:47 UTC
SVN commit 512513 by arwalker:

BUG:122458 Make legend size reasonable for zero entries

 M  +14 -6     kstviewlegend.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #512512:512513
@@ -262,7 +262,7 @@
       RenderContext rc(_fontName, _absFontSize, 0L);
       renderLabel(rc, (*it)->parsedLegendTag()->chunk);
       if (_vertical) {
-        if (rc.xMax>_textWidth) {
+        if (rc.xMax > _textWidth) {
           _textWidth = rc.xMax;
         }
       } else {
@@ -280,9 +280,17 @@
   _ascent = rc.fontAscent();
 
   if (_vertical) {
-    _textHeight = _curves.count()*rc.fontHeight() + (_curves.count()-1)*_ascent/4;
+    if (_curves.count() > 0) {
+      _textHeight = _curves.count()*rc.fontHeight() + (_curves.count()-1)*_ascent/4;
+    } else {
+      _textHeight = _ascent/4;
+    }
   } else {
-    _textWidth += _curves.count()*_ascent;
+    if (_curves.count() > 0) {
+      _textWidth += _curves.count()*_ascent;
+    } else {
+      _textWidth += _ascent;
+    }
   }
 
   // determine title size
@@ -420,13 +428,13 @@
   if (_vertical) {
     width = QMAX(_textWidth + 9*_ascent/2, _titleWidth);
     height = _textHeight;
-    if (_titleHeight>0) {
-      height+=_titleHeight;
+    if (_titleHeight > 0) {
+      height += _titleHeight;
     }
   } else {
     height = QMAX(_textHeight, _titleHeight);
 
-    if (_titleWidth>0) {
+    if (_titleWidth > 0) {
       width = _titleWidth + _textWidth + 9*_ascent*_curves.count()/2;
     } else {
       width = _textWidth + 9*_ascent*_curves.count()/2 - _ascent;