cutest version!!
parent
9888093c9c
commit
9936509ffb
|
|
@ -42,7 +42,7 @@
|
||||||
Bangle.drawWidgets = () => { };
|
Bangle.drawWidgets = () => { };
|
||||||
Bangle.loadWidgets = () => { };
|
Bangle.loadWidgets = () => { };
|
||||||
|
|
||||||
const ITEM_HEIGHT = 110;
|
const ITEM_HEIGHT = 100;
|
||||||
|
|
||||||
E.showScroller({
|
E.showScroller({
|
||||||
h: ITEM_HEIGHT,
|
h: ITEM_HEIGHT,
|
||||||
|
|
@ -55,31 +55,75 @@
|
||||||
let icon = apps[idx].icon;
|
let icon = apps[idx].icon;
|
||||||
let iconWidth = icon.width || 48;
|
let iconWidth = icon.width || 48;
|
||||||
let iconHeight = icon.height || 48;
|
let iconHeight = icon.height || 48;
|
||||||
let maxSize = 70;
|
let maxSize = 45;
|
||||||
let scale = Math.min(maxSize / iconWidth, maxSize / iconHeight);
|
let scale = Math.min(maxSize / iconWidth, maxSize / iconHeight);
|
||||||
let scaledHeight = Math.floor(iconHeight * scale);
|
let scaledHeight = Math.floor(iconHeight * scale);
|
||||||
|
|
||||||
// Center the icon horizontally
|
// Center the icon horizontally
|
||||||
let iconX = rect.x + (rect.w - maxSize) / 2;
|
let iconX = rect.x + (rect.w - maxSize) / 2;
|
||||||
g.drawImage(icon, iconX, rect.y, { scale: scale });
|
|
||||||
|
|
||||||
// Draw app name with ellipsis if needed
|
// Define rectangle size (independent of icon size)
|
||||||
let name = apps[idx].name;
|
const rectSize = 80;
|
||||||
let maxWidth = rect.w - 80; // Leave some padding
|
const rectX = rect.x + (rect.w - rectSize) / 2;
|
||||||
let textWidth = g.stringWidth(name);
|
|
||||||
|
|
||||||
|
// Draw rounded rectangle background using polygon
|
||||||
|
g.setColor(g.theme.bg2);
|
||||||
|
const r = 15;
|
||||||
|
const x1 = rectX - 5;
|
||||||
|
const y1 = rect.y + 5;
|
||||||
|
const x2 = rectX + rectSize + 5;
|
||||||
|
const y2 = rect.y + rectSize + 10;
|
||||||
|
|
||||||
|
// Create points for a rounded rectangle (approximating curves with more points per corner)
|
||||||
|
g.fillPoly([
|
||||||
|
x1 + r, y1, // Top edge
|
||||||
|
x2 - r, y1,
|
||||||
|
x2 - r * 0.7, y1,
|
||||||
|
x2 - r * 0.4, y1 + r * 0.1,
|
||||||
|
x2 - r * 0.1, y1 + r * 0.4, // Top right corner
|
||||||
|
x2, y1 + r * 0.7,
|
||||||
|
x2, y1 + r,
|
||||||
|
x2, y2 - r, // Right edge
|
||||||
|
x2, y2 - r * 0.7,
|
||||||
|
x2 - r * 0.1, y2 - r * 0.4,
|
||||||
|
x2 - r * 0.4, y2 - r * 0.1, // Bottom right corner
|
||||||
|
x2 - r * 0.7, y2,
|
||||||
|
x2 - r, y2,
|
||||||
|
x1 + r, y2, // Bottom edge
|
||||||
|
x1 + r * 0.7, y2,
|
||||||
|
x1 + r * 0.4, y2 - r * 0.1,
|
||||||
|
x1 + r * 0.1, y2 - r * 0.4, // Bottom left corner
|
||||||
|
x1, y2 - r * 0.7,
|
||||||
|
x1, y2 - r,
|
||||||
|
x1, y1 + r, // Left edge
|
||||||
|
x1, y1 + r * 0.7,
|
||||||
|
x1 + r * 0.1, y1 + r * 0.4,
|
||||||
|
x1 + r * 0.4, y1 + r * 0.1, // Top left corner
|
||||||
|
x1 + r * 0.7, y1
|
||||||
|
]);
|
||||||
|
g.setColor(g.theme.fg);
|
||||||
|
|
||||||
|
// Draw icon centered in the top portion
|
||||||
|
let iconPadding = 8;
|
||||||
|
// Center icon within the rectangle
|
||||||
|
let iconXInRect = rectX + (rectSize - maxSize) / 2;
|
||||||
|
g.setBgColor(g.theme.bg2).drawImage(icon, iconXInRect, rect.y + iconPadding + 8, { scale: scale });
|
||||||
|
|
||||||
|
// Draw app name with ellipsis if too long
|
||||||
|
const maxWidth = rectSize - 8;
|
||||||
|
let text = apps[idx].name;
|
||||||
|
let textWidth = g.stringWidth(text);
|
||||||
if (textWidth > maxWidth) {
|
if (textWidth > maxWidth) {
|
||||||
// Add ellipsis and truncate text
|
const ellipsis = "...";
|
||||||
while (textWidth > maxWidth - g.stringWidth("...") && name.length > 1) {
|
const ellipsisWidth = g.stringWidth(ellipsis);
|
||||||
name = name.slice(0, -1);
|
while (textWidth + ellipsisWidth > maxWidth && text.length > 0) {
|
||||||
textWidth = g.stringWidth(name);
|
text = text.slice(0, -1);
|
||||||
|
textWidth = g.stringWidth(text);
|
||||||
}
|
}
|
||||||
name += "...";
|
text = text + ellipsis;
|
||||||
}
|
}
|
||||||
|
let textY = rect.y + iconPadding + scaledHeight + 15;
|
||||||
// Position text below icon with padding
|
g.drawString(text, rectX + rectSize / 2, textY);
|
||||||
let textY = rect.y + scaledHeight + 4;
|
|
||||||
g.drawString(name, rect.x + rect.w / 2, textY);
|
|
||||||
},
|
},
|
||||||
select: (idx) => {
|
select: (idx) => {
|
||||||
// Launch the selected app
|
// Launch the selected app
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "cutelauncher",
|
"id": "cutelauncher",
|
||||||
"name": "Cute Launcher",
|
"name": "Cute Launcher",
|
||||||
"version": "0.09",
|
"version": "0.1",
|
||||||
"description": "A simple launcher app for Bangle.js 2 that makes use of the full touchscreen",
|
"description": "A simple launcher app for Bangle.js 2 that makes use of the full touchscreen",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue