mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed item pen width in big images.
This commit is contained in:
parent
1504f92a64
commit
d9a29b6f15
2 changed files with 33 additions and 20 deletions
|
@ -27,11 +27,6 @@ auto Normalized(float64 angle) {
|
||||||
+ ((std::abs(angle) < 360) ? 0 : (-360 * (angle < 0 ? -1 : 1)));
|
+ ((std::abs(angle) < 360) ? 0 : (-360 * (angle < 0 ? -1 : 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPen PenStyled(QPen pen, Qt::PenStyle style) {
|
|
||||||
pen.setStyle(style);
|
|
||||||
return pen;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int NumberedItem::number() const {
|
int NumberedItem::number() const {
|
||||||
|
@ -49,13 +44,6 @@ ItemBase::ItemBase(
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
: _lastZ(zPtr)
|
: _lastZ(zPtr)
|
||||||
, _selectPen(QBrush(Qt::white), 1, Qt::DashLine, Qt::SquareCap, Qt::RoundJoin)
|
|
||||||
, _selectPenInactive(
|
|
||||||
QBrush(Qt::gray),
|
|
||||||
1,
|
|
||||||
Qt::DashLine,
|
|
||||||
Qt::SquareCap,
|
|
||||||
Qt::RoundJoin)
|
|
||||||
, _horizontalSize(size)
|
, _horizontalSize(size)
|
||||||
, _zoom(std::move(zoomValue)) {
|
, _zoom(std::move(zoomValue)) {
|
||||||
setFlags(QGraphicsItem::ItemIsMovable
|
setFlags(QGraphicsItem::ItemIsMovable
|
||||||
|
@ -78,6 +66,13 @@ ItemBase::ItemBase(
|
||||||
.min = int(st::photoEditorItemMinSize / zoom),
|
.min = int(st::photoEditorItemMinSize / zoom),
|
||||||
.max = int(st::photoEditorItemMaxSize / zoom),
|
.max = int(st::photoEditorItemMaxSize / zoom),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updatePens(QPen(
|
||||||
|
QBrush(),
|
||||||
|
1 / zoom,
|
||||||
|
Qt::DashLine,
|
||||||
|
Qt::SquareCap,
|
||||||
|
Qt::RoundJoin));
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,13 +98,11 @@ void ItemBase::paint(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PainterHighQualityEnabler hq(*p);
|
PainterHighQualityEnabler hq(*p);
|
||||||
const auto &pen = (option->state & QStyle::State_HasFocus)
|
const auto hasFocus = (option->state & QStyle::State_HasFocus);
|
||||||
? _selectPen
|
p->setPen(hasFocus ? _pens.select : _pens.selectInactive);
|
||||||
: _selectPenInactive;
|
|
||||||
p->setPen(pen);
|
|
||||||
p->drawRect(innerRect());
|
p->drawRect(innerRect());
|
||||||
|
|
||||||
p->setPen(PenStyled(pen, Qt::SolidLine));
|
p->setPen(hasFocus ? _pens.handle : _pens.handleInactive);
|
||||||
p->setBrush(st::photoEditorItemBaseHandleFg);
|
p->setBrush(st::photoEditorItemBaseHandleFg);
|
||||||
p->drawEllipse(rightHandleRect());
|
p->drawEllipse(rightHandleRect());
|
||||||
p->drawEllipse(leftHandleRect());
|
p->drawEllipse(leftHandleRect());
|
||||||
|
@ -270,4 +263,19 @@ void ItemBase::setFlip(bool value) {
|
||||||
void ItemBase::performFlip() {
|
void ItemBase::performFlip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemBase::updatePens(QPen pen) {
|
||||||
|
_pens = {
|
||||||
|
.select = pen,
|
||||||
|
.selectInactive = pen,
|
||||||
|
.handle = pen,
|
||||||
|
.handleInactive = pen,
|
||||||
|
};
|
||||||
|
_pens.select.setColor(Qt::white);
|
||||||
|
_pens.selectInactive.setColor(Qt::gray);
|
||||||
|
_pens.handle.setColor(Qt::white);
|
||||||
|
_pens.handleInactive.setColor(Qt::gray);
|
||||||
|
_pens.handle.setStyle(Qt::SolidLine);
|
||||||
|
_pens.handleInactive.setStyle(Qt::SolidLine);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -82,11 +82,16 @@ private:
|
||||||
QRectF leftHandleRect() const;
|
QRectF leftHandleRect() const;
|
||||||
bool isHandling() const;
|
bool isHandling() const;
|
||||||
void updateVerticalSize();
|
void updateVerticalSize();
|
||||||
|
void updatePens(QPen pen);
|
||||||
|
|
||||||
const std::shared_ptr<float64> _lastZ;
|
const std::shared_ptr<float64> _lastZ;
|
||||||
const QPen _selectPen;
|
|
||||||
const QPen _selectPenInactive;
|
struct {
|
||||||
const QPen _handlePen;
|
QPen select;
|
||||||
|
QPen selectInactive;
|
||||||
|
QPen handle;
|
||||||
|
QPen handleInactive;
|
||||||
|
} _pens;
|
||||||
|
|
||||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue