add initial saver program

This commit is contained in:
Andrew Pamment 2023-05-21 22:19:48 +10:00
parent 65cada6951
commit afcf23e775
6 changed files with 2054 additions and 25 deletions

17
gui.c
View File

@ -22,6 +22,7 @@ struct gui_colour_scheme_t sys_color;
// extern const struct bitmap_font font; // extern const struct bitmap_font font;
#define WIN_REQ_FLAG_NO_TITLE 0x01 #define WIN_REQ_FLAG_NO_TITLE 0x01
#define WIN_REQ_FLAG_NO_MOUSE 0x02
#define BochsBreak() \ #define BochsBreak() \
outportw(0x8A00, 0x8A00); \ outportw(0x8A00, 0x8A00); \
@ -851,8 +852,22 @@ void gui_flip() {
} }
// draw mouse // draw mouse
gui_display_pointer(); int mouse_visible = 1;
for (i = ptr_vector_len(&vwindows) - 1; i >= 0; i--) {
struct window_t *win = (struct window_t *)ptr_vector_get(&vwindows, i);
if (!win->minimized) {
if (mouse_pos_x >= win->posx && mouse_pos_x <= win->posx + win->width && mouse_pos_y >= win->posy && mouse_pos_y <= win->posy + win->height) {
if (win->flags & WIN_REQ_FLAG_NO_MOUSE) {
mouse_visible = 0;
}
break;
}
}
}
if (mouse_visible) {
gui_display_pointer();
}
// flip // flip
/* /*
for (int j = 0; j < bytesPerLine * height; j++) { for (int j = 0; j < bytesPerLine * height; j++) {

View File

@ -129,6 +129,13 @@ i686-quinn-strip sysfont.exe
mv sysfont.exe $HOME/Quinn/fsroot/gui mv sysfont.exe $HOME/Quinn/fsroot/gui
rm sysfont.o rm sysfont.o
cd $HOME/Quinn/src/quinn-os/programs/gui/saver/
i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c saver.c
i686-quinn-gcc $CFLAGS saver.o $HOME/Quinn/sysroot/usr/lib/libquinn.a $HOME/Quinn/sysroot/usr/lib/libfreetype.a $HOME/Quinn/sysroot/usr/lib/libpng.a $HOME/Quinn/sysroot/usr/lib/libz.a -o saver.exe
i686-quinn-strip saver.exe
mv saver.exe $HOME/Quinn/fsroot/gui
rm saver.o
cd $HOME/Quinn/src/quinn-os/programs/gui/terminal/ cd $HOME/Quinn/src/quinn-os/programs/gui/terminal/
i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c terminal.c i686-quinn-gcc $CFLAGS -I$HOME/Quinn/sysroot/usr/include -c terminal.c
i686-quinn-gcc $CFLAGS -c font.c i686-quinn-gcc $CFLAGS -c font.c

View File

@ -2,6 +2,7 @@
#define __QUINN_H #define __QUINN_H
#define WIN_REQ_FLAG_NO_TITLE 0x01 #define WIN_REQ_FLAG_NO_TITLE 0x01
#define WIN_REQ_FLAG_NO_MOUSE 0x02
struct event_msg_t { struct event_msg_t {
int type; int type;

View File

@ -0,0 +1,80 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "saver_big.xpm"
#include "quinn.h"
#include "convertxpm.h"
void surf_callback(int x, int y, void *data) {
quinn_exit();
exit(0);
}
void exit_callback(int wh) {
quinn_exit();
exit(0);
}
void surf_char(char c) {
quinn_exit();
exit(0);
}
int main(int argc, char **argv) {
struct widget_t *surfw;
int direction_x = 1;
int direction_y = 1;
int pos_x = rand() % (1024 - 256);
int pos_y = rand() % (768 - 256);
unsigned char *logo;
quinn_init();
struct window_req_t *req = (struct window_req_t *)malloc(sizeof(struct window_req_t));
unsigned char *surf;
req->x = 0;
req->y = 0;
req->width = 1024;
req->height = 768;
req->icon = NULL;
req->flags = WIN_REQ_FLAG_NO_TITLE | WIN_REQ_FLAG_NO_MOUSE;
strcpy(req->name, "Screen Saver");
int window_handle = quinn_req_window(req, exit_callback);
free(req);
surfw = quinn_add_surface(window_handle, 0, 0, 1024, 768, surf_callback, NULL, surf_char, surf_char);
surf = quinn_surface_get_surface(surfw);
convert_xpm(saver_big_xpm, &logo);
while (1) {
if (direction_x) {
pos_x+=2;
} else {
pos_x-=2;
}
if (direction_y) {
pos_y+=2;
} else {
pos_y-=2;
}
if (pos_x <= 4 || pos_x >= 1024 - 260) {
direction_x = !direction_x;
}
if (pos_y <= 4 || pos_y >= 768 - 260) {
direction_y = !direction_y;
}
quinn_fill_rect(window_handle, surf, 1024, 768, 0, 0, 1024, 768, 0xff000000);
quinn_render(window_handle, surf, logo, 256, 256, pos_x, pos_y, 1024, 768);
if (!quinn_process(0)) {
quinn_yield();
}
}
quinn_exit();
}

File diff suppressed because it is too large Load Diff

View File

@ -73,15 +73,15 @@ void listbox_callback(char *item, int index) {
sprintf(temp, "disk0:/system/fonts/%s.f16", item); sprintf(temp, "disk0:/system/fonts/%s.f16", item);
FILE *fptr = fopen(temp, "rb"); FILE *fptr = fopen(temp, "rb");
if (fptr) { if (fptr) {
memset(font, 0, 4096); memset(font, 0, 4096);
if (!fread(font, 4096, 1, fptr)) { if (!fread(font, 4096, 1, fptr)) {
fclose(fptr);
return;
}
fclose(fptr); fclose(fptr);
strcpy(fontname, temp); return;
quinn_fill_rect(window_handle, surf, 290, 180, 0, 0, 290, 180, 0xffffffff); }
draw_text(surf, 290, 240, 3, 3, 0xFF000000, "The quick brown fox"); fclose(fptr);
strcpy(fontname, temp);
quinn_fill_rect(window_handle, surf, 290, 180, 0, 0, 290, 180, 0xffffffff);
draw_text(surf, 290, 240, 3, 3, 0xFF000000, "The quick brown fox");
} }
return; return;
} }
@ -91,8 +91,8 @@ void setfont_callback(void *data) {
__asm__ volatile ("int $0x30" : "=a" (ret) : "0" (60), "b" (font)); __asm__ volatile ("int $0x30" : "=a" (ret) : "0" (60), "b" (font));
FILE *fptr = fopen("disk0:/system/fonts/chosen.fnt", "w"); FILE *fptr = fopen("disk0:/system/fonts/chosen.fnt", "w");
if (fptr) { if (fptr) {
fprintf(fptr, "%s\n", fontname); fprintf(fptr, "%s\n", fontname);
fclose(fptr); fclose(fptr);
} }
} }
@ -124,11 +124,11 @@ int fill_dir_list(struct widget_t *lb) {
if (!stat(buffer2, &s)) { if (!stat(buffer2, &s)) {
if (!S_ISDIR(s.st_mode)) { if (!S_ISDIR(s.st_mode)) {
if (dent->name_len > 4 && strcmp(&dent->name[dent->name_len - 4], ".f16") == 0) { if (dent->name_len > 4 && strcmp(&dent->name[dent->name_len - 4], ".f16") == 0) {
memset(temp, '\0', 256); memset(temp, '\0', 256);
strncpy(temp, dent->name, dent->name_len - 4); strncpy(temp, dent->name, dent->name_len - 4);
quinn_listbox_additem(lb, temp); quinn_listbox_additem(lb, temp);
} }
} }
} }
bpos = dent->next_offset; bpos = dent->next_offset;
@ -142,13 +142,13 @@ int fill_dir_list(struct widget_t *lb) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
struct widget_t *surfw; struct widget_t *surfw;
quinn_init(); quinn_init();
struct window_req_t *req = (struct window_req_t *)malloc(sizeof(struct window_req_t)); struct window_req_t *req = (struct window_req_t *)malloc(sizeof(struct window_req_t));
unsigned char *icon; unsigned char *icon;
convert_xpm(sysfont_xpm, &icon); convert_xpm(sysfont_xpm, &icon);
req->x = 100; req->x = 100;
req->y = 100; req->y = 100;
@ -162,16 +162,16 @@ int main(int argc, char **argv) {
free(req); free(req);
free(icon); free(icon);
// add list box with font listing // add list box with font listing
listbox = quinn_add_listbox(window_handle, 3, 3, 290, 240, listbox_callback); listbox = quinn_add_listbox(window_handle, 3, 3, 290, 240, listbox_callback);
fill_dir_list(listbox); fill_dir_list(listbox);
// add preview surface // add preview surface
surfw = quinn_add_surface(window_handle, 293, 3, 290, 180, NULL, NULL, NULL, NULL); surfw = quinn_add_surface(window_handle, 293, 3, 290, 180, NULL, NULL, NULL, NULL);
surf = quinn_surface_get_surface(surfw); surf = quinn_surface_get_surface(surfw);
quinn_add_button(window_handle, 351, 215, 120, 25, "Set Font", NULL, setfont_callback); quinn_add_button(window_handle, 351, 215, 120, 25, "Set Font", NULL, setfont_callback);
quinn_add_button(window_handle, 476, 215, 120, 25, "Quit", NULL, quit_callback); quinn_add_button(window_handle, 476, 215, 120, 25, "Quit", NULL, quit_callback);
while (1) { while (1) {
quinn_process(1); quinn_process(1);