From f603fcdb727819eca0d79e1c90fd0331b71f5c49 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 6 Sep 2021 16:54:40 -0700 Subject: [PATCH] mGUI: Add 9-slice drawing --- include/mgba-util/gui/font.h | 33 ++++++++++++++++++++++ res/icons.png | Bin 619 -> 663 bytes res/icons2x.png | Bin 1421 -> 1494 bytes src/util/gui/font-metrics.c | 25 +++++++++++++++++ src/util/gui/font.c | 52 +++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) diff --git a/include/mgba-util/gui/font.h b/include/mgba-util/gui/font.h index 1751898c3..5ad318e65 100644 --- a/include/mgba-util/gui/font.h +++ b/include/mgba-util/gui/font.h @@ -59,6 +59,31 @@ enum GUIIcon { GUI_ICON_UP, GUI_ICON_RIGHT, GUI_ICON_DOWN, + GUI_ICON_9SLICE_EMPTY_NW, + GUI_ICON_9SLICE_EMPTY_N, + GUI_ICON_9SLICE_EMPTY_NE, + GUI_ICON_9SLICE_EMPTY_W, + GUI_ICON_9SLICE_EMPTY_E, + GUI_ICON_9SLICE_EMPTY_SW, + GUI_ICON_9SLICE_EMPTY_S, + GUI_ICON_9SLICE_EMPTY_SE, + GUI_ICON_9SLICE_FILLED_NW, + GUI_ICON_9SLICE_FILLED_N, + GUI_ICON_9SLICE_FILLED_NE, + GUI_ICON_9SLICE_FILLED_W, + GUI_ICON_9SLICE_FILLED_C, + GUI_ICON_9SLICE_FILLED_E, + GUI_ICON_9SLICE_FILLED_SW, + GUI_ICON_9SLICE_FILLED_S, + GUI_ICON_9SLICE_FILLED_SE, + GUI_ICON_9SLICE_CAP_NNW, + GUI_ICON_9SLICE_CAP_NWW, + GUI_ICON_9SLICE_CAP_NNE, + GUI_ICON_9SLICE_CAP_NEE, + GUI_ICON_9SLICE_CAP_SSW, + GUI_ICON_9SLICE_CAP_SWW, + GUI_ICON_9SLICE_CAP_SSE, + GUI_ICON_9SLICE_CAP_SEE, GUI_ICON_MAX, }; @@ -80,6 +105,12 @@ struct GUIIconMetric { int height; }; +enum GUI9SliceStyle { + GUI_9SLICE_FILLED, + GUI_9SLICE_EMPTY, + GUI_9SLICE_EMPTY_CAPPED, +}; + unsigned GUIFontHeight(const struct GUIFont*); unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph); unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text); @@ -96,6 +127,8 @@ void GUIFontDrawIconSize(struct GUIFont* font, int x, int y, int w, int h, uint3 void GUIFontDrawSubmit(struct GUIFont* font); #endif +void GUIFontDraw9Slice(struct GUIFont*, int x, int y, int width, int height, uint32_t color, enum GUI9SliceStyle style); + CXX_GUARD_END #endif diff --git a/res/icons.png b/res/icons.png index b52df6688a4da7d6a5b85df6d7fe4146a0c0282c..1b75cddd9aea8606378eab9000b6d1919ae55c5c 100644 GIT binary patch delta 604 zcmV-i0;B!w1eXPnMt=cxQchCC|3|mGR3#6L z*x@C~Os96^x|;(DH_&Z!o57%1i9fyX?(;E@9|($_cUb=9Nxv_v0JQfHh`t@N$3P77dnZe#N06xI@PtLzn*Zk?IaX%Y#;(u4>B+O}xi};HOH~_elbZDT{>wFvacw z7E6JI02VERtbb>%D~ua#i$7TgYo@)jJ5={zq#OW3&9oO^ruNa;(;3iC4p%-LEtbYx z{xjU%rrdYadOLbVujbqBe$eoD&L>*awXGy}ZEjt|uD;#&7u5L4QAGSU*)6j}chGa7 zfQyo;EE&K!0KTCEX*}TZlV~BN7@H5+%taHdyFkbI#eb9+BN`YUa=#G9r!YGbJibI~ z$mOPNX8^MM1H@rv@|zH_Y6J?7zXq8Bh&3SxAZqcWj7|r@tO2YjYAJwBccud1DZo-> zyj5U7yiVdJ5r|boJ?@t;p;u>7r~}L#m&+#Z0KoM!IgS$K%1Y* zb8~a6S5=^ty1i6M+84KFYcl@+^^(!|P@D%VO=*yrBA(z5#tJ@FA`VxFT>cda~0000l`&K8 z?T%t+PXxPoqoF`s6c;~D{76K@$I-6Ei)V6bi*folS&5YW1PD0g2JToO=fo1^@pY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