mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Added startUserTransformation() and handleUserTransformation() methods to the CustomElementPart class and all of its subclasses.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2026 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -268,6 +268,31 @@ bool PartTextField::isUseless() const {
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
Start the user-induced transformation, provided this primitive is contained
|
||||
within the \a initial_selection_rect bounding rectangle.
|
||||
*/
|
||||
void PartTextField::startUserTransformation(const QRectF &initial_selection_rect) {
|
||||
Q_UNUSED(initial_selection_rect)
|
||||
saved_point_ = pos(); // scene coordinates, no need to mapFromScene()
|
||||
saved_font_size_ = font().pointSize();
|
||||
}
|
||||
|
||||
/**
|
||||
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
||||
*/
|
||||
void PartTextField::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
||||
// let's try the naive approach
|
||||
QPointF new_pos = mapPoints(initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_point_).first();
|
||||
setPos(new_pos);
|
||||
|
||||
// adjust the font size following the smallest scale factor
|
||||
qreal sx = new_selection_rect.width() / initial_selection_rect.width();
|
||||
qreal sy = new_selection_rect.height() / initial_selection_rect.height();
|
||||
qreal smallest_scale_factor = sx > sy ? sy : sx;
|
||||
qreal new_font_size = saved_font_size_ * smallest_scale_factor;
|
||||
setProperty("size", qMax(1, qRound(new_font_size)));
|
||||
}
|
||||
/**
|
||||
Dessine le texte statique.
|
||||
@param painter QPainter a utiliser pour effectuer le rendu
|
||||
|
||||
Reference in New Issue
Block a user