use a new screensaver, C-- a new UI component FileBox used in DIFF app

git-svn-id: svn://kolibrios.org@7658 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2019-05-16 10:48:21 +00:00
parent fab3b3a411
commit d7aa06e1d1
5 changed files with 161 additions and 66 deletions

View File

@ -334,7 +334,7 @@ tup.append_table(img_files, {
{"@NOTIFY", PROGS .. "/system/notify3/notify"},
{"@OPEN", PROGS .. "/system/open/open"},
{"@TASKBAR", PROGS .. "/system/taskbar/trunk/TASKBAR"},
{"@SS", PROGS .. "/system/ss/trunk/@ss"},
{"@SS", PROGS .. "/system/scrsaver/scrsaver"},
{"@VOLUME", PROGS .. "/media/volume/volume"},
{"HACONFIG", PROGS .. "/other/ha/HACONFIG"},
{"APM", PROGS .. "/system/apm/apm"},

View File

@ -14,3 +14,6 @@ double_click_delay=64
LBA=off
PCI=on
[screensaver]
timeout=10 ;in minutes
program=/sys/demos/spiral

View File

@ -1,80 +1,86 @@
//===================================================//
// //
// LIB //
// //
//===================================================//
#include "../lib/gui.h"
#include "../lib/obj/box_lib.h"
#include "../lib/obj/proc_lib.h"
#include "../lib/patterns/simple_open_dialog.h"
//===================================================//
// //
// DATA //
// //
//===================================================//
//proc_info Form;
#define WIN_W 450
char default_dir[] = "/rd/1";
od_filter filter2 = {0,0};
char src_box_text[4096];
char dst_box_text[4096];
edit_box src_box = {340,20,35,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(src_box_text)-2,#src_box_text,0, ed_focus};
edit_box dst_box = {340,20,95,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(dst_box_text)-2,#dst_box_text,0, 0b};
char src_path[4096];
char dst_path[4096];
edit_box src_box = {WIN_W-36-DOT_W,18,30,0xffffff,0x94AECE,0xFFFfff,
0xffffff,0x10000000,sizeof(src_path)-2,#src_path,0, ed_focus};
edit_box dst_box = {WIN_W-36-DOT_W,18,85,0xffffff,0x94AECE,0xFFFfff,
0xffffff,0x10000000,sizeof(dst_path)-2,#dst_path,0, 0b};
#define BID_EXIT_PRC 01
#define BID_SRC_OPEN 10
#define BID_DST_OPEN 11
#define BID_COMPARE 12
enum {
BID_EXIT_PRC=1,
BID_SRC_OPEN,
BID_DST_OPEN,
BID_GO
};
proc_info Form;
#ifndef COPYING
#define T_FIRST "First file:"
#define T_SECOND "Second file:"
#define T_GO " Compare "
#endif
#define READY 0
int state=READY;
//===================================================//
// //
// CODE //
// //
//===================================================//
void gui()
{
word btn;
char run_param[4096];
load_dll(boxlib, #box_lib_init,0);
load_dll(Proc_lib, #OpenDialog_init,0);
OpenDialog_init stdcall (#o_dialog);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop() switch(WaitEvent())
{
case evMouse:
edit_box_mouse stdcall (#src_box);
edit_box_mouse stdcall (#dst_box);
if (READY == state) {
edit_box_mouse stdcall (#src_box);
edit_box_mouse stdcall (#dst_box);
}
break;
case evButton:
btn = GetButtonID();
switch (btn)
{
case BID_EXIT_PRC:
ExitProcess();
case BID_SRC_OPEN:
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#src_box_text, #openfile_path);
EditBox_UpdateText(#src_box, #src_box.flags);
}
break;
case BID_DST_OPEN:
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#dst_box_text, #openfile_path);
EditBox_UpdateText(#dst_box, #dst_box.flags);
}
break;
case BID_COMPARE:
sprintf(#run_param, "\"%s\" \"%s\"", #src_box_text, #dst_box_text);
io.run(I_Path, #run_param);
break;
}
btn = @GetButtonID();
if (btn == BID_EXIT_PRC) ExitProcess();
if (btn == BID_SRC_OPEN) EventOpenDialogFirst();
if (btn == BID_DST_OPEN) EventOpenDialogSecond();
if (btn == BID_GO) EventGo();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
if (key_scancode == SCAN_CODE_TAB) {
if ( src_box.flags & ed_focus ) {
src_box.flags -= ed_focus;
dst_box.flags += ed_focus;
} else {
src_box.flags += ed_focus;
dst_box.flags -= ed_focus;
}
edit_box_draw stdcall (#src_box);
edit_box_draw stdcall (#dst_box);
}
if (key_scancode == SCAN_CODE_TAB) EventTabClick();
if (key_scancode == SCAN_CODE_ENTER) EventGo();
if (key_scancode == SCAN_CODE_INS) EventInsert();
EAX = key_editbox;
edit_box_key stdcall (#src_box);
EAX = key_editbox;
@ -90,14 +96,80 @@ void gui()
void draw_window()
{
system.color.get();
DefineAndDrawWindow(215, 100, 450, 195 + skin_height, 0x34, system.color.work, #window_title,0);
GetProcessInfo(#Form, SelfInfo);
DefineAndDrawWindow(215, 100, WIN_W+9, 170 + skin_height, 0x34, system.color.work, #window_title,0);
//GetProcessInfo(#Form, SelfInfo);
if (READY==state) {
DrawFileBox(#src_box, T_FIRST, BID_SRC_OPEN);
DrawFileBox(#dst_box, T_SECOND, BID_DST_OPEN);
DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_GO, T_GO);
}
#ifdef COPYING
if (COPYING==state) {
pr.frame_color = system.color.work_graph;
DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, system.color.work_dark,
system.color.work_light);
DrawProgress();
DrawStandartCaptButton(-19*8+WIN_W/2-15, dst_box.top + 35, B_STOP, " Stop ");
}
#endif
}
WriteText(src_box.left-2, src_box.top-21, 0x90, system.color.work_text, "First file:");
WriteText(dst_box.left-2, dst_box.top-21, 0x90, system.color.work_text, "Second file:");
DrawEditBox(#src_box);
DrawEditBox(#dst_box);
DrawStandartCaptButton(src_box.left + src_box.width + 15, src_box.top-3, BID_SRC_OPEN, "...");
DrawStandartCaptButton(dst_box.left + dst_box.width + 15, dst_box.top-3, BID_DST_OPEN, "...");
DrawStandartCaptButton(dst_box.left - 2, dst_box.top + 40, BID_COMPARE, "Compare");
void UpdateEditBoxes(dword f1, f2)
{
EditBox_UpdateText(#src_box, f1);
EditBox_UpdateText(#dst_box, f2);
edit_box_draw stdcall (#src_box);
edit_box_draw stdcall (#dst_box);
}
//===================================================//
// //
// EVENTS //
// //
//===================================================//
#ifndef COPYING
void EventGo()
{
char run_param[4096];
sprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
RunProgram(I_Path, #run_param);
}
#endif
void EventTabClick()
{
if ( src_box.flags & ed_focus ) {
UpdateEditBoxes(0, ed_focus);
} else {
UpdateEditBoxes(ed_focus, 0);
}
}
void EventOpenDialogFirst()
{
o_dialog.type = 0; //0-file, 1-save, 2-select folder
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#src_path, #openfile_path);
UpdateEditBoxes(ed_focus, 0);
}
}
void EventOpenDialogSecond()
{
#ifdef COPYING
o_dialog.type = 1; //0-file, 1-save, 2-select folder
#endif
OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) {
strcpy(#dst_path, #openfile_path);
UpdateEditBoxes(0, ed_focus);
}
}
void EventInsert()
{
if ( src_box.flags & ed_focus ) EventOpenDialogFirst();
if ( dst_box.flags & ed_focus ) EventOpenDialogSecond();
}

View File

@ -1,10 +1,10 @@
#define WIN_DIALOG_W 380
#define WIN_DIALOG_H 85
#define WIN_DIALOG_H 100
#define PR_LEFT 14
#define PR_TOP 28
#define PR_TOP 32
#define PR_W WIN_DIALOG_W-PR_LEFT-PR_LEFT
#define PR_H 14
#define PR_H 18
proc_info Dialog_Form;
progress_bar copy_bar = {0,PR_LEFT,PR_TOP,PR_W,PR_H,0,0,1,0xFFFFFF,0x00FF00,0x555555};
@ -44,7 +44,7 @@ void DisplayOperationForm()
case evReDraw:
DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_DIALOG_W+9,skin_height+WIN_DIALOG_H,0x34,system.color.work,title,0);
GetProcessInfo(#Dialog_Form, SelfInfo);
DrawCaptButtonSmallText(WIN_DIALOG_W-PR_LEFT-80, PR_TOP+PR_H+6, 80,22, 2,
DrawCaptButton(WIN_DIALOG_W-PR_LEFT-101, PR_TOP+PR_H+6, 100,26, 2,
system.color.work_button, system.color.work_button_text, T_ABORT_WINDOW_BUTTON);
DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, system.color.work_dark, system.color.work_light);
@ -65,8 +65,8 @@ void Operation_Draw_Progress(dword filename) {
return;
}
DisplayOperationForm();
DrawBar(PR_LEFT, PR_TOP-14, WIN_DIALOG_W-PR_LEFT, 10, system.color.work);
WriteText(PR_LEFT, PR_TOP-14, 0x80, system.color.work_text, filename);
DrawBar(PR_LEFT, PR_TOP-20, WIN_DIALOG_W-PR_LEFT, 15, system.color.work);
WriteText(PR_LEFT, PR_TOP-20, 0x90, system.color.work_text, filename);
progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar);
@ -74,6 +74,6 @@ void Operation_Draw_Progress(dword filename) {
//pause(1);
//copying.draw_progress(copy_bar.value*copying.w/copy_bar.max, copy_bar.value, copy_bar.max-copy_bar.value, "");
DrawBar(PR_LEFT, PR_TOP+PR_H+6, 100, 15, system.color.work);
WriteText(PR_LEFT, PR_TOP+PR_H+6, 0x80, system.color.work_text, sprintf(#param, "%i/%i", copy_bar.value, copy_bar.max));
WriteTextWithBg(PR_LEFT, PR_TOP+PR_H+5, 0xD0, system.color.work_text,
sprintf(#param, "%i/%i", copy_bar.value, copy_bar.max), system.color.work);
}

View File

@ -145,6 +145,26 @@
DrawRectangle3D(x-3, y-3, w+5, h+5, system.color.work_dark, system.color.work_light);
}
#define DOT_W 37
:void DrawFileBox(dword edit_box_pointer, title, btn)
{
dword x,y,w,h,bg,t;
ESI = edit_box_pointer;
x = ESI.edit_box.left;
y = ESI.edit_box.top;
w = ESI.edit_box.width+1;
h = 22;
if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
edit_box_draw stdcall (edit_box_pointer);
DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
DrawRectangle(x-2, y-2, w+3, h+3, system.color.work_graph);
DrawRectangle3D(x-3, y-3, w+DOT_W+5, h+5, system.color.work_dark, system.color.work_light);
WriteText(x-2, y-19, 0x90, system.color.work_text, title);
DrawCaptButton(x+w+1, y-2, DOT_W, h+3, btn, system.color.work_button, system.color.work_button_text, "...");
}
:void DrawEditBoxPos(dword x,y, edit_box_pointer)
{
ESI = edit_box_pointer;