Capture GUI refactor (#1939)
* Merge CTB::ButtonType into CaptureTool::Type Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove configshortcuts.cpp which I forgot to do earlier Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add activeButtonTool & activeButtonToolType in CaptureWidget Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Rename slots in CaptureTool for better mnemonics Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix move tool bug Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Refactor ShortcutsWidget::initButtons Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move code from CaptureWidget to SelectionWidget: part 1 Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move code from CaptureWidget to SelectionWidget: part 2 Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move code from CaptureWidget to SelectionWidget: part 3 Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move code from CaptureWidget to SelectionWidget: part 4 Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add SelectionWidget::updateCursor Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move code from CaptureWidget to SelectionWidget: part 5 Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Refactor mouse events in CaptureWidget Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Overlay message update Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Replace connect/disconnect with blockSignals Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * updateIcon on button animation finished Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove CaptureWidget::selectAll Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move moveLeft and similar to SelectionWidget Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Mark update calls for removal Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Specialize CaptureWidget update to affected rects Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Tune update of tool objects Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove redundant CaptureTool requests Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Improve performance of update in CaptureWidget Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix failing builds Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix failing builds again Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix undo/redo update Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Undo/redo update workaround Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Extend capture tool update rects Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix circle count tool update bug Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add 'Left Double-Click' tooltip to copy button Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Improve ColorPicker performance Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
@@ -44,6 +44,46 @@ bool AbstractPathTool::showMousePreview() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QRect AbstractPathTool::mousePreviewRect(const CaptureContext& context) const
|
||||
{
|
||||
QRect rect(0, 0, context.thickness + 2, context.thickness + 2);
|
||||
rect.moveCenter(context.mousePos);
|
||||
return rect;
|
||||
}
|
||||
|
||||
QRect AbstractPathTool::boundingRect() const
|
||||
{
|
||||
if (m_points.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
int min_x = m_points.at(0).x();
|
||||
int min_y = m_points.at(0).y();
|
||||
int max_x = m_points.at(0).x();
|
||||
int max_y = m_points.at(0).y();
|
||||
for (auto point : m_points) {
|
||||
if (point.x() < min_x) {
|
||||
min_x = point.x();
|
||||
}
|
||||
if (point.y() < min_y) {
|
||||
min_y = point.y();
|
||||
}
|
||||
if (point.x() > max_x) {
|
||||
max_x = point.x();
|
||||
}
|
||||
if (point.y() > max_y) {
|
||||
max_y = point.y();
|
||||
}
|
||||
}
|
||||
|
||||
int offset =
|
||||
m_thickness <= 1 ? 1 : static_cast<int>(round(m_thickness * 0.7 + 0.5));
|
||||
return QRect(min_x - offset,
|
||||
min_y - offset,
|
||||
std::abs(min_x - max_x) + offset * 2,
|
||||
std::abs(min_y - max_y) + offset * 2)
|
||||
.normalized();
|
||||
}
|
||||
|
||||
void AbstractPathTool::drawEnd(const QPoint& p)
|
||||
{
|
||||
Q_UNUSED(p)
|
||||
@@ -54,12 +94,12 @@ void AbstractPathTool::drawMove(const QPoint& p)
|
||||
addPoint(p);
|
||||
}
|
||||
|
||||
void AbstractPathTool::colorChanged(const QColor& c)
|
||||
void AbstractPathTool::onColorChanged(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
}
|
||||
|
||||
void AbstractPathTool::thicknessChanged(int th)
|
||||
void AbstractPathTool::onThicknessChanged(int th)
|
||||
{
|
||||
m_thickness = th;
|
||||
}
|
||||
@@ -91,36 +131,6 @@ void AbstractPathTool::move(const QPoint& mousePos)
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractPathTool::drawObjectSelection(QPainter& painter)
|
||||
{
|
||||
int min_x = m_points.at(0).x();
|
||||
int min_y = m_points.at(0).y();
|
||||
int max_x = m_points.at(0).x();
|
||||
int max_y = m_points.at(0).y();
|
||||
for (auto point : m_points) {
|
||||
if (point.x() < min_x) {
|
||||
min_x = point.x();
|
||||
}
|
||||
if (point.y() < min_y) {
|
||||
min_y = point.y();
|
||||
}
|
||||
if (point.x() > max_x) {
|
||||
max_x = point.x();
|
||||
}
|
||||
if (point.y() > max_y) {
|
||||
max_y = point.y();
|
||||
}
|
||||
}
|
||||
|
||||
int offset =
|
||||
m_thickness <= 1 ? 1 : static_cast<int>(round(m_thickness / 2 + 0.5));
|
||||
QRect rect = QRect(min_x - offset,
|
||||
min_y - offset,
|
||||
std::abs(min_x - max_x) + offset * 2,
|
||||
std::abs(min_y - max_y) + offset * 2);
|
||||
drawObjectSelectionRect(painter, rect);
|
||||
}
|
||||
|
||||
const QPoint* AbstractPathTool::pos()
|
||||
{
|
||||
if (m_points.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user