mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-26 02:39:55 +03:00
appearance: final version! Now the selected value is restored after program reopen
git-svn-id: svn://kolibrios.org@9524 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1f8ba94314
commit
3813663899
@ -1,5 +1,4 @@
|
||||
//11.03.12 - start!
|
||||
//TODO: select current value at startap
|
||||
|
||||
#define MEMSIZE 1024*70
|
||||
#include "../lib/mem.h"
|
||||
@ -16,6 +15,8 @@
|
||||
#include "../lib/patterns/simple_open_dialog.h"
|
||||
#include "../lib/patterns/restart_process.h"
|
||||
|
||||
dword fmas;
|
||||
|
||||
#include "ui_elements_preview.h"
|
||||
#include "const.h"
|
||||
|
||||
@ -25,7 +26,7 @@
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
int active_skin, active_wallpaper, active_screensaver;
|
||||
int active_skin=-1, active_wallpaper=-1, active_screensaver=-1;
|
||||
|
||||
checkbox update_docky = { T_UPDATE_DOCK, false };
|
||||
|
||||
@ -37,6 +38,7 @@ char ss_available[200];
|
||||
|
||||
collection list;
|
||||
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// CODE //
|
||||
@ -178,91 +180,95 @@ void draw_timeout()
|
||||
WriteTextWithBg(RIGHTx, PANEL_H, 0xD0, sc.work_text, #param, sc.work);
|
||||
}
|
||||
|
||||
bool strreqi(dword _left, _right)
|
||||
void add_filesnames_into_the_list()
|
||||
{
|
||||
return strcmp(_left+strrchr(_left,'.'), _right);
|
||||
int j;
|
||||
for (j=0; j<select_list.count; j++) {
|
||||
miniprintf(#param,"%s/",#folder_path);
|
||||
strcat(#param, io.dir.position(ESDWORD[j*4+fmas]));
|
||||
list.add(#param);
|
||||
}
|
||||
}
|
||||
|
||||
dword files_mas[400];
|
||||
void Open_Dir()
|
||||
{
|
||||
int j;
|
||||
char fname[4096];
|
||||
dword ext;
|
||||
select_list.ClearList();
|
||||
if(io.dir.buffer)free(io.dir.buffer);
|
||||
|
||||
if (io.dir.buffer) free(io.dir.buffer);
|
||||
io.dir.load(#folder_path,DIR_ONLYREAL);
|
||||
|
||||
if (fmas) free(fmas);
|
||||
fmas = malloc(io.dir.count * 4);
|
||||
|
||||
for (j=0; j<io.dir.count; j++)
|
||||
{
|
||||
strcpy(#fname, io.dir.position(j));
|
||||
strlwr(#fname);
|
||||
strncpy(#param, io.dir.position(j), PATHLEN);
|
||||
strlwr(#param);
|
||||
ext = #param + strrchr(#param,'.');
|
||||
if (tabs.active_tab==TAB_SKINS) {
|
||||
if (strreqi(#fname,"skn")!=0) continue;
|
||||
if (!streq(ext,"skn")) continue;
|
||||
}
|
||||
if (tabs.active_tab==TAB_WALLPAPERS) {
|
||||
if (strreqi(#fname,"png")!=0)
|
||||
&& (strreqi(#fname,"jpg")!=0)
|
||||
&& (strreqi(#fname,"jpeg")!=0)
|
||||
&& (strreqi(#fname,"bmp")!=0)
|
||||
&& (strreqi(#fname,"gif")!=0) continue;
|
||||
if (!streq(ext,"png")) && (!streq(ext,"jpg"))
|
||||
&& (!streq(ext,"jpeg")) && (!streq(ext,"bmp"))
|
||||
&& (!streq(ext,"gif")) continue;
|
||||
}
|
||||
ESDWORD[select_list.count*4 + #files_mas] = j;
|
||||
ESDWORD[select_list.count*4 + fmas] = j;
|
||||
select_list.count++;
|
||||
}
|
||||
Sort_by_Name(0, select_list.count-1);
|
||||
sort_by_name(0, select_list.count-1);
|
||||
|
||||
list.drop();
|
||||
//save current item for tab change
|
||||
//add default item
|
||||
switch(tabs.active_tab) {
|
||||
CASE TAB_SKINS:
|
||||
select_list.cur_y = active_skin;
|
||||
if(tabs.active_tab == TAB_SKINS)
|
||||
{
|
||||
select_list.count++;
|
||||
list.add(#default_skin);
|
||||
BREAK;
|
||||
CASE TAB_WALLPAPERS:
|
||||
select_list.cur_y = active_wallpaper;
|
||||
add_filesnames_into_the_list();
|
||||
if (active_skin==-1) && (ESBYTE[#previous_skin])
|
||||
{
|
||||
for (j=0; j<select_list.count; j++) {
|
||||
if (streq(list.get(j), #previous_skin)) {
|
||||
active_skin = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
select_list.cur_y = active_skin;
|
||||
} else {
|
||||
select_list.count++;
|
||||
list.add(#default_wallp);
|
||||
BREAK;
|
||||
CASE TAB_SCREENSAVERS:
|
||||
select_list.cur_y = active_screensaver;
|
||||
}
|
||||
|
||||
add_filesnames_into_the_list();
|
||||
if (active_wallpaper==-1) && (ESBYTE[#previous_wallp]=='\\')
|
||||
{
|
||||
for (j=0; j<select_list.count; j++) {
|
||||
miniprintf(#param,"%s/",#folder_path);
|
||||
strcat(#param, io.dir.position(files_mas[j]));
|
||||
list.add(#param);
|
||||
if (streq(list.get(j), #previous_wallp+4)) {
|
||||
active_wallpaper = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
select_list.cur_y = active_wallpaper;
|
||||
}
|
||||
|
||||
if (!select_list.count) notify(T_NO_FILES);
|
||||
if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y;
|
||||
if (select_list.cur_y>SL_VISIBLE) {
|
||||
select_list.first = -SL_VISIBLE/2 + select_list.cur_y;
|
||||
}
|
||||
select_list.CheckDoesValuesOkey();
|
||||
if (LIST_W) draw_window();
|
||||
}
|
||||
|
||||
void Sort_by_Name(int a, b) // for the first call: a = 0, b = sizeof(mas) - 1
|
||||
{
|
||||
int j;
|
||||
int isn = a;
|
||||
if (a >= b) return;
|
||||
for (j = a; j <= b; j++) {
|
||||
if (strcmpi(io.dir.position(files_mas[j]), io.dir.position(files_mas[b]))<=0) {
|
||||
files_mas[isn] >< files_mas[j];
|
||||
isn++;
|
||||
}
|
||||
}
|
||||
Sort_by_Name(a, isn-2);
|
||||
Sort_by_Name(isn, b);
|
||||
}
|
||||
|
||||
void SelectList_DrawLine(dword i)
|
||||
{
|
||||
int draw_y = i*SELECT_LIST_ITEMH+PANEL_H;
|
||||
int i_abs = select_list.first + i;
|
||||
dword text_color = 0xFFFfff;
|
||||
dword bg_color = 0x000000;
|
||||
char filename_buf[4096];
|
||||
char filename_buf[PATHLEN];
|
||||
char* filename = #filename_buf;
|
||||
|
||||
strcpy(filename, list.get(i_abs));
|
||||
@ -294,28 +300,20 @@ void SelectList_DrawLine(dword i)
|
||||
WriteText(select_list.x+12,draw_y+select_list.text_y,select_list.font_type,bg_color, filename);
|
||||
}
|
||||
|
||||
void SelectList_LineChanged()
|
||||
{
|
||||
EventApply();
|
||||
}
|
||||
|
||||
dword GetRealKolibriosPath()
|
||||
{
|
||||
char real_kolibrios_path[4096];
|
||||
if (!dir_exists("/kolibrios")) return 0;
|
||||
SetCurDir("/kolibrios");
|
||||
GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
|
||||
return #real_kolibrios_path;
|
||||
}
|
||||
|
||||
void GetIniSettings()
|
||||
{
|
||||
ini.section = "screensaver";
|
||||
ss_timeout.position = ini.GetInt("timeout", 10) - 1;
|
||||
ini.GetString("available", #ss_available, sizeof(ss_available), 0);
|
||||
ini.section = "style";
|
||||
ini.GetString("default_skin", #default_skin, PATHLEN, 0);
|
||||
ini.GetString("default_wallp", #default_wallp, PATHLEN, 0);
|
||||
ini.GetString("skin", #previous_skin, PATHLEN, 0);
|
||||
ini.GetString("bg_param", #previous_wallp, PATHLEN, 0);
|
||||
|
||||
ini.section = "screensaver";
|
||||
ss_timeout.position = ini.GetInt("timeout", 10) - 1;
|
||||
ini.GetString("available", #ss_available, sizeof(ss_available), 0);
|
||||
ini.GetString("program", #previous_ss, PATHLEN, 0);
|
||||
}
|
||||
|
||||
//===================================================//
|
||||
@ -326,7 +324,7 @@ void GetIniSettings()
|
||||
|
||||
void EventTabSkinsClick()
|
||||
{
|
||||
miniprintf(#folder_path, "%s/res/skins", GetRealKolibriosPath());
|
||||
miniprintf(#folder_path, "%s/res/skins", get_real_kolibrios_path());
|
||||
Open_Dir();
|
||||
}
|
||||
|
||||
@ -335,7 +333,7 @@ void EventTabWallpappersClick()
|
||||
if (opendir_path) {
|
||||
strcpy(#folder_path, #opendir_path);
|
||||
} else {
|
||||
miniprintf(#folder_path, "%s/res/wallpapers", GetRealKolibriosPath());
|
||||
miniprintf(#folder_path, "%s/res/wallpapers", get_real_kolibrios_path());
|
||||
}
|
||||
Open_Dir();
|
||||
}
|
||||
@ -359,6 +357,13 @@ void EventTabScreensaverClick()
|
||||
select_list.count++;
|
||||
} while (j);
|
||||
|
||||
if (active_screensaver == -1) && (ESBYTE[#previous_ss]) {
|
||||
for (j=0; j<select_list.count; j++) {
|
||||
if (strstr(list.get(j), #previous_ss)) active_screensaver = j;
|
||||
}
|
||||
}
|
||||
select_list.cur_y = active_screensaver;
|
||||
|
||||
if (LIST_W) draw_window();
|
||||
}
|
||||
|
||||
@ -438,7 +443,7 @@ void EventOpenFile()
|
||||
|
||||
void EventExit()
|
||||
{
|
||||
if (GetRealKolibriosPath()) {
|
||||
if (get_real_kolibrios_path()) && (ESBYTE[#cur_skin_path]) {
|
||||
ini.section = "style";
|
||||
ini.SetString("skin", #cur_skin_path, strlen(#cur_skin_path));
|
||||
}
|
||||
@ -457,7 +462,13 @@ void EventSetSs()
|
||||
stop:
|
||||
|
||||
char folder_path[PATHLEN];
|
||||
|
||||
char cur_file_path[PATHLEN];
|
||||
char cur_skin_path[PATHLEN];
|
||||
|
||||
char default_skin[PATHLEN];
|
||||
char default_wallp[PATHLEN];
|
||||
|
||||
char previous_skin[PATHLEN];
|
||||
char previous_wallp[PATHLEN];
|
||||
char previous_ss[PATHLEN];
|
@ -37,10 +37,11 @@
|
||||
#endif
|
||||
|
||||
#define WIN_W 560
|
||||
#define WIN_H 450
|
||||
#define WIN_H 445
|
||||
#define LIST_W 260
|
||||
#define PANEL_H 50
|
||||
#define LP 6 //LIST_PADDING
|
||||
#define SL_VISIBLE WIN_H - PANEL_H - LP / SELECT_LIST_ITEMH
|
||||
|
||||
#define RIGHTx LP + LIST_W + TAB_P + 30
|
||||
#define RIGHTy PANEL_H
|
||||
@ -70,3 +71,36 @@ _tabs tabs = { -sizeof(t_skins)-sizeof(t_wallpapers)-sizeof(t_screensaver)
|
||||
|
||||
scroll_bar ss_timeout = { RIGHTw-19,RIGHTx,15,RIGHTy+25,0,3,89,10,0,0xFFFfff,
|
||||
0xBBBbbb,0xeeeeee};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void sort_by_name(int a, b) // for the first call: a = 0, b = sizeof(mas) - 1
|
||||
{
|
||||
int j;
|
||||
int isn = a;
|
||||
if (a >= b) return;
|
||||
for (j = a; j <= b; j++) {
|
||||
if (strcmpi(io.dir.position(ESDWORD[j*4+fmas]), io.dir.position(ESDWORD[b*4+fmas]))<=0) {
|
||||
ESDWORD[isn*4+fmas] >< ESDWORD[j*4+fmas];
|
||||
isn++;
|
||||
}
|
||||
}
|
||||
sort_by_name(a, isn-2);
|
||||
sort_by_name(isn, b);
|
||||
}
|
||||
|
||||
dword get_real_kolibrios_path()
|
||||
{
|
||||
char real_kolibrios_path[256];
|
||||
if (!dir_exists("/kolibrios")) return 0;
|
||||
SetCurDir("/kolibrios");
|
||||
GetCurDir(#real_kolibrios_path, sizeof(real_kolibrios_path));
|
||||
return #real_kolibrios_path;
|
||||
}
|
||||
|
||||
void SelectList_LineChanged()
|
||||
{
|
||||
EventApply();
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
tup.rule("default.asm", 'fasm "%f" "%o" ' .. tup.getconfig("KPACK_CMD"), "Blacky.skn")
|
||||
tup.rule("default.dtp.asm", 'fasm "%f" "%o"', "default.dtp")
|
||||
tup.rule({"default.asm", extra_inputs = {"default.dtp"}}, 'fasm "%f" "%o" ' .. tup.getconfig("KPACK_CMD"), "Blacky.skn")
|
||||
|
||||
|
@ -5,10 +5,10 @@ SKIN_PARAMS \
|
||||
margins = [6:5:65:3],\ ; margins [left:top:right:bottom]
|
||||
colors active = [binner=0x626262:\ ; border inner
|
||||
bouter=0x010812:\ ; border outer
|
||||
bframe=0x626262],\ ; border middle
|
||||
bframe=0x1E1E1E],\ ; border middle
|
||||
colors inactive = [binner=0x626262:\ ; border inner
|
||||
bouter=0x010812:\ ; border outer
|
||||
bframe=0x626262],\ ; border middle
|
||||
bframe=0x1E1E1E],\ ; border middle
|
||||
dtp = 'default.dtp' ; dtp colors
|
||||
|
||||
SKIN_BUTTONS \
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user