[Kst] extragear/graphics/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Sat Aug 20 00:11:58 CEST 2005
SVN commit 451110 by rchern:
Restore focusRect to show which object has focus, but with 2 differences:
- instead of rectangle, draw outlines of the hotpoints in the inverted background color. Selected objects with focus have green hotpoint with white outlines; selected objects without focus have green hotpoints with black outlines. Unselected objects with focus have transparent hotpoints with hotpoint outlines only.
- instead of repainting everytime focus changes, just draw over the old focusRect (to clear it) and draw the new focusRect, without repainting any of the view objects (reduces flicker, which was one of the reasons focusRect behaviour was removed)
All mouse behaviour remains the same - focusRect is just for visual aid only.
M +35 -6 ksttoplevelview.cpp
M +1 -0 ksttoplevelview.h
M +8 -3 kstviewline.cpp
M +1 -0 kstviewline.h
M +8 -9 kstviewobject.cpp
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #451109:451110
@@ -179,6 +179,7 @@
void KstTopLevelView::paint(KstPaintType type) {
+
QRegion r = clipRegion();
QPainter p;
p.begin(_w);
@@ -192,6 +193,19 @@
p.setClipping(false);
paint(type, p);
p.end();
+
+ // now, check what has the focus and repaint the focus rect, as all focus rects are now lost
+ if (_hoverFocus) {
+ QPainter p;
+ p.begin(_w);
+ p.setViewXForm(true);
+ _hoverFocus->setFocus(false);
+ p.setRasterOp(Qt::NotROP);
+ p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
+ p.setBrush(Qt::NoBrush);
+ _hoverFocus->drawFocusRect(p);
+ p.end();
+ }
}
@@ -203,16 +217,18 @@
_w->unsetCursor();
_focusOn = false;
//recursively<bool>(&KstViewObject::setFocus, false);
- QPainter p;
- p.begin(_w);
- p.setViewXForm(true);
if (_hoverFocus) {
+ QPainter p;
+ p.begin(_w);
+ p.setViewXForm(true);
_hoverFocus->setFocus(false);
+ p.setRasterOp(Qt::NotROP);
+ p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
+ p.setBrush(Qt::NoBrush);
_hoverFocus->drawFocusRect(p);
+ p.end();
_hoverFocus = 0L;
}
- //paint(P_PAINT, p);
- p.end();
}
}
@@ -239,12 +255,25 @@
}
if (_focusOn) { // something else has the focus, clear it
p->setFocus(true);
+ QPainter painter;
+ painter.begin(_w);
+ painter.setRasterOp(Qt::NotROP);
+ painter.setPen(QPen(Qt::black, 0, Qt::SolidLine));
+ painter.setBrush(Qt::NoBrush);
+ p->drawFocusRect(painter);
+ painter.end();
clearFocus();
_focusOn = true;
} else {
p->setFocus(true);
+ QPainter painter;
+ painter.begin(_w);
+ painter.setRasterOp(Qt::NotROP);
+ painter.setPen(QPen(Qt::black, 0, Qt::SolidLine));
+ painter.setBrush(Qt::NoBrush);
+ p->drawFocusRect(painter);
+ painter.end();
_focusOn = true;
- // paint(P_PAINT);
}
_hoverFocus = p;
} else {
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #451109:451110
@@ -151,6 +151,7 @@
ViewMode _mode : 9;
signed int _pressDirection : 7;
QCursor _cursor;
+ QCursor _endpointCursor; // for storage of the custom hotpoint cursor
QPoint _moveOffset;
QPoint _moveOffsetSticky;
KstViewObjectPtr _pressTarget, _hoverFocus;
--- trunk/extragear/graphics/kst/kst/kstviewline.cpp #451109:451110
@@ -205,7 +205,7 @@
}
-void KstViewLine::drawSelectRect(QPainter& p) {
+void KstViewLine::drawFocusRect(QPainter& p) {
// draw the hotpoints
QPoint point1, point2;
@@ -221,14 +221,19 @@
QRect rect;
rect.setSize(QSize(2*dx+1,2*dx+1));
rect.moveTopLeft(point1);
- p.setPen(QPen(Qt::black, 0));
- p.setBrush(QBrush(Qt::green, Qt::SolidPattern));
p.drawRect(rect);
rect.moveTopLeft(point2);
p.drawRect(rect);
}
+void KstViewLine::drawSelectRect(QPainter& p) {
+ p.setPen(QPen(Qt::black, 0));
+ p.setBrush(QBrush(Qt::green, Qt::SolidPattern));
+ drawFocusRect(p);
+}
+
+
signed int KstViewLine::directionFor(const QPoint& pos) {
if (!isSelected()) {
--- trunk/extragear/graphics/kst/kst/kstviewline.h #451109:451110
@@ -61,6 +61,7 @@
virtual Qt::PenStyle penStyle() const;
virtual void drawSelectRect(QPainter& p);
+ virtual void drawFocusRect(QPainter& p);
virtual signed int directionFor(const QPoint& pos);
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #451109:451110
@@ -324,7 +324,7 @@
if (_focus) {
//kdDebug() << "Object " << tagName() << " has focus" << endl;
- drawFocusRect(p);
+ //drawFocusRect(p);
}
if (isSelected()) {
@@ -338,14 +338,8 @@
void KstViewObject::drawFocusRect(QPainter& p) {
- Q_UNUSED(p)
// to draw a focus rect, put something here
-}
-
-
-void KstViewObject::drawSelectRect(QPainter& p) {
-
// draw the 8 hotpoints
QPoint topLeft = geometry().topLeft();
QPoint topRight = geometry().topRight();
@@ -359,8 +353,6 @@
int dx = KST_RESIZE_BORDER_W/2;
int width = 2*dx + 1;
- p.setBrush(QBrush(Qt::green));
- p.setPen(QPen(Qt::black, 0));
p.drawRect(topLeft.x()-dx, topLeft.y()-dx, width, width);
p.drawRect(topRight.x()-dx, topRight.y()-dx, width, width);
p.drawRect(bottomLeft.x()-dx, bottomLeft.y()-dx, width, width);
@@ -372,6 +364,13 @@
}
+void KstViewObject::drawSelectRect(QPainter& p) {
+ p.setBrush(QBrush(Qt::green));
+ p.setPen(QPen(Qt::black, 0));
+ drawFocusRect(p);
+}
+
+
void KstViewObject::appendChild(KstViewObjectPtr obj, bool keepAspect) {
obj->_parent = this;
_children.append(obj);
More information about the Kst
mailing list