[PATCH 1/2] uxtheme: Search TMT_IMAGEFILE1~7 first when drawing background for parts without glyph images.

Zhiyi Zhang zzhang at codeweavers.com
Tue Jan 25 02:00:17 CST 2022


Try TMT_IMAGEFILE first when drawing part background and the part contains glyph images.
Otherwise, search TMT_IMAGEFILE1~7 and then TMT_IMAGEFILE or TMT_GLYPHIMAGEFILE. This behavior can
be verified by drawing scroll bar arrow buttons, where TMT_IMAGEFILE is used for background despite
TMT_IMAGEFILE1 being present and TMT_IMAGEFILE1 is used for glyphs despite TMT_IMAGEFILE is present.
For parts without glyph images, TMT_IMAGEFILE1~7 are always searched first, then try TMT_IMAGEFILE
or TMT_GLYPHIMAGEFILE.

Fix the size grip on status control not being painted when using builtin Light theme. The status
gripper part uses TMT_IMAGEFILE1~7 and doesn't have TMT_IMAGEFILE. So when UXTHEME_SelectImage()
tries to query TMT_IMAGEFILE for status gripper, it falls back to using status class TMT_IMAGEFILE.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/uxtheme/draw.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c
index 4aac46f3fed..709cf522d00 100644
--- a/dlls/uxtheme/draw.c
+++ b/dlls/uxtheme/draw.c
@@ -185,20 +185,23 @@ static int imagefile_index_to_property(int index)
 static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, int iPartId, int iStateId,
                                            const RECT *pRect, BOOL glyph, int *imageDpi)
 {
-    PTHEME_PROPERTY tp;
-    int imageselecttype = IST_NONE;
+    int imageselecttype = IST_NONE, glyphtype = GT_NONE;
+    PTHEME_PROPERTY tp = NULL;
     int i;
-    int image;
-    if(glyph)
-        image = TMT_GLYPHIMAGEFILE;
-    else
-        image = TMT_IMAGEFILE;
 
     if (imageDpi)
         *imageDpi = 96;
 
-    if((tp=MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, image)))
-        return tp;
+    /* Try TMT_IMAGEFILE first when drawing part background and the part contains glyph images.
+     * Otherwise, search TMT_IMAGEFILE1~7 and then TMT_IMAGEFILE or TMT_GLYPHIMAGEFILE */
+    if (!glyph)
+    {
+        GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_GLYPHTYPE, &glyphtype);
+        if (glyphtype == GT_IMAGEGLYPH &&
+            (tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, TMT_IMAGEFILE)))
+                return tp;
+    }
+
     GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_IMAGESELECTTYPE, &imageselecttype);
 
     if(imageselecttype == IST_DPI) {
@@ -223,7 +226,7 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, int iPartId, int iStat
             }
         }
         /* If an image couldn't be selected, choose the first one */
-        return MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, TMT_IMAGEFILE1);
+        tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, TMT_IMAGEFILE1);
     }
     else if(imageselecttype == IST_SIZE) {
         POINT size = {pRect->right-pRect->left, pRect->bottom-pRect->top};
@@ -270,9 +273,13 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, int iPartId, int iStat
             }
         }
         /* If an image couldn't be selected, choose the smallest one */
-        return MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, TMT_IMAGEFILE1);
+        tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, TMT_IMAGEFILE1);
     }
-    return NULL;
+
+    if (!tp)
+        tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME,
+                                   glyph ? TMT_GLYPHIMAGEFILE : TMT_IMAGEFILE);
+    return tp;
 }
 
 /***********************************************************************
-- 
2.32.0




More information about the wine-devel mailing list