diff --git a/comp/src/gb.gui.base/.project b/comp/src/gb.gui.base/.project index c77a55b9b..3b6a830d0 100644 --- a/comp/src/gb.gui.base/.project +++ b/comp/src/gb.gui.base/.project @@ -1,6 +1,6 @@ # Gambas Project File 3.0 Title=Common controls and classes for GUI components -Startup=FLabel +Startup=FTestIconView Icon=.hidden/window.png Version=3.16.90 VersionFile=1 @@ -8,7 +8,7 @@ Component=gb.image Component=gb.gui Component=gb.settings Arguments=[["-style=oxygen"],["-style=qtcurve"]] -Environment="GB_JIT_DEBUG=1\nGB_GUI=gb.gtk3\nLIBOVERLAY_SCROLLBAR=0\n GTK_DEBUG=interactive" +Environment="GB_JIT_DEBUG=1\nGB_GUI=gb.qt5\nLIBOVERLAY_SCROLLBAR=0\n GTK_DEBUG=interactive" TabSize=2 Translate=1 Language=en diff --git a/comp/src/gb.gui.base/.src/IconView/IconView.class b/comp/src/gb.gui.base/.src/IconView/IconView.class index 02cacc6dc..b21fa2bf0 100644 --- a/comp/src/gb.gui.base/.src/IconView/IconView.class +++ b/comp/src/gb.gui.base/.src/IconView/IconView.class @@ -107,6 +107,8 @@ Private $fFindTime As Float Private $iLock As Integer Private $hArrangeTimer As Timer +Private $cTrimTextCache As New Collection + Public Sub _new() $hView = New ScrollArea(Me) As "ScrollArea" @@ -534,6 +536,8 @@ Public Sub ScrollArea_Arrange() Dim W, H As Integer Dim nRow As Integer Dim DS As Integer + Dim iOldGridHeight As Integer + Dim iOldGridWidth As Integer If $iLock Then Return @@ -550,6 +554,9 @@ Public Sub ScrollArea_Arrange() ExitRename + iOldGridHeight = $iGridHeight + iOldGridWidth = $iGridWidth + If $bHorizontal Then $iGridHeight = Max(DS, $iIconSize) + DS * 2 @@ -594,6 +601,8 @@ Public Sub ScrollArea_Arrange() Endif + If iOldGridWidth <> $iGridWidth Or If iOldGridHeight <> $iGridHeight Then $cTrimTextCache.Clear + End Public Sub ScrollArea_Resize() @@ -1620,6 +1629,8 @@ Public Sub ScrollArea_Font() Dim hItem As _IconView_Item + $cTrimTextCache.Clear + For Each hItem In $aItems hItem._Invalidate Next @@ -1628,6 +1639,12 @@ Public Sub ScrollArea_Font() End +Public Sub _GetTrimTextCache() As Collection + + Return $cTrimTextCache + +End + Private Function Keys_Read() As String[] Dim aKeys As New String[] diff --git a/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class b/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class index f689b8f3e..4e670b6dc 100644 --- a/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class +++ b/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class @@ -357,7 +357,7 @@ Public Sub _Draw(hRect As Rect, hClip As Rect, hIconView As IconView, bHorizonta HT = hRect.H + DS \ 2 If H > HT Then - sText = Paint.TrimRichText(sText, W, HT) + sText = MyTrimRichText(sText, W, HT) $bEllipsized = True Else $bEllipsized = False @@ -413,7 +413,7 @@ Public Sub _Draw(hRect As Rect, hClip As Rect, hIconView As IconView, bHorizonta HT = hRect.H - (Y - hRect.Y) If H > HT Then - sText = Paint.TrimRichText(sText, hRect.W, HT) + sText = MyTrimRichText(sText, hRect.W, HT) $bEllipsized = True Else $bEllipsized = False @@ -794,3 +794,26 @@ Private Sub Tag_Write(Value As Variant) $vTag = Value End + +Private Sub MyTrimRichText(RichText As String, W As Float, Optional H As Float) As String + + Dim sResult As String + Dim cCache As Collection + + cCache = GetIconView()._GetTrimTextCache() + sResult = cCache[RichText] + If Not sResult Then + sResult = Paint.TrimRichText(RichText, W, H) + cCache[RichText] = sResult + If cCache.Count > 256 Then + For Each cCache + cCache.Remove(cCache.Key) + Break + Next + Endif + Endif + + Return sResult + +End + diff --git a/comp/src/gb.gui.base/.src/Paint.class b/comp/src/gb.gui.base/.src/Paint.class index 29922475f..3b12f7a19 100644 --- a/comp/src/gb.gui.base/.src/Paint.class +++ b/comp/src/gb.gui.base/.src/Paint.class @@ -167,7 +167,7 @@ Static Public Sub TrimRichText(RichText As String, W As Float, Optional H As Flo If bMarkup Then Continue sPrevLeft = sLeft sLeft = HtmlLeft(RichText, I) - If Paint.Font.RichTextHeight(sLeft, W) > H Then Break + If Paint.Font.RichTextHeight(AddThreeDots(sLeft), W) > H Then Break Next If I = 1 Then Return diff --git a/comp/src/gb.gui.base/.src/Test/FTestIconView.form b/comp/src/gb.gui.base/.src/Test/FTestIconView.form index 886540579..97b7ed04e 100644 --- a/comp/src/gb.gui.base/.src/Test/FTestIconView.form +++ b/comp/src/gb.gui.base/.src/Test/FTestIconView.form @@ -25,5 +25,6 @@ Sorted = True Editable = True GridSize = 24 + IconLines = 3 } }