Bug 120488 - Legend object can be resized
Summary: Legend object can be resized
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-01-20 02:27 UTC by Andrew Walker
Modified: 2006-01-24 23:55 UTC (History)
0 users

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-20 02:27:43 UTC
Version:           HEAD (using KDE KDE 3.4.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
The legend object can be resized such that none of its entries are visible

STEPS TO REPRODUCE:
Create a plot in Kst and ebale the Legend object
Enter layout mode and resize the legend object to a small fraction of its original size

RESULTS:
The entries in the legend object are no longer visible.

EXPECTED RESULTS:
The legend font size should be modified to reflect the new size of the legend object itself.
Alternatively the legend should not be resizable.
Comment 1 Netterfield 2006-01-20 02:53:43 UTC
As an added inconsistency: if the legend *is* manually resized, any re-draw of the plot resets the legend to its default size.  
I think the legend should not be resizable.
Comment 2 Andrew Walker 2006-01-24 23:55:29 UTC
SVN commit 502137 by arwalker:

BUG:120488 Make it so that the user cannot resize the legend object through the UI.

 M  +14 -11    ksttoplevelview.cpp  
 M  +2 -0      kstviewlegend.cpp  
 M  +36 -26    kstviewobject.cpp  
 M  +3 -1      kstviewobject.h  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #502136:502137
@@ -287,7 +287,7 @@
   _mode = v;
   
   // change the mouse handler
-  if ((_mode == CreateMode) || (_mode == LabelMode)) {
+  if (_mode == CreateMode || _mode == LabelMode) {
     _activeHandler = handlerForObject(objectType);
   } else {
     _activeHandler = 0L;
@@ -656,17 +656,20 @@
     if (_pressDirection == 0) {
       // moving an object
       pressMoveLayoutModeMove(pos, shift);
-    } else if (_pressDirection & ENDPOINT) {
-      // moving an endpoint of an object
-      pressMoveLayoutModeEndPoint(pos, shift);
-    } else if (_pressDirection & CENTEREDRESIZE) {
-      // resizing an object with fixed center
-      pressMoveLayoutModeCenteredResize(pos, shift);
-    } else {
-      // resizing a rectangular object
-      pressMoveLayoutModeResize(pos, shift);
+      KstApp::inst()->slotUpdateDataMsg(i18n("(x0,y0)-(x1,y1)", "(%1,%2)-(%3,%4)").arg(_prevBand.topLeft().x()).arg(_prevBand.topLeft().y()).arg(_prevBand.bottomRight().x()).arg(_prevBand.bottomRight().y()));
+    } else if (_pressTarget->isResizable()) { 
+      if (_pressDirection & ENDPOINT) {
+        // moving an endpoint of an object
+        pressMoveLayoutModeEndPoint(pos, shift);
+      } else if (_pressDirection & CENTEREDRESIZE) {
+        // resizing an object with fixed center
+        pressMoveLayoutModeCenteredResize(pos, shift);
+      } else {
+        // resizing a rectangular object
+        pressMoveLayoutModeResize(pos, shift);
+      }
+      KstApp::inst()->slotUpdateDataMsg(i18n("(x0,y0)-(x1,y1)", "(%1,%2)-(%3,%4)").arg(_prevBand.topLeft().x()).arg(_prevBand.topLeft().y()).arg(_prevBand.bottomRight().x()).arg(_prevBand.bottomRight().y()));
     }
-    KstApp::inst()->slotUpdateDataMsg(i18n("(x0,y0)-(x1,y1)", "(%1,%2)-(%3,%4)").arg(_prevBand.topLeft().x()).arg(_prevBand.topLeft().y()).arg(_prevBand.bottomRight().x()).arg(_prevBand.bottomRight().y()));
   } else {
     // selecting objects
     pressMoveLayoutModeSelect(pos, shift);
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #502136:502137
@@ -59,6 +59,7 @@
   _vertical = true;
   _fontName = KstApp::inst()->defaultFont();
   _fontSize = 0;
+  _isResizable = false;
   setForegroundColor(KstSettings::globalSettings()->foregroundColor);
   setBorderColor(KstSettings::globalSettings()->foregroundColor);
   setBackgroundColor(KstSettings::globalSettings()->backgroundColor);
@@ -82,6 +83,7 @@
   _fontName = KstApp::inst()->defaultFont();
   _fontSize = 0;
   _vertical = true;
+  _isResizable = false;
   _absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
   _layoutActions &= ~(MoveTo | Copy | CopyTo);
   _standardActions |= Delete | Edit;
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #502136:502137
@@ -72,6 +72,7 @@
   _followsFlow = false;
   _dialogLock = false;
   _fallThroughTransparency = true;
+  _isResizable = true;
   setMinimumSize(DEFAULT_MINIMUM_SIZE);
 }
 
@@ -87,6 +88,7 @@
   _followsFlow = false;
   _dialogLock = false;
   _fallThroughTransparency = true;
+  _isResizable = true;
   setMinimumSize(DEFAULT_MINIMUM_SIZE);
   load(e);
 }
@@ -108,6 +110,7 @@
   _dialogLock = false;
   _selected = false;
   _fallThroughTransparency = true;
+  _isResizable = viewObject._isResizable;
   _geom = viewObject._geom;
   _transparent = viewObject._transparent;
   _followsFlow = viewObject._followsFlow;
@@ -1739,34 +1742,36 @@
 
   signed int direction = NONE;
 
-  const QRect geom(geometry());
-  const QPoint topLeft(geom.topLeft());
-  const QPoint topRight(geom.topRight());
-  const QPoint bottomLeft(geom.bottomLeft());
-  const QPoint bottomRight(geom.bottomRight());
-  const QPoint topMiddle(QPoint((topLeft.x() + topRight.x())/2, topLeft.y()));
-  const QPoint bottomMiddle(QPoint((bottomLeft.x() + bottomRight.x())/2, bottomLeft.y()));
-  const QPoint middleLeft(QPoint(topLeft.x(), (topLeft.y() + bottomLeft.y())/2));
-  const QPoint middleRight(QPoint(topRight.x(), (topRight.y() + bottomRight.y())/2));
+  if (_isResizable) {
+    const QRect geom(geometry());
+    const QPoint topLeft(geom.topLeft());
+    const QPoint topRight(geom.topRight());
+    const QPoint bottomLeft(geom.bottomLeft());
+    const QPoint bottomRight(geom.bottomRight());
+    const QPoint topMiddle(QPoint((topLeft.x() + topRight.x())/2, topLeft.y()));
+    const QPoint bottomMiddle(QPoint((bottomLeft.x() + bottomRight.x())/2, bottomLeft.y()));
+    const QPoint middleLeft(QPoint(topLeft.x(), (topLeft.y() + bottomLeft.y())/2));
+    const QPoint middleRight(QPoint(topRight.x(), (topRight.y() + bottomRight.y())/2));
 
-  if (pointsCloseEnough(topLeft, pos)) {
-    direction |= UP | LEFT;
-  } else if (pointsCloseEnough(topRight, pos)) {
-    direction |= UP | RIGHT;
-  } else if (pointsCloseEnough(bottomLeft, pos)) {
-    direction |= DOWN | LEFT;
-  } else if (pointsCloseEnough(bottomRight, pos)) {
-    direction |= DOWN | RIGHT;
-  } else if (pointsCloseEnough(topMiddle, pos)) {
-    direction |= UP;
-  } else if (pointsCloseEnough(bottomMiddle, pos)) {
-    direction |= DOWN;
-  } else if (pointsCloseEnough(middleLeft, pos)) {
-    direction |= LEFT;
-  } else if (pointsCloseEnough(middleRight, pos)) {
-    direction |= RIGHT;
+    if (pointsCloseEnough(topLeft, pos)) {
+      direction |= UP | LEFT;
+    } else if (pointsCloseEnough(topRight, pos)) {
+      direction |= UP | RIGHT;
+    } else if (pointsCloseEnough(bottomLeft, pos)) {
+      direction |= DOWN | LEFT;
+    } else if (pointsCloseEnough(bottomRight, pos)) {
+      direction |= DOWN | RIGHT;
+    } else if (pointsCloseEnough(topMiddle, pos)) {
+      direction |= UP;
+    } else if (pointsCloseEnough(bottomMiddle, pos)) {
+      direction |= DOWN;
+    } else if (pointsCloseEnough(middleLeft, pos)) {
+      direction |= LEFT;
+    } else if (pointsCloseEnough(middleRight, pos)) {
+      direction |= RIGHT;
+    }
   }
-
+  
   return direction;
 }
 
@@ -1849,5 +1854,10 @@
   return _fallThroughTransparency;
 }
 
+bool KstViewObject::isResizable() const {
+  return _isResizable;
+}
+
+
 #include "kstviewobject.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstviewobject.h #502136:502137
@@ -125,7 +125,8 @@
 
     bool objectDirty() const; // true if this object or a child is dirty
     bool fallThroughTransparency() const;
-
+    bool isResizable() const;
+    
     virtual QWidget *configWidget();
 
     // can't be const due to KstViewObjectPtr?
@@ -306,6 +307,7 @@
     bool _dialogLock : 1;
     bool _container : 1;
     bool _fallThroughTransparency : 1;
+    bool _isResizable : 1;
     int _columns : 6; // "64 columns ought to be enough for anyone"
     QGuardedPtr<KstViewObject> _topObjectForMenu;
     QGuardedPtr<KstViewObject> _parent; // danger!!