Add NeoUI 240x320 UI SDK, migrate all GUI plugins, add Yabasic FFI wrapper and fix camera rotation
This commit is contained in:
1 parent
1f9138f0c6
commit
c137feee0e
59 files changed
+5932
-2128
No files matched your search
@@ -247,11 +247,6 @@ void saveRingSettings(const RingSettings& s) {
|
||||
runAsyncCmd("sxmo_hook_statusbar.sh audio >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
std::string formatFileSize(off_t bytes) {
|
||||
if (bytes < 1024) return std::to_string(bytes) + " B";
|
||||
return std::to_string((bytes + 512) / 1024) + " KB";
|
||||
}
|
||||
|
||||
int runRingtonesApp(int argc, char** argv) {
|
||||
gRunning = 1;
|
||||
std::setlocale(LC_ALL, "");
|
||||
@@ -283,50 +278,20 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
sigaction(SIGTERM, &sa, nullptr);
|
||||
|
||||
Display* dpy = XOpenDisplay(nullptr);
|
||||
if (!dpy) {
|
||||
NeoWindow neo;
|
||||
if (!neo.create("xringtones", "XRingtones", "Ringtones",
|
||||
kWinX, kWinY, kWinWidth, kWinHeight)) {
|
||||
if (fifoFd >= 0) ::close(fifoFd);
|
||||
::unlink(daemonPidPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(dpy);
|
||||
Window root = RootWindow(dpy, screen);
|
||||
Visual* visual = DefaultVisual(dpy, screen);
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
|
||||
ThemeSpec initSpec;
|
||||
initSpec.loadActive(dpy, screen);
|
||||
|
||||
XSetWindowAttributes swa {};
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = initSpec.bgMain;
|
||||
swa.border_pixel = initSpec.selBg;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
|
||||
VisibilityChangeMask | StructureNotifyMask;
|
||||
|
||||
Window win = XCreateWindow(
|
||||
dpy, root, kWinX, kWinY, kWinWidth, kWinHeight, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent, visual,
|
||||
CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWEventMask, &swa);
|
||||
|
||||
XClassHint ch {};
|
||||
char resName[] = "xringtones";
|
||||
char resClass[] = "XRingtones";
|
||||
ch.res_name = resName;
|
||||
ch.res_class = resClass;
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
XStoreName(dpy, win, "Ringtones");
|
||||
|
||||
Pixmap pix = XCreatePixmap(dpy, win, kWinWidth, kWinHeight,
|
||||
DefaultDepth(dpy, screen));
|
||||
GC gc = XCreateGC(dpy, pix, 0, nullptr);
|
||||
XftDraw* xftDraw = XftDrawCreate(dpy, pix, visual, cmap);
|
||||
|
||||
PluginTheme pt;
|
||||
pt.init(dpy, screen, visual, cmap, win);
|
||||
auto& layoutMain = pt.layoutMain;
|
||||
auto& layoutSmall = pt.layoutSmall;
|
||||
Display* dpy = neo.dpy;
|
||||
Window win = neo.win;
|
||||
Pixmap pix = neo.pix;
|
||||
GC gc = neo.gc;
|
||||
PluginTheme& pt = neo.theme;
|
||||
auto& layoutMain = neo.layoutMain;
|
||||
auto& layoutSmall = neo.layoutSmall;
|
||||
auto& colWhite = pt.colWhite;
|
||||
auto& colLight = pt.colLight;
|
||||
auto& colMuted = pt.colMuted;
|
||||
@@ -448,35 +413,13 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
int h, const std::string& text, int maxW = -1,
|
||||
int align = 0) {
|
||||
if (text.empty()) return;
|
||||
pango_layout_set_text(layout, text.c_str(), -1);
|
||||
if (maxW > 0) {
|
||||
pango_layout_set_width(layout, maxW * PANGO_SCALE);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
} else {
|
||||
pango_layout_set_width(layout, -1);
|
||||
}
|
||||
int tw = 0, th = 0;
|
||||
pango_layout_get_pixel_size(layout, &tw, &th);
|
||||
int tx = x;
|
||||
if (align == 1 && maxW > 0) tx = x + (maxW - tw) / 2;
|
||||
else if (align == 2 && maxW > 0) tx = x + maxW - tw;
|
||||
int ty = y + (h - th) / 2;
|
||||
pango_xft_render_layout(xftDraw, color, layout, tx * PANGO_SCALE,
|
||||
ty * PANGO_SCALE);
|
||||
neo.drawPango(layout, color, x, y, h, text, maxW, align);
|
||||
};
|
||||
|
||||
auto drawSoftkeyBar = [&](const std::string& leftLabel,
|
||||
const std::string& midLabel,
|
||||
const std::string& rightLabel) {
|
||||
int barY = kWinHeight - 24;
|
||||
XSetForeground(dpy, gc, pt.spec.bgHeader);
|
||||
XFillRectangle(dpy, pix, gc, 0, barY, kWinWidth, 24);
|
||||
XSetForeground(dpy, gc, pt.spec.border);
|
||||
XDrawLine(dpy, pix, gc, 0, barY, kWinWidth, barY);
|
||||
|
||||
drawPango(layoutSmall, &colLight, 6, barY, 24, leftLabel, 76, 0);
|
||||
drawPango(layoutMain, &colYellow, 82, barY, 24, midLabel, 76, 1);
|
||||
drawPango(layoutSmall, &colLight, 158, barY, 24, rightLabel, 76, 2);
|
||||
neo.drawSoftbar(leftLabel, midLabel, rightLabel, &colYellow, 24);
|
||||
};
|
||||
|
||||
auto render = [&]() {
|
||||
@@ -913,11 +856,6 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
hideWindow();
|
||||
if (fifoFd >= 0) ::close(fifoFd);
|
||||
::unlink(daemonPidPath.c_str());
|
||||
if (xftDraw) XftDrawDestroy(xftDraw);
|
||||
XFreeGC(dpy, gc);
|
||||
XFreePixmap(dpy, pix);
|
||||
XDestroyWindow(dpy, win);
|
||||
XCloseDisplay(dpy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user