[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 10 14:21:35 UTC 2020
include/vcl/treelistentry.hxx | 4 ++++
include/vcl/weld.hxx | 2 ++
vcl/source/app/salvtables.cxx | 7 +++++++
vcl/source/treelist/treelistbox.cxx | 3 +--
vcl/source/treelist/treelistentry.cxx | 4 +++-
vcl/unx/gtk3/gtk3gtkinst.cxx | 24 ++++++++++++++++++++++++
6 files changed, 41 insertions(+), 3 deletions(-)
New commits:
commit 0ddc588164c4a9a0fca7374a58ea1f7708978f66
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Mar 10 13:10:12 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 10 15:20:58 2020 +0100
writer navigator requires ability of per-row extra indent
Change-Id: Iaf34e245b2418c0dddb9a8a449da1a0abdd8def2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90257
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/treelistentry.hxx b/include/vcl/treelistentry.hxx
index 456a99c3fd67..8cc808bb09c1 100644
--- a/include/vcl/treelistentry.hxx
+++ b/include/vcl/treelistentry.hxx
@@ -60,6 +60,7 @@ class VCL_DLLPUBLIC SvTreeListEntry
SvTreeListEntries m_Children;
sal_uLong nAbsPos;
sal_uLong nListPos;
+ sal_uInt32 mnExtraIndent;
ItemsType m_Items;
void* pUserData;
SvTLEntryFlags nEntryFlags;
@@ -115,6 +116,9 @@ public:
void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
std::optional<Color> const & GetTextColor() const { return mxTextColor; }
+ void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
+ sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
+
SvTreeListEntry* GetParent() const { return pParent; }
SvTreeListEntry* NextSibling() const;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 936484a31d0c..838fb2729f04 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -931,6 +931,8 @@ public:
virtual bool get_row_expanded(const TreeIter& rIter) const = 0;
virtual bool get_children_on_demand(const TreeIter& rIter) const = 0;
virtual void set_children_on_demand(const TreeIter& rIter, bool bChildrenOnDemand) = 0;
+ //visually indent this row as if it was at get_iter_depth() + nIndentLevel
+ virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0;
virtual void expand_row(const TreeIter& rIter) = 0;
virtual void collapse_row(const TreeIter& rIter) = 0;
virtual void set_text(const TreeIter& rIter, const OUString& rStr, int col = -1) = 0;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 5fa320af8dbc..7fc78bf5ef0b 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3885,6 +3885,13 @@ public:
set_toggle(rVclIter.iter, eState, col);
}
+ virtual void set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) override
+ {
+ weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter);
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter);
+ rVclIter.iter->SetExtraIndent(nIndentLevel);
+ }
+
void set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, int col)
{
++col; //skip dummy/expander column
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index c17c9c78a0eb..6c25d2fd658e 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -2986,7 +2986,6 @@ tools::Rectangle SvTreeListBox::GetFocusRect( SvTreeListEntry* pEntry, long nLin
return aRect;
}
-
sal_IntPtr SvTreeListBox::GetTabPos( SvTreeListEntry* pEntry, SvLBoxTab* pTab)
{
assert(pTab);
@@ -2997,7 +2996,7 @@ sal_IntPtr SvTreeListBox::GetTabPos( SvTreeListEntry* pEntry, SvLBoxTab* pTab)
nDepth = nDepth * static_cast<sal_uInt16>(nIndent);
nPos += static_cast<sal_IntPtr>(nDepth);
}
- return nPos;
+ return nPos + (pEntry->GetExtraIndent() * nIndent);
}
SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX,
diff --git a/vcl/source/treelist/treelistentry.cxx b/vcl/source/treelist/treelistentry.cxx
index 8d397d228a9b..d380866cfc7a 100644
--- a/vcl/source/treelist/treelistentry.cxx
+++ b/vcl/source/treelist/treelistentry.cxx
@@ -51,6 +51,7 @@ SvTreeListEntry::SvTreeListEntry()
: pParent(nullptr)
, nAbsPos(0)
, nListPos(0)
+ , mnExtraIndent(0)
, pUserData(nullptr)
, nEntryFlags(SvTLEntryFlags::NONE)
, maBackColor(Application::GetSettings().GetStyleSettings().GetWindowColor())
@@ -89,7 +90,8 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource)
{
nListPos &= 0x80000000;
nListPos |= ( pSource->nListPos & 0x7fffffff);
- nAbsPos = pSource->nAbsPos;
+ nAbsPos = pSource->nAbsPos;
+ mnExtraIndent = pSource->mnExtraIndent;
m_Items.clear();
for (auto const& it : pSource->m_Items)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 23dc0c65825a..a044fd906289 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8622,6 +8622,8 @@ private:
std::map<int, int> m_aWeightMap;
// map from text column to sensitive column
std::map<int, int> m_aSensitiveMap;
+ // map from text column to indent column
+ std::map<int, int> m_aIndentMap;
// currently expanding parent that logically, but not currently physically,
// contain placeholders
o3tl::sorted_vector<GtkTreeIter, CompareGtkTreeIter> m_aExpandingPlaceHolderParents;
@@ -9182,6 +9184,19 @@ private:
}
}
+ int get_expander_size() const
+ {
+ gint nExpanderSize;
+ gint nHorizontalSeparator;
+
+ gtk_widget_style_get(GTK_WIDGET(m_pTreeView),
+ "expander-size", &nExpanderSize,
+ "horizontal-separator", &nHorizontalSeparator,
+ nullptr);
+
+ return nExpanderSize + (nHorizontalSeparator/ 2);
+ }
+
public:
GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership)
@@ -9221,6 +9236,7 @@ public:
m_nTextCol = nIndex;
m_aWeightMap[nIndex] = -1;
m_aSensitiveMap[nIndex] = -1;
+ m_aIndentMap[nIndex] = -1;
g_signal_connect(G_OBJECT(pCellRenderer), "editing-started", G_CALLBACK(signalCellEditingStarted), this);
g_signal_connect(G_OBJECT(pCellRenderer), "editing-canceled", G_CALLBACK(signalCellEditingCanceled), this);
g_signal_connect(G_OBJECT(pCellRenderer), "edited", G_CALLBACK(signalCellEdited), this);
@@ -9256,6 +9272,8 @@ public:
a.second = nIndex++;
for (auto& a : m_aSensitiveMap)
a.second = nIndex++;
+ for (auto& a : m_aIndentMap)
+ a.second = nIndex++;
ensure_drag_begin_end();
@@ -9775,6 +9793,12 @@ public:
}
}
+ virtual void set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) override
+ {
+ const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
+ set(rGtkIter.iter, m_aIndentMap[m_nTextCol], nIndentLevel * get_expander_size());
+ }
+
virtual void set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) override
{
const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
More information about the Libreoffice-commits
mailing list