desktop ui

This commit is contained in:
y4my4my4m 2023-08-25 15:24:51 +09:00
parent b32f9cea77
commit 3149a8f2ea
4 changed files with 596 additions and 0 deletions

BIN
src/Home/Desktop/DesktopIcons.DD Executable file

Binary file not shown.

99
src/Home/Desktop/HomeSys.ZC Executable file
View file

@ -0,0 +1,99 @@
// HOME VERSION
U0 UserStartUp()
{//Run each time a user a spawned
DocTermNew;
Type("::/Doc/Start.DD");
LBts(&Fs->display_flags, DISPLAYf_SHOW);
Fs->title_src = TTS_LOCKED_CONST;
Fs->title_src = Fs->display_doc->filename.name;
WinToTop;
WinZBufUpdate;
Dir;
}
U0 ServerStartUp()
{//Run each time a server task is spawned.
DocTermNew;
LBts(&Fs->display_flags, DISPLAYf_SHOW);
Fs->title_src = TTS_LOCKED_CONST;
WinToTop;
WinZBufUpdate;
}
U0 StartUpTasks()
{
//////////////////////////
// SysLog Window Config //
//////////////////////////
DocCursor(OFF);
Fs->title_src = TTS_LOCKED_CONST;
Fs->title_src = "SysLog";
DocClear(Fs->border_doc, TRUE);
/////////////////////////
// Initial Term Config //
/////////////////////////
CTask *user = User;
user->border_src = BDS_CONST;
user->text_attr = DKGRAY << 4 + BLUE;
user->title_src = TTS_LOCKED_CONST;
user->title_src = user->display_doc->filename.name;
DocClear(user->border_doc, TRUE);
user->win_width = GR_WIDTH / 2;
WinHorz((user->win_width/8) - ((user->win_width/2)/7),
(user->win_width/8) + ((user->win_width/2)/7) - 1, user);
user->win_height = GR_HEIGHT / 2;
WinVert((user->win_height/8) - ((user->win_height/2)/8),
(user->win_height/8) + ((user->win_height/2)/8) - 1, user);
I64 initialWinTop = user->win_top;
I64 initialWinLeft = user->win_left;
user->win_top = (GR_HEIGHT/2)/8;
user->win_bottom = (GR_HEIGHT/2)/8;
user->win_left = (GR_WIDTH/2)/8;
user->win_right = (GR_WIDTH/2)/8;
while(user->win_left > initialWinLeft){
user->win_left--;
user->win_right++;
Sleep(2);
}
while(user->win_top > initialWinTop){
user->win_top--;
user->win_bottom++;
Sleep(10);
}
WinToTop(user);
WinZBufUpdate;
"\n\n Boot Time:$$RED$$%7.3fs$$FG$$\n", tS;
//XTalk(user, "Cd; #include \"Once\";\n");
Silent; //no output to screen
//ACInit("/*;!*/Bible.TXT;!*/Clementine.TXT;!*/PCIDevices.DD;!*/HTML/*;!*/ChangeLog.DD");
Silent(OFF); //no output to screen
//AutoComplete(OFF);
//if (sys_boot_src.u16[0] != BOOT_SRC_RAM)
// PopUp("ExeFile2(\"::/System/ZSplash.ZC\");");
}
#include "~/PaletteEditor/Palettes/Tradition"
PaletteSetTradition;
StartUpTasks;
"\n\n $$PURPLE$$ZealOS$$FG$$ V%0.2f\t%D %T\n\n", sys_os_version, sys_compile_time, sys_compile_time;

5
src/Home/Desktop/Install.ZC Executable file
View file

@ -0,0 +1,5 @@
Cd(__DIR__);;
Copy("HomeSys.ZC", "~/HomeSys.ZC");
Copy("DesktopIcons.DD", "~/DesktopIcons.DD");
Copy("WallPaper.ZC", "::/System/WallPaper.ZC");

492
src/Home/Desktop/WallPaper.ZC Executable file
View file

