From f733c87902927d967bd67397de843bac44d86c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Thu, 30 May 2024 15:06:08 +0200 Subject: [PATCH 1/5] Account for margin in visibility icon click check --- src/Gui/Tree.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 1833a75523..3432e8ad63 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1608,15 +1608,19 @@ void TreeWidget::mousePressEvent(QMouseEvent* event) // Rect occupied by the item relative to viewport auto iconRect = visualItemRect(objitem); + auto style = this->style(); + // If the checkboxes are visible, these are displayed before the icon // and we have to compensate for its width. if (isSelectionCheckBoxesEnabled()) { - auto style = this->style(); int checkboxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth) + style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); iconRect.adjust(checkboxWidth, 0, 0, 0); } + int const margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; + iconRect.adjust(margin, 0, 0, 0); + // We are interested in the first icon (visibility icon) iconRect.setWidth(iconSize()); From 9c9f1b0a5db447ba09fda81af5f13f7a5b0fc838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Sun, 2 Jun 2024 14:22:41 +0200 Subject: [PATCH 2/5] Increase space between visibility icon and normal icon Adds PM_LayoutHorizontalSpacing betweenthe visibility icon and the normal icon. --- src/Gui/Tree.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 3432e8ad63..03b088e422 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -5335,17 +5335,19 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2 // Prepend the visibility pixmap to the final icon pixmaps and use these as the icon. QIcon new_icon; + auto style = this->getTree()->style(); + int const spacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); for (auto state: {QIcon::On, QIcon::Off}) { QPixmap px_org = icon.pixmap(0xFFFF, 0xFFFF, QIcon::Normal, state); - QPixmap px(2*px_org.width(), px_org.height()); + QPixmap px(2*px_org.width() + spacing, px_org.height()); px.fill(Qt::transparent); QPainter pt; pt.begin(&px); pt.setPen(Qt::NoPen); pt.drawPixmap(0, 0, px_org.width(), px_org.height(), (currentStatus & Status::Visible) ? pxVisible : pxInvisible); - pt.drawPixmap(px_org.width(), 0, px_org.width(), px_org.height(), px_org); + pt.drawPixmap(px_org.width() + spacing, 0, px_org.width(), px_org.height(), px_org); pt.end(); new_icon.addPixmap(px, QIcon::Normal, state); From 198c29b816716258e7d5a46bc4c60e948f98ec74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Thu, 30 May 2024 15:08:45 +0200 Subject: [PATCH 3/5] Gray out hidden items regardless of the visibility icon setting --- src/Gui/Tree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 03b088e422..c05aed9ad8 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -5217,7 +5217,7 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2 previousStatus = currentStatus; QIcon::Mode mode = QIcon::Normal; - if (isVisibilityIconEnabled() || (currentStatus & Status::Visible)) { + if (currentStatus & Status::Visible) { // Note: By default the foreground, i.e. text color is invalid // to make use of the default color of the tree widget's palette. // If we temporarily set this color to dark and reset to an invalid From 5e21c4cd0c5db425f35c51a295169ef1fd5e2974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Thu, 30 May 2024 15:29:06 +0200 Subject: [PATCH 4/5] Use a gray invisible icon for the tree --- src/Gui/Icons/TreeItemInvisible.svg | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Gui/Icons/TreeItemInvisible.svg b/src/Gui/Icons/TreeItemInvisible.svg index 69b78db09a..fc8c703321 100644 --- a/src/Gui/Icons/TreeItemInvisible.svg +++ b/src/Gui/Icons/TreeItemInvisible.svg @@ -2,20 +2,20 @@ + inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" + sodipodi:docname="TreeItemInvisible.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + inkscape:snap-global="true" + inkscape:showpageshadow="2" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1"> + snapvisiblegridlinesonly="true" + originx="0" + originy="0" + spacingy="1" + spacingx="1" + units="px" /> @@ -587,7 +595,7 @@ style="opacity:0.8479996;fill:#ffffff;stroke:none;stroke-width:0.18025407;stroke-opacity:1" /> Date: Sun, 2 Jun 2024 14:24:20 +0200 Subject: [PATCH 5/5] Change visibility icon default to enabled --- src/Gui/TreeParams.cpp | 6 +++--- src/Gui/TreeParams.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Gui/TreeParams.cpp b/src/Gui/TreeParams.cpp index acbe950640..81421cea17 100644 --- a/src/Gui/TreeParams.cpp +++ b/src/Gui/TreeParams.cpp @@ -157,7 +157,7 @@ public: funcs["ColumnSize2"] = &TreeParamsP::updateColumnSize2; TreeToolTipIcon = handle->GetBool("TreeToolTipIcon", false); funcs["TreeToolTipIcon"] = &TreeParamsP::updateTreeToolTipIcon; - VisibilityIcon = handle->GetBool("VisibilityIcon", false); + VisibilityIcon = handle->GetBool("VisibilityIcon", true); funcs["VisibilityIcon"] = &TreeParamsP::updateVisibilityIcon; } @@ -395,7 +395,7 @@ public: } // Auto generated code (Tools/params_utils.py:296) static void updateVisibilityIcon(TreeParamsP *self) { - auto v = self->handle->GetBool("VisibilityIcon", false); + auto v = self->handle->GetBool("VisibilityIcon", true); if (self->VisibilityIcon != v) { self->VisibilityIcon = v; TreeParams::onVisibilityIconChanged(); @@ -1407,7 +1407,7 @@ const bool & TreeParams::getVisibilityIcon() { // Auto generated code (Tools/params_utils.py:366) const bool & TreeParams::defaultVisibilityIcon() { - const static bool def = false; + const static bool def = true; return def; } diff --git a/src/Gui/TreeParams.py b/src/Gui/TreeParams.py index a640753ca8..6db88a1e7a 100644 --- a/src/Gui/TreeParams.py +++ b/src/Gui/TreeParams.py @@ -80,7 +80,7 @@ Params = [ ParamInt('ColumnSize1', 0), ParamInt('ColumnSize2', 0), ParamBool('TreeToolTipIcon', False, title='Show icon in tool tip'), - ParamBool('VisibilityIcon', False, on_change=True, title='Show visibility icon', + ParamBool('VisibilityIcon', True, on_change=True, title='Show visibility icon', doc = "If enabled, show an eye icon before the tree view items, showing the items visibility status. When clicked the visibility is toggled"), ]