Bug 121064 - Problems in redrawing transparent label
Summary: Problems in redrawing transparent label
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: view objects (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-30 21:44 UTC by Andrew Walker
Modified: 2006-01-31 05:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2006-01-30 21:44:53 UTC
Version:           HEAD (using KDE KDE 3.5.0)
OS:                Linux

PROBLEM:
A transparent label is not redrawn correctly

STEPS TO REPRODUCE:
Create a plot within Kst
Add a text label
Check the transparent property in the Edit Label dialog
Enter layout mode
Resize the text label a few times

RESULTS:
It is apparent that the text label is not redrawn correctly

EXPECTED RESULTS:
The text label is redrawn properly
Comment 1 George Staikos 2006-01-31 04:44:47 UTC
The clip region was not always being invalidated when the label was dirty.  Patch to fix this:
Index: kstviewlabel.cpp
===================================================================
--- kstviewlabel.cpp    (revision 504009)
+++ kstviewlabel.cpp    (working copy)
@@ -324,6 +324,7 @@

 void KstViewLabel::updateSelf() {
   if (dirty()) {
+    invalidateClipRegion();
     if (_autoResize) {
       adjustSizeForText(_parent->contentsRect());
     } else {
Comment 2 Netterfield 2006-01-31 05:37:36 UTC
OK. Please commit.

On January 30, 2006 07:44 pm, George Staikos wrote:
[bugs.kde.org quoted mail]
Comment 3 George Staikos 2006-01-31 05:45:26 UTC
SVN commit 504021 by staikos:

- make transparent label/legend space movable from the transparent regions
- make transparent labels update the clip mask appropriately
- fix the margin size in labels and legends

Reviewed by Barth
BUG: 121064


 M  +6 -3      kstviewlabel.cpp  
 M  +6 -5      kstviewlegend.cpp  


--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #504020:504021
@@ -55,6 +55,7 @@
 
 KstViewLabel::KstViewLabel(const QString& txt, KstLJustifyType justify, float rotation)
 : KstBorderedViewObject("Label") {
+  _fallThroughTransparency = false;
   _container = false;
   setFollowsFlow(true);
   _dataPrecision = 8;
@@ -80,6 +81,7 @@
 KstViewLabel::KstViewLabel(const QDomElement& e) 
 : KstBorderedViewObject(e) {
   // some defaults and invariants
+  _fallThroughTransparency = false;
   _container = false;
   setFollowsFlow(true);
   _type = "Label";
@@ -324,6 +326,7 @@
 
 void KstViewLabel::updateSelf() {
   if (dirty()) {
+    invalidateClipRegion();
     if (_autoResize) {
       adjustSizeForText(_parent->contentsRect());
     } else {
@@ -484,7 +487,7 @@
   }
 
   QRect cr(contentsRect());
-  cr.setSize(sz + QSize(2 * _labelMargin + _ascent / 5, 2 * _labelMargin + _ascent / 5));
+  cr.setSize(sz + QSize(2 * _labelMargin * _ascent / 10, 2 * _labelMargin * _ascent / 10));
   setContentsRect(cr);
 }
 
@@ -572,7 +575,7 @@
     widget->_boxColors->setForeground(KstSettings::globalSettings()->foregroundColor);
     widget->_boxColors->setBackground(KstSettings::globalSettings()->backgroundColor);
 
-    if (size().width()*size().height()<25) { // assume a click, and default to just text
+    if (size().width() * size().height() < 25) { // assume a click, and default to just text
       widget->_transparent->setChecked(true);
       widget->_autoResize->setChecked(true);
       widget->_border->setValue(0);
@@ -634,7 +637,7 @@
   setBorderColor(widget->_boxColors->foreground());
   setBackgroundColor(widget->_boxColors->background());
   setLabelMargin(widget->_margin->value());
-  
+ 
   reparse(); // calls setDirty()
   return true;
 }
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #504020:504021
@@ -54,6 +54,7 @@
 
 KstViewLegend::KstViewLegend()
 : KstBorderedViewObject("Legend") {
+  _fallThroughTransparency = false;
   _container = false;
   _rotation = 0;
   _vertical = true;
@@ -77,6 +78,7 @@
 : KstBorderedViewObject(e) {
 
   // some defaults and invariants
+  _fallThroughTransparency = false;
   _container = false;
   _type = "Legend";
   _rotation = 0.0;
@@ -177,9 +179,8 @@
     for (KstBaseCurveList::Iterator it = _curves.begin(); it != _curves.end(); ++it) {
       p.save();
       if ((*it)->parsedLegendTag()) {
-        p.translate(borderWidth() + _legendMargin*_ascent/10, borderWidth() + _legendMargin*_ascent/10 + (i)*(rc.fontHeight()+_ascent/4));
-        QRect symbolBound(QPoint(0,0),
-                          QSize(16*_ascent/4, rc.fontHeight()));
+        p.translate(_legendMargin*_ascent/10, _legendMargin*_ascent/10 + i * (rc.fontHeight() + _ascent / 4));
+        QRect symbolBound(QPoint(0,0), QSize(16*_ascent/4, rc.fontHeight()));
 
         (*it)->paintLegendSymbol(&p, symbolBound);
         p.translate(9*_ascent/2, 0);
@@ -193,7 +194,7 @@
     }
   } else {
     p.save();
-    p.translate(borderWidth() + _legendMargin*_ascent/10, borderWidth() + _legendMargin*_ascent/10);
+    p.translate(_legendMargin*_ascent/10, _legendMargin*_ascent/10);
     for (KstBaseCurveList::Iterator it = _curves.begin(); it != _curves.end(); ++it) {
       if ((*it)->parsedLegendTag()) {
         QRect symbolBound(QPoint(0,0),
@@ -380,7 +381,7 @@
   }
 
   QRect cr(contentsRect());
-  cr.setSize(sz + QSize(2 * _legendMargin + _ascent / 5, 2 * _legendMargin + _ascent / 5));
+  cr.setSize(sz + QSize(2 * _legendMargin * _ascent / 10, 2 * _legendMargin * _ascent / 10));
   setContentsRect(cr);
 }