[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    Plugin Api add core bitmaps
From:       rockbox-gerrit-noreply--- via rockbox-cvs <rockbox-cvs () cool ! haxx ! se>
Date:       2021-08-26 12:55:37
Message-ID: 202108261255.17QCtbx51672126 () stuffed ! shaftnet ! org
[Download RAW message or body]

commit b56372bbcb016376cf841fb81b1107832a3fada1
Author: William Wilgus <wilgus.william@gmail.com>
Date:   Thu Aug 19 22:00:36 2021 -0400

    Plugin Api add core bitmaps
    
    share all the core icons with plugins
    these are all small mono icons like usb plug icon or
    play, fast forward, rewind icons
    
    --include the icon_helper function
    
    Change-Id: I385028815a4dd368515f491a9e19dee3d500252d

diff --git a/apps/plugin.c b/apps/plugin.c
index 4877c3d255..30269b39e7 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -178,7 +178,7 @@ static const struct plugin_api rockbox_api = {
     &global_settings,
     &global_status,
     language_strings,
-
+    &core_bitmaps,
     /* lcd */
     splash,
     splashf,
diff --git a/apps/plugin.h b/apps/plugin.h
index bd467bcade..023b442295 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -188,6 +188,7 @@ struct plugin_api {
     struct user_settings* global_settings;
     struct system_status *global_status;
     unsigned char **language_strings;
+    const struct cbmp_bitmap_info_entry *core_bitmaps;
 
     /* lcd */
     void (*splash)(int ticks, const char *str);
@@ -700,7 +701,7 @@ struct plugin_api {
     void (*dsp_eq_enable)(bool enable);
     void (*dsp_dither_enable)(bool enable);
 #ifdef HAVE_PITCHCONTROL
-    void (*dsp_set_timestretch)(int32_t percent);
+    void    (*dsp_set_timestretch)(int32_t percent);
 #endif
     intptr_t (*dsp_configure)(struct dsp_config *dsp,
                               unsigned int setting, intptr_t value);
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES
index 811771e0ca..6d5fe6cb5f 100644
--- a/apps/plugins/lib/SOURCES
+++ b/apps/plugins/lib/SOURCES
@@ -2,6 +2,7 @@ sha1.c
 gcc-support.c
 pluginlib_actions.c
 helper.c
+icon_helper.c
 md5.c
 jhash.c
 configfile.c
diff --git a/apps/plugins/lib/icon_helper.c b/apps/plugins/lib/icon_helper.c
new file mode 100644
index 0000000000..857bddb128
--- /dev/null
+++ b/apps/plugins/lib/icon_helper.c
@@ -0,0 +1,48 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2021 William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "plugin.h"
+#include "icon_helper.h"
+
+const unsigned char* cbmp_get_icon(unsigned int cbmp_fmt, unsigned int index, int *width, int *height)
+{
+    const unsigned char* bmp = NULL;
+    while (cbmp_fmt < CBMP_BitmapFormatLast)
+    {
+        const struct cbmp_bitmap_info_entry *cbmp = &rb->core_bitmaps[cbmp_fmt];
+        if (index > cbmp->count)
+            break;
+        int w = cbmp->width;
+        int h = cbmp->height;
+        /* ((height/CHAR_BIT) Should always be 1 thus far */
+
+        off_t offset = (((unsigned)h/CHAR_BIT) * (index * w));
+        bmp = cbmp->pbmp + offset;
+
+        if (width)
+            *width = w;
+        if (height)
+            *height = h;
+        break;
+    }
+
+    return bmp;
+}
diff --git a/apps/plugins/lib/icon_helper.h b/apps/plugins/lib/icon_helper.h
new file mode 100644
index 0000000000..e30a607a3f
--- /dev/null
+++ b/apps/plugins/lib/icon_helper.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2021 William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _LIB_ICON_HELPER_H_
+#define _LIB_ICON_HELPER_H_
+
+#include "plugin.h"
+const unsigned char* cbmp_get_icon(unsigned int cbmp_fmt, unsigned int index, int *width, int *height);
+#endif /* _LIB_ICON_HELPER_H_ */
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index cc53716674..de623d28b7 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -122,3 +122,11 @@ const unsigned char bitmap_icon_disk[12] =
     {0x00,0x00,0x00,0x1c,0x2e,0x4f,0x77,0x79,0x3a,0x1c,0x00,0x00};
 #endif
 
+const struct cbmp_bitmap_info_entry core_bitmaps[CBMP_BitmapFormatLast] = /* */
+{
+/* index, pointer, w, h, count */
+[CBMP_Mono_5x8] = {bitmap_icons_5x8[0], 5,8, Icon5x8Last},
+[CBMP_Mono_7x8] = {bitmap_icons_7x8[0], 7, 8, Icon7x8Last},
+[CBMP_Mono_12x8] = {bitmap_icon_disk, 12, 8, 1},
+};
+
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index 249453a943..944f319415 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -32,7 +32,25 @@
 #ifdef HAVE_REMOTE_LCD
 #include "bitmaps/remote_rockboxlogo.h"
 #endif
+#endif /* PLUGIN */
+
+struct cbmp_bitmap_info_entry /* */
+{
+    const unsigned char* pbmp;
+    unsigned char width;
+    unsigned char height; /* !ASSUMES MULTIPLES OF 8! */
+    unsigned char count;
+};
+
+enum cbmp_bitmap_format
+{
+    CBMP_Mono_5x8 = 0,
+    CBMP_Mono_7x8,
+    CBMP_Mono_12x8,
+    CBMP_BitmapFormatLast
+};
 
+extern const struct cbmp_bitmap_info_entry core_bitmaps[CBMP_BitmapFormatLast];
 
 /* Symbolic names for icons */
 enum icons_5x8 {
@@ -65,6 +83,12 @@ enum icons_7x8 {
     Icon7x8Last
 };
 
+enum icons_12x8 {
+    Icon_Disk,
+    Icon12x8Last
+};
+
+#ifndef PLUGIN
 #if defined (HAVE_RECORDING)
 #define BM_GLYPH_WIDTH 4
 enum Glyphs_4x8 {
_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
https://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic