mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 00:06:35 +00:00
cleanup
This commit is contained in:
parent
a9c1241df6
commit
29c8eb99ac
1 changed files with 78 additions and 50 deletions
|
@ -6,7 +6,7 @@ See $LK,"CCtrl",A="MN:CCtrl"$.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Start of autocreated Code
|
//Start of autocreated Code
|
||||||
#define SLIDER_RANGE 256
|
#define SLIDER_RANGE 255
|
||||||
#define SLIDER_SPACING 28
|
#define SLIDER_SPACING 28
|
||||||
#define SLIDER_BORDER 2
|
#define SLIDER_BORDER 2
|
||||||
|
|
||||||
|
@ -28,42 +28,65 @@ I0 DrawPixel(I64 x, I64 y, CBGR24 color)
|
||||||
|
|
||||||
U0 DrawCtrlSlider(CDC *dc,CCtrl *c)
|
U0 DrawCtrlSlider(CDC *dc,CCtrl *c)
|
||||||
{
|
{
|
||||||
|
|
||||||
CSliderState *s=c->state;
|
CSliderState *s=c->state;
|
||||||
|
|
||||||
|
|
||||||
//box
|
//box
|
||||||
|
|
||||||
dc->color=LTRED;
|
dc->color=LTRED;
|
||||||
GrRect(dc, c->left,c->top,SLIDER_SPACING*4+2,SLIDER_SPACING*2+SLIDER_RANGE);
|
GrRect(dc, c->left,
|
||||||
|
c->top,
|
||||||
|
SLIDER_SPACING*4+2,
|
||||||
|
SLIDER_SPACING*2+SLIDER_RANGE);
|
||||||
dc->color=BLUE;
|
dc->color=BLUE;
|
||||||
GrRect(dc, c->left+SLIDER_BORDER,c->top+SLIDER_BORDER,
|
GrRect(dc, c->left+SLIDER_BORDER,
|
||||||
|
c->top+SLIDER_BORDER,
|
||||||
SLIDER_SPACING*4+2-2*SLIDER_BORDER,
|
SLIDER_SPACING*4+2-2*SLIDER_BORDER,
|
||||||
SLIDER_SPACING*2+SLIDER_RANGE-2*SLIDER_BORDER);
|
SLIDER_SPACING*2+SLIDER_RANGE-2*SLIDER_BORDER);
|
||||||
|
|
||||||
//slider
|
//slider
|
||||||
|
|
||||||
dc->color=BLACK;
|
dc->color=BLACK;
|
||||||
|
|
||||||
I64 SLIDER_AMOUNT=3;
|
I64 SLIDER_AMOUNT=3;
|
||||||
I64 i,k,j,l;
|
I64 i,k,j,l;
|
||||||
for(i=1; i<=3; i++){
|
for(i=1; i<=3; i++){
|
||||||
GrLine(dc,c->left+i*SLIDER_SPACING+i-1,c->top+SLIDER_SPACING, c->left+i*SLIDER_SPACING+i-1,c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
GrLine(dc, c->left+i*SLIDER_SPACING+i-1,
|
||||||
|
c->top+SLIDER_SPACING,
|
||||||
|
c->left+i*SLIDER_SPACING+i-1,
|
||||||
|
c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//values
|
//values
|
||||||
|
|
||||||
dc->color=LTRED;
|
dc->color=LTRED;
|
||||||
I64 pos,col;
|
I64 pos,col;
|
||||||
|
|
||||||
for(i=1; i<=3; i++){
|
for(i=1; i<=3; i++){
|
||||||
|
|
||||||
if (i==1) { pos=s->left_pos; col="B";}
|
if (i==1) { pos=s->left_pos; col="B";}
|
||||||
if (i==2) { pos=s->middle_pos;col="G";}
|
if (i==2) { pos=s->middle_pos;col="G";}
|
||||||
if (i==3) { pos=s->right_pos; col="R";}
|
if (i==3) { pos=s->right_pos; col="R";}
|
||||||
|
|
||||||
//values
|
//values
|
||||||
GrPrint(dc,c->left+i*SLIDER_SPACING+i-FONT_WIDTH/2, c->top+SLIDER_SPACING+SLIDER_RANGE+8, "%d",pos);
|
GrPrint(dc, c->left+i*SLIDER_SPACING+i-FONT_WIDTH/2,
|
||||||
|
c->top+SLIDER_SPACING+SLIDER_RANGE+8,
|
||||||
|
"%d",pos);
|
||||||
//RGB label
|
//RGB label
|
||||||
GrPrint(dc,c->left+i*SLIDER_SPACING+3-FONT_WIDTH/2,c->top+14, "%s", col);
|
GrPrint(dc, c->left+i*SLIDER_SPACING+3-FONT_WIDTH/2,
|
||||||
|
c->top+14,
|
||||||
|
"%s", col);
|
||||||
//knobs
|
//knobs
|
||||||
GrRect(dc,c->left+i*SLIDER_SPACING+i-4, c->top+SLIDER_SPACING+SLIDER_RANGE-1-pos-2,7,5);
|
GrRect(dc, c->left+i*SLIDER_SPACING+i-4,
|
||||||
//inner knobs
|
c->top+SLIDER_SPACING+SLIDER_RANGE-1-pos-2,
|
||||||
//dc->color=YELLOW;
|
7,5);
|
||||||
//GrRect(dc,c->left+i*SLIDER_SPACING+i-2, c->top+SLIDER_SPACING+SLIDER_RANGE-1-pos-1,5,3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//color preview
|
//color preview
|
||||||
I64 size=20;
|
I64 size=20;
|
||||||
|
|
||||||
for(i=0;i<16;i++){
|
for(i=0;i<16;i++){
|
||||||
for (j = 0; j <= size; j++){
|
for (j = 0; j <= size; j++){
|
||||||
for (k = 0; k <= size; k++){
|
for (k = 0; k <= size; k++){
|
||||||
|
@ -77,10 +100,11 @@ U0 DrawCtrlSlider(CDC *dc,CCtrl *c)
|
||||||
// label
|
// label
|
||||||
GrPrint(dc,(size/2)+4+(i*size),c->top - 180, "%d", i+1);
|
GrPrint(dc,(size/2)+4+(i*size),c->top - 180, "%d", i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// current color box preview
|
// current color box preview
|
||||||
GrPrint(dc,size,c->top,"Current Color in RGB: %u,%u,%u", gr_palette[SELECTED_COLOR] & 0xFF,
|
GrPrint(dc,size,c->top,"Current Color in RGB: %u,%u,%u", gr_palette[SELECTED_COLOR].r,
|
||||||
gr_palette[SELECTED_COLOR] >> 8 & 0xFF,
|
gr_palette[SELECTED_COLOR].g,
|
||||||
gr_palette[SELECTED_COLOR] >> 16 & 0xFF);
|
gr_palette[SELECTED_COLOR].b);
|
||||||
// pixel loop for current color preview
|
// pixel loop for current color preview
|
||||||
for(i=0; i <=size; i++)
|
for(i=0; i <=size; i++)
|
||||||
for(j=0; j<=size; j++){
|
for(j=0; j<=size; j++){
|
||||||
|
@ -91,43 +115,37 @@ U0 DrawCtrlSlider(CDC *dc,CCtrl *c)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//public CBGR24 gr_palette_temp[16] = {
|
|
||||||
// 0xFFFFFF, 0x3465A4, 0x4E9A06, 0x06989A, 0xA24444, 0x75507B, 0xCE982F, 0xBCC0B9,
|
|
||||||
// 0x555753, 0x729FCF, 0x82BC49, 0x34E2E2, 0xAC3535, 0xAD7FA8, 0xFCE94F, 0x000000
|
|
||||||
//};
|
|
||||||
|
|
||||||
U0 FESave(Bool prompt)
|
U0 FESave(Bool prompt)
|
||||||
{
|
{
|
||||||
//U8 old_draw_it = Fs->draw_it;
|
//U8 old_draw_it = Fs->draw_it;
|
||||||
CDoc *doc = DocNew;
|
CDoc *doc = DocNew;
|
||||||
I64 i;
|
I64 i;
|
||||||
I64 name="blue";
|
U8 tmp_name= doc->filename.name;
|
||||||
|
U8 name;
|
||||||
|
//StrLastRemove(tmp_name,".", name);
|
||||||
|
//StrFirstRemove(tmp_name,"/", name);
|
||||||
|
|
||||||
DocPrint(doc, "public CBGR24 gr_palette_%s[COLORS_NUM] = {
|
DocPrint(doc, "public CBGR24 gr_palette_%s[COLORS_NUM] = {\n ", name);
|
||||||
", name);
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if (i == 15) DocPrint(doc, "0x%X", gr_palette[i]);
|
if (i == 15) DocPrint(doc, "0x%X", gr_palette[i]);
|
||||||
else DocPrint(doc, "0x%X, ", gr_palette[i]);
|
else DocPrint(doc, "0x%X, ", gr_palette[i]);
|
||||||
|
|
||||||
if (i == 7) {
|
if (i == 7) {
|
||||||
DocPrint(doc, "
|
DocPrint(doc, "\n ");
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DocPrint(doc, "
|
DocPrint(doc,"\n};
|
||||||
};
|
\n\n
|
||||||
|
public U0 PaletteSet%s(Bool persistent=TRUE)\n
|
||||||
public U0 PaletteSetBlue(Bool persistent=TRUE)
|
{\n GrPaletteSet(gr_palette_%s);\n
|
||||||
{
|
LFBFlush;\n
|
||||||
GrPaletteSet(gr_palette_%s);
|
if (persistent)\n
|
||||||
LFBFlush;
|
fp_set_std_palette = &PaletteSet%s\n
|
||||||
if (persistent)
|
}",name,name,name);
|
||||||
fp_set_std_palette = &PaletteSetBlue;
|
|
||||||
}",name);
|
|
||||||
|
|
||||||
DocWrite(doc, prompt);
|
DocWrite(doc, prompt);
|
||||||
DocDel(doc);
|
DocDel(doc);
|
||||||
}
|
}
|
||||||
|
@ -152,18 +170,23 @@ U0 SelectColor(I64 color_number, CCtrl *c){
|
||||||
SELECTED_COLOR = color_number;
|
SELECTED_COLOR = color_number;
|
||||||
CSliderState *s=c->state;
|
CSliderState *s=c->state;
|
||||||
|
|
||||||
s->left_pos = gr_palette[SELECTED_COLOR] & 0xFF;
|
s->left_pos = gr_palette[SELECTED_COLOR].r;
|
||||||
s->middle_pos= gr_palette[SELECTED_COLOR] >> 8 & 0xFF;
|
s->middle_pos= gr_palette[SELECTED_COLOR].g;
|
||||||
s->right_pos = gr_palette[SELECTED_COLOR] >> 16 & 0xFF;
|
s->right_pos = gr_palette[SELECTED_COLOR].b;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 UpdateDerivedCtrlSlider(CCtrl *c)
|
U0 UpdateDerivedCtrlSlider(CCtrl *c)
|
||||||
{
|
{
|
||||||
CSliderState *s=c->state;
|
CSliderState *s=c->state;
|
||||||
|
|
||||||
c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2;
|
// c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2;
|
||||||
|
// c->right=c->left+3*SLIDER_SPACING+2;
|
||||||
|
// c->top=c->win_task->pix_height/2-(SLIDER_SPACING*2+SLIDER_RANGE)/2;
|
||||||
|
// c->bottom=c->top+SLIDER_SPACING*2+SLIDER_RANGE;
|
||||||
|
|
||||||
|
c->left=c->win_task->pix_width/2;
|
||||||
c->right=c->left+3*SLIDER_SPACING+2;
|
c->right=c->left+3*SLIDER_SPACING+2;
|
||||||
c->top=c->win_task->pix_height/2-(SLIDER_SPACING*2+SLIDER_RANGE)/2;
|
c->top=c->win_task->pix_height/3;
|
||||||
c->bottom=c->top+SLIDER_SPACING*2+SLIDER_RANGE;
|
c->bottom=c->top+SLIDER_SPACING*2+SLIDER_RANGE;
|
||||||
|
|
||||||
// I used to clamp between 0 and 127 and do math but i changed it to 256 for now.
|
// I used to clamp between 0 and 127 and do math but i changed it to 256 for now.
|
||||||
|
@ -173,12 +196,13 @@ U0 UpdateDerivedCtrlSlider(CCtrl *c)
|
||||||
|
|
||||||
// add the slider's BGR value to s->preview
|
// add the slider's BGR value to s->preview
|
||||||
s->preview = s->left_pos + s->middle_pos << 8 + s->right_pos << 16;
|
s->preview = s->left_pos + s->middle_pos << 8 + s->right_pos << 16;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
U0 LeftClickSlider(CCtrl *c,I64 x,I64 y,Bool)
|
U0 LeftClickSlider(CCtrl *c,I64 x,I64 y,Bool)
|
||||||
{
|
{
|
||||||
CSliderState *s=c->state;
|
CSliderState *s=c->state;
|
||||||
|
|
||||||
if (x<c->left+1*SLIDER_SPACING+0+SLIDER_SPACING/3)
|
if (x<c->left+1*SLIDER_SPACING+0+SLIDER_SPACING/3)
|
||||||
s->left_pos=SLIDER_RANGE-1-(y-(c->top+SLIDER_SPACING));
|
s->left_pos=SLIDER_RANGE-1-(y-(c->top+SLIDER_SPACING));
|
||||||
|
|
||||||
|
@ -193,7 +217,6 @@ U0 LeftClickSlider(CCtrl *c,I64 x,I64 y,Bool)
|
||||||
// set palette
|
// set palette
|
||||||
gr_palette[SELECTED_COLOR] = s->preview;
|
gr_palette[SELECTED_COLOR] = s->preview;
|
||||||
PaletteSetTemp(FALSE);
|
PaletteSetTemp(FALSE);
|
||||||
LFBFlush; //why is this used?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CCtrl *SliderNew()
|
CCtrl *SliderNew()
|
||||||
|
@ -224,6 +247,9 @@ U0 Main()
|
||||||
{
|
{
|
||||||
|
|
||||||
SettingsPush;
|
SettingsPush;
|
||||||
|
WinBorder;
|
||||||
|
WinMax;
|
||||||
|
WinHorz(0, 50, Fs);
|
||||||
MenuPush(
|
MenuPush(
|
||||||
"File {"
|
"File {"
|
||||||
" New(,'.');"
|
" New(,'.');"
|
||||||
|
@ -241,7 +267,9 @@ U0 Main()
|
||||||
//AutoComplete;
|
//AutoComplete;
|
||||||
//WinBorder;
|
//WinBorder;
|
||||||
//WinMax;
|
//WinMax;
|
||||||
|
//WinTileVert;
|
||||||
|
// WinHorz(50,Fs->win_right);
|
||||||
|
// WinVert(3, Fs->win_bottom);
|
||||||
//dirname=StrNew("~/Palettes");
|
//dirname=StrNew("~/Palettes");
|
||||||
|
|
||||||
MenuPop;
|
MenuPop;
|
||||||
|
|
Loading…
Reference in a new issue