[Uml-devel] branches/work/soc-umbrello/umbrello/widgets
Gopala Krishna A
krishna.ggk at gmail.com
Sun Jun 28 12:47:52 UTC 2009
SVN commit 988584 by gopala:
Appearance Style changes (experimentation basis)
* Fill brush and line color changed to a Gray gradient brush and dark yellow
color respectively, for all widgets[link 1].
* Left align attributes and operations in ClassifierWidget (my uml textbook
asserts this).
* Draw a rounded rect for ClassifierWidget. Looks really pretty :)
* ClassifierWidget for now draws a rounded rect covering the header
area (name and stereotype) with different color(also pretty IMHO).
[link 1] http://picasaweb.google.com/krishna.ggk/Projects#5352357434709495186
TODO: Implement the double color based filling for all widgets.
M +29 -10 classifierwidget.cpp
M +0 -1 classifierwidget.h
M +12 -3 widgetbase.cpp
--- branches/work/soc-umbrello/umbrello/widgets/classifierwidget.cpp #988583:988584
@@ -28,6 +28,18 @@
#include "umlscene.h"
#include "umlview.h"
+static QBrush awesomeHeaderBrush()
+{
+ static QBrush brush;
+ if (brush.style() == Qt::NoBrush) {
+ QColor alphaBlue(Qt::darkBlue);
+ alphaBlue.setAlpha(155);
+ brush.setStyle(Qt::SolidPattern);
+ brush.setColor(alphaBlue);
+ }
+ return brush;
+}
+
const qreal ClassifierWidget::CircleMinimumRadius = 30;
const int ClassifierWidget::InvalidIndex = 99999;
@@ -53,7 +65,7 @@
// Null initially
m_dummyAttributeItem = m_dummyOperationItem = 0;
- m_lineItem1Index = m_lineItem2Index = InvalidIndex;
+ m_lineItem2Index = InvalidIndex;
m_baseType = Uml::wt_Class;
// TODO: The following properties should be set using the
@@ -419,11 +431,16 @@
else {
// The elements not to be drawn will have null dimension and
// hence it effectively is not drawn. (automatic ;) )
- painter->drawRect(m_classifierRect);
+ painter->drawRoundedRect(m_classifierRect, 5, 5);
painter->drawLines(m_classifierLines, 2);
+ painter->setPen(QPen(Qt::NoPen));
+ painter->setBrush(awesomeHeaderBrush());
+ painter->drawRoundedRect(textItemGroupAt(HeaderGroupIndex)->groupGeometry(), 5, 5);
+
pen.setStyle(Qt::DotLine);
painter->setPen(pen);
+ painter->setBrush(brush());
painter->drawRect(m_templateRect);
}
}
@@ -561,9 +578,10 @@
const int cnt = attribOpGroup->textItemCount();
qreal expanderDistance = 4;
- if (cnt > m_lineItem1Index) {
- TextItem *item = headerGroup->textItemAt(m_lineItem1Index);
- qreal y = item->mapToParent(item->boundingRect().bottomLeft()).y();
+ bool showNameOnly = (!visualProperty(ShowAttributes) && !visualProperty(ShowOperations)
+ && !visualProperty(ShowStereotype) && !shouldDrawAsCircle());
+ if (!showNameOnly && !shouldDrawAsCircle()) {
+ qreal y = textItemGroupAt(HeaderGroupIndex)->groupGeometry().bottom();
m_classifierLines[0].setLine(m_classifierRect.left(), y, m_classifierRect.right(), y);
qreal expanderX = rect().left() -
m_attributeExpanderBox->rect().width() -
@@ -574,7 +592,8 @@
TextItem *item = attribOpGroup->textItemAt(m_lineItem2Index);
qreal y = item->mapToParent(item->boundingRect().bottomLeft()).y();
m_classifierLines[1].setLine(m_classifierRect.left(), y, m_classifierRect.right(), y);
- qreal expanderX = rect().left() - m_operationExpanderBox->rect().width() - expanderDistance;
+ qreal expanderX = rect().left() - m_operationExpanderBox->rect().width() -
+ expanderDistance;
m_operationExpanderBox->setPos(expanderX, y);
}
}
@@ -594,6 +613,9 @@
TextItemGroup *attribOpGroup = textItemGroupAt(AttribOpGroupIndex);
TextItemGroup *templateGroup = textItemGroupAt(TemplateGroupIndex);
+ attribOpGroup->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+ templateGroup->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+
UMLClassifier *umlC = classifier();
UMLClassifierListItemList attribList = umlC->getFilteredList(Uml::ot_Attribute);
UMLClassifierListItemList opList = umlC->getFilteredList(Uml::ot_Operation);
@@ -638,9 +660,6 @@
bool showNameOnly = (!visualProperty(ShowAttributes) && !visualProperty(ShowOperations)
&& !visualProperty(ShowStereotype) && !shouldDrawAsCircle());
nameItem->setText(nameText);
- if (!showNameOnly) {
- m_lineItem1Index = NameItemIndex;
- }
int attribStartIndex = 0;
int opStartIndex = attribStartIndex + attribList.size();
@@ -853,6 +872,6 @@
m_dummyOperationItem = 0;
}
- m_lineItem1Index = m_lineItem2Index = InvalidIndex;
+ m_lineItem2Index = InvalidIndex;
m_classifierLines[0] = m_classifierLines[1] = QLineF();
}
--- branches/work/soc-umbrello/umbrello/widgets/classifierwidget.h #988583:988584
@@ -144,7 +144,6 @@
void invalidateDummies();
- int m_lineItem1Index;
int m_lineItem2Index;
TextItem *m_dummyAttributeItem;
TextItem *m_dummyOperationItem;
--- branches/work/soc-umbrello/umbrello/widgets/widgetbase.cpp #988583:988584
@@ -42,10 +42,14 @@
QLinearGradient grad;
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
grad.setColorAt(0, Qt::white);
- grad.setColorAt(1, QColor("#ffda0c"));
+ // grad.setColorAt(1, QColor("#ffda0c"));
+ const int grayLevel = 220;
+ const int alpha = 255;
+ QColor gray(grayLevel, grayLevel, grayLevel, alpha);
+ grad.setColorAt(1, gray);
grad.setStart(0, 0);
- grad.setFinalStop(0, 1);
+ grad.setFinalStop(1, 1);
brush = QBrush(grad);
}
@@ -58,6 +62,11 @@
}
return brush;
}
+
+static QColor awesomeLineColor()
+{
+ return QColor(80, 80, 0);
+}
////////////////////////////////////////////////
/**
@@ -92,7 +101,7 @@
*/
WidgetBase::WidgetBase(UMLObject *object) :
m_umlObject(object),
- m_lineColor(Qt::red),
+ m_lineColor(awesomeLineColor()),
m_lineWidth(0),
m_brush(awesomeBrush()),
m_widgetInterfaceData(0),
More information about the umbrello-devel
mailing list