@ -0,0 +1,492 @@
#help_index "Windows"
class CWallPaperGlobals
{
I64 last_calc_idle_count, last_swap_counter[MP_PROCESSORS_NUM];
F64 last_calc_idle_delta_time;
U8 top_line[STR_LEN];
} *wall = CAlloc(sizeof(CWallPaperGlobals));
wall->last_calc_idle_delta_time = 1.0;
class CTaskWallPaperData
{
I64 alloced_u8s, used_u8s;
U8 caller_stack[4096 - $$];
};
U0 UserTerm()
{
CTask *user = User;
user->border_src = BDS_CONST;
user->text_attr = DKGRAY << 4 + BLUE;
user->title_src = TTS_LOCKED_CONST;
user->title_src = user->display_doc->filename.name;
DocClear(user->border_doc, TRUE);
DocClear;
user->win_width = GR_WIDTH / 2;
WinHorz((user->win_width/8) - ((user->win_width/2)/6),
(user->win_width/8) + ((user->win_width/2)/6) - 1, user);
user->win_height = GR_HEIGHT / 2;
WinVert((user->win_height/8) - ((user->win_height/2)/7),
(user->win_height/8) + ((user->win_height/2)/7) - 1, user);
I64 initialWinTop = user->win_top;
I64 initialWinLeft = user->win_left;
user->win_top = (GR_HEIGHT/2)/8;
user->win_bottom = (GR_HEIGHT/2)/8;
user->win_left = (GR_WIDTH/2)/8;
user->win_right = (GR_WIDTH/2)/8;
while(user->win_left > initialWinLeft){
user->win_left--;
user->win_right++;
Sleep(2);
}
while(user->win_top > initialWinTop){
user->win_top--;
user->win_bottom++;
Sleep(10);
}
// WinToTop(user);
// WinZBufUpdate;
Dir;
}
U0 WallPaper(CTask *_task)
{
I64 i, j, k, l = TEXT_ROWS - 1;
CTask *task;
CTaskWallPaperData *wpd;
CHashTable *old_hash = Fs->hash_table;
CCPU *c;
CDateStruct ds;
U8 *st;
_task->text_attr = DKGRAY << 4 + LTGRAY;
if (sys_data_bp)
{
TextPrint(Fs, 0, l--, DKGRAY << 4 + YELLOW,
"%010X/%010X %010X/%010X%12td%12td%12td",
sys_data_bp->used_u8s, sys_data_bp->alloced_u8s,
sys_code_bp->used_u8s, sys_code_bp->alloced_u8s,
cmp.compiled_lines, blkdev.read_count, blkdev.write_count);
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY,
"______Data_Heap______ ______Code_Heap______ "
"___Lines___ ___Reads___ __Writes___");
}
else
{
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY,
"%010X/%010X%12td%12td%12td",
sys_code_bp->used_u8s, sys_code_bp->alloced_u8s,
cmp.compiled_lines, blkdev.read_count, blkdev.write_count);
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY,
"____CodeData_Heap____ "
"___Lines___ ___Reads___ ___Writes__");
}
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY, "ProgressBars:%016X %016X %016X %016X",
progress1, progress2, progress3, progress4);
for (i = 0; i < mp_count; i++)
{
c = &cpu_structs[i];
if (winmgr.t->calc_idle_count != wall->last_calc_idle_count)
{
wall->last_calc_idle_delta_time = winmgr.t->calc_idle_delta_time;
wall->last_swap_counter[i] = winmgr.t->last_swap_counter[i];
winmgr.t->last_swap_counter[i] = c->swap_counter;
}
task = c->executive_task;
do
{
wpd = &task->wallpaper_data;
if (!TaskValidate(task))
break;
if (!(winmgr.updates & 5))
{
if (c == Gs)
Fs->hash_table = task->hash_table;
else //precaution
Fs->hash_table = old_hash;
StrPrint(wpd->caller_stack, " %p ", TaskCaller(task, 0));
for (j = 1; j < 16; j++)
{
if ((k = TaskCaller(task, j)) > 0)
CatPrint(wpd->caller_stack, "? %p ", k);
}
}
TextPrint(Fs, 0, l--, DKGRAY << 4 + YELLOW, wpd->caller_stack);
j = UnusedStack(task);
if (j < 0)
Panic("Stack Overflow", task);
if (!(winmgr.updates & 15))
{
wpd->alloced_u8s = TaskMemAlloced(task);
wpd->used_u8s = TaskMemUsed(task);
}
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY,
" %-18ts #%08X %010X %010X/%010X %04X:%02tX:%08X",
task->task_title, task, j, wpd->used_u8s, wpd->alloced_u8s,
task->task_flags, task->display_flags, task->win_inhibit);
if (!TaskValidate(task))
break;
task = task->next_task;
}
while (task != c->executive_task);
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY, "CPU%02X %2tf%% ContextSwaps/s:%9,d", i,
100.0 * (1.0 - c->idle_factor), ToI64((winmgr.t->last_swap_counter[i]
- wall->last_swap_counter[i]) / wall->last_calc_idle_delta_time));
}
TextPrint(Fs, 0, l--, DKGRAY << 4 + LTGRAY,
" ___Description____ #__Task__ UnusedStack _UsedMem_/_AllocMem_ ______Flags_____");
if (!(winmgr.updates & 15) || !*wall->top_line)
{
Date2Struct(&ds, Now);
i = sys_code_bp->alloced_u8s - sys_code_bp->used_u8s;
if (sys_data_bp)
i += sys_data_bp->alloced_u8s - sys_data_bp->used_u8s;
StrPrint(wall->top_line,
" ð %3tZ %02d/%02d/%02d %02d:%02d:%02d ³ FPS: %2tf ³ Mem: %010X ³ CPU: ",
ds.day_of_week, "ST_DAYS_OF_WEEK", ds.mon, ds.day_of_mon, ds.year % 100,
ds.hour, ds.min, ds.sec, winmgr.fps, i);
}
TextPrint(Fs, 0, 0, DKGRAY << 4 + LTGRAY, wall->top_line);
if (screencast.record)
TextPrint(Fs, 44 - 4, 0, DKGRAY << 4 + LTGREEN, "*");
for (i = 0; i < mp_count; i++)
{
c = &cpu_structs[i];
if (i & 1)
TextPrint(Fs, 60 + i * 2, 0, DKGRAY << 4 + LTGRAY, "%2tf", 100.0 * (1.0 - c->idle_factor));
else
TextPrint(Fs, 60 + i * 2, 0, DKGRAY << 4 + LTGREEN, "%2tf", 100.0 * (1.0 - c->idle_factor));
}
st = ScanCode2KeyName(kbd.last_down_scan_code);
TextPrint(Fs, TEXT_COLS - 25, 0, DKGRAY << 4 + LTGREEN, "%25ts", st);
Free(st);
Fs->hash_table = old_hash;
wall->last_calc_idle_count = winmgr.t->calc_idle_count;
}
$SP,"<1>",BI=1$
$SP,"<2>",BI=2,BP="::/Home/DesktopIcons.DD,1"$
$SP,"<3>",BI=3,BP="::/Home/DesktopIcons.DD,2"$
$SP,"<4>",BI=4,BP="::/Home/DesktopIcons.DD,3"$
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
U0 DrawTermBttn(CDC *dc, CCtrl *c)
{
Sprite3(dc, c->left-8, c->top-8, 0, $IB,"<1>",BI=1$);
}
U0 LeftClickTermBttn(CCtrl *, I64, I64, Bool down)
{
if (down)
User;
}
CCtrl *TermBttnNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawTermBttn;
c->left_click = &LeftClickTermBttn;
SpriteExtents($IB,"<1>",BI=1$, &min_x, &max_x, &min_y, &max_y);
//min must be zero
c->left = sys_winmgr_task->pix_width - (max_x - min_x + 1);
c->right = c->left + (max_x - min_x + 1) - 1;
c->top = sys_winmgr_task->pix_height - (max_y - min_y + 1);
c->bottom = c->top + (max_y - min_y + 1) - 1;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
//// HOME
U0 DrawHomeIcon(CDC *dc, CCtrl *c)
{
c->top = (sys_task->win_bottom * 8) + 26;
c->bottom = c->top + 60 + 8;
//dc->color = PURPLE;
//GrRect(dc, c->left, c->top, c->right, c->bottom);
Sprite3(dc, c->left, c->top, -1, $IB,"<2>",BI=2$);
}
U0 LeftClickHomeIcon(CCtrl *, I64, I64, Bool down)
{
if (down)
Spawn(&UserTerm, , "User Terminal");
}
CCtrl *HomeIconNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawHomeIcon;
c->left_click = &LeftClickHomeIcon;
SpriteExtents($IB,"<2>",BI=2$, &min_x, &max_x, &min_y, &max_y);
//min must be zero
c->left = 8;
c->right = c->left + (max_x - min_x + 1) - 1;
c->top = (sys_task->win_bottom*8) + (max_y - min_y + 1);
c->bottom = c->top + max_y + 8;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
//// TELNET
U0 DrawTelnetIcon(CDC *dc, CCtrl *c)
{
c->top = (sys_task->win_bottom * 8) + 16*2 + 80;
//dc->color = RED;
//GrRect(dc, c->left, c->top, c->right, c->bottom);
Sprite3(dc, c->left, c->top, -1, $IB,"<3>",BI=3$);
}
U0 LeftClickTelnetIcon(CCtrl *, I64, I64, Bool down)
{
if (down)
PopUp("ExeFile2(\"~/Net/Programs/Telnet/Telnet.ZC\");");
}
CCtrl *TelnetIconNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawTelnetIcon;
c->left_click = &LeftClickTelnetIcon;
SpriteExtents($IB,"<3>",BI=3$, &min_x, &max_x, &min_y, &max_y);
//min must be zerocp
c->left = 8;
c->right = c->left + (max_x - min_x);
c->top = (sys_task->win_bottom*8) + (max_y - min_y + 1) * 2;
c->bottom = c->top + max_y + 16;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
//// PALETTE EDITOR
U0 DrawPaletteIcon(CDC *dc, CCtrl *c)
{
c->top = (sys_task->win_bottom * 8) + 16*3 + 130;
//dc->color = RED;
//GrRect(dc, c->left, c->top, c->right, c->bottom);
Sprite3(dc, c->left, c->top, -1, $IB,"<4>",BI=4$);
}
U0 LeftClickPaletteIcon(CCtrl *, I64, I64, Bool down)
{
if (down)
PopUp("ExeFile2(\"~/PaletteEditor/Run.ZC\");");
}
CCtrl *PaletteIconNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawPaletteIcon;
c->left_click = &LeftClickPaletteIcon;
SpriteExtents($IB,"<7>",BI=7$, &min_x, &max_x, &min_y, &max_y);
//min must be zerocp
c->left = 8;
c->right = c->left + (max_x - min_x);
c->top = (sys_task->win_bottom*8) + (max_y - min_y + 1) * 3;
c->bottom = c->top + max_y + 16;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
U0 DrawNetLogBttn(CDC *dc, CCtrl *c)
{
Sprite3(dc, c->left-8, c->top-8, 0, $IB,"<5>",BI=5$);
}
U0 LeftClickNetLogBttn(CCtrl *, I64, I64, Bool down)
{
if(down)
Sys("NetLogToggle;");
}
CCtrl *NetLogIconNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawNetLogBttn;
c->left_click = &LeftClickNetLogBttn;
SpriteExtents($IB,"<5>",BI=5$, &min_x, &max_x, &min_y, &max_y);
//min must be zero
c->left = sys_winmgr_task->pix_width - (max_x - min_x + 1);
c->right = c->left + (max_x - min_x + 1) - 1;
c->top = sys_winmgr_task->pix_height - (max_y - min_y + 1) - 40;
c->bottom = c->top + (max_y - min_y + 1) - 1;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
U0 DrawShowStatsBttn(CDC *dc, CCtrl *c)
{
Sprite3(dc, c->left-8, c->top-8, 0, $IB,"<6>",BI=6$);
}
U0 LeftClickShowStatsBttn(CCtrl *, I64, I64, Bool down)
{
if(down)
Sys("WallPaperToggle;");
}
CCtrl *ShowStatsIconNew()
{
I64 min_x, max_x, min_y, max_y;
CCtrl *c = SysCAlloc(sizeof(CCtrl));
c->win_task = sys_winmgr_task;
c->flags = CTRLF_SHOW;
c->type = CTRLT_GENERIC;
c->draw_it = &DrawShowStatsBttn;
c->left_click = &LeftClickShowStatsBttn;
SpriteExtents($IB,"<6>",BI=6$, &min_x, &max_x, &min_y, &max_y);
//min must be zero
c->left = sys_winmgr_task->pix_width - (max_x - min_x + 1);
c->right = c->left + (max_x - min_x + 1) - 1;
c->top = sys_winmgr_task->pix_height - (max_y - min_y + 1) - 80;
c->bottom = c->top + (max_y - min_y + 1) - 1;
QueueInsert(c, sys_winmgr_task->last_ctrl);
TaskDerivedValsUpdate(sys_winmgr_task);
return c;
}
U0 WallPaperInit(Bool enableTermIcon = TRUE, Bool enableDesktopIcons = TRUE)
{
if(enableTermIcon)
{
TermBttnNew;
NetLogIconNew;
ShowStatsIconNew;
}
if(enableDesktopIcons)
{
HomeIconNew;
TelnetIconNew;
PaletteIconNew;
}
gr.fp_wall_paper = &WallPaper;
}
; N L
TERMINALn 6 5 1  BBS !60&Telnet9 N L
NetLog8 N L
Stats