Skip to content

Commit baa47a9

Browse files
authored
Merge pull request #9051 from gadfort/gui-min-highlight
gui: draw bbox when highlight is smaller than coarse limit (10px)
2 parents b2317a3 + 1f7459f commit baa47a9

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/gui/src/layoutViewer.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,8 +1898,32 @@ void LayoutViewer::paintEvent(QPaintEvent* event)
18981898
brush.a = 100;
18991899
}
19001900

1901-
animate_selection_->selection.highlight(
1902-
gui_painter, Painter::kHighlight, pen_width, brush);
1901+
odb::Rect bbox;
1902+
bool draw_hightlight = true;
1903+
if (animate_selection_->selection.getBBox(bbox)) {
1904+
const int size = bbox.maxDXDY();
1905+
1906+
const int min_size = highlightSizeLimit();
1907+
1908+
if (size < min_size) {
1909+
draw_hightlight = false;
1910+
1911+
const int half_size = min_size / 2.0;
1912+
const int bloat_by = half_size - size;
1913+
1914+
odb::Rect draw_rect;
1915+
bbox.bloat(bloat_by, draw_rect);
1916+
gui_painter.setPen(Painter::kHighlight, true, pen_width);
1917+
gui_painter.setBrush(brush, Painter::Brush::kSolid);
1918+
1919+
gui_painter.drawRect(draw_rect, 0, 0);
1920+
}
1921+
}
1922+
1923+
if (draw_hightlight) {
1924+
animate_selection_->selection.highlight(
1925+
gui_painter, Painter::kHighlight, pen_width, brush);
1926+
}
19031927
}
19041928

19051929
// draw partial ruler if present
@@ -2474,6 +2498,11 @@ int LayoutViewer::shapeSizeLimit() const
24742498
return nominalViewableResolution();
24752499
}
24762500

2501+
int LayoutViewer::highlightSizeLimit() const
2502+
{
2503+
return coarseViewableResolution();
2504+
}
2505+
24772506
int LayoutViewer::fineViewableResolution() const
24782507
{
24792508
return 1.0 / pixels_per_dbu_;

src/gui/src/layoutViewer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class LayoutViewer : public QWidget
301301
int coarseViewableResolution() const;
302302
int instanceSizeLimit() const;
303303
int shapeSizeLimit() const;
304+
int highlightSizeLimit() const;
304305

305306
std::vector<std::tuple<odb::dbObject*, odb::Rect, int>> getRowRects(
306307
odb::dbBlock* block,

0 commit comments

Comments
 (0)