menu: limit enum text length
authornotaz <notasas@gmail.com>
Sat, 10 Dec 2011 23:32:30 +0000 (23:32 +0000)
committernotaz <notasas@gmail.com>
Sat, 10 Dec 2011 23:32:30 +0000 (23:32 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@939 be3aeb3a-fb24-0410-a615-afba39da0efa

common/menu.c

index 1513d39..d76eda4 100644 (file)
@@ -482,7 +482,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
        for (ent = entries; ent->name; ent++)\r
        {\r
                const char **names;\r
-               int len;\r
+               int len, leftname_end = 0;\r
 \r
                if (!ent->enabled)\r
                        continue;\r
@@ -492,8 +492,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
                        if (ent->generate_name)\r
                                name = ent->generate_name(ent->id, &offs);\r
                }\r
-               if (name != NULL)\r
+               if (name != NULL) {\r
                        text_out16(x, y, name);\r
+                       leftname_end = x + (strlen(name) + 1) * me_mfont_w;\r
+               }\r
 \r
                switch (ent->beh) {\r
                case MB_NONE:\r
@@ -516,13 +518,15 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
                        break;\r
                case MB_OPT_ENUM:\r
                        names = (const char **)ent->data;\r
-                       offs = 0;\r
                        for (i = 0; names[i] != NULL; i++) {\r
+                               offs = x + col2_offs;\r
                                len = strlen(names[i]);\r
                                if (len > 10)\r
-                                       offs = 10 - len - 2;\r
+                                       offs += (10 - len - 2) * me_mfont_w;\r
+                               if (offs < leftname_end)\r
+                                       offs = leftname_end;\r
                                if (i == *(unsigned char *)ent->var) {\r
-                                       text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]);\r
+                                       text_out16(offs, y, "%s", names[i]);\r
                                        break;\r
                                }\r
                        }\r