/* :dword MixColors(dword _base, _overlying, dword a) { _rgb rgb1, rgb2, rgb_final; dword n_a; rgb1.DwordToRgb(_base); rgb2.DwordToRgb(_overlying); n_a = 255 - a; rgb_final.b = calc(rgb1.b*a/255) + calc(rgb2.b*n_a/255); rgb_final.g = calc(rgb1.g*a/255) + calc(rgb2.g*n_a/255); rgb_final.r = calc(rgb1.r*a/255) + calc(rgb2.r*n_a/255); return rgb_final.RgbToDword(); } :bool skin_is_dark() { ESI = #sc.work; EDI = DSBYTE[ESI]*DSBYTE[ESI]; EDI += DSBYTE[ESI+1]*DSBYTE[ESI+1]; EDI += DSBYTE[ESI+2]*DSBYTE[ESI+2]; if (sqrt(EDI) / 3 < 65) { return true; } else { return false; } } unsigned int DrawTopPanelButton(dword _button_id, _x, _y, signed int _icon_n, bool pressed) { #define TSZE 25 static dword lightest, i16_mem, old_work_light; dword i16_size; if (!lightest) || (old_work_light != sc.light) { old_work_light = sc.light; lightest = MixColors(sc.light, 0xFFFfff, skin_is_dark()*155 + 20); if (ESI = memopen("ICONS18", NULL, SHM_READ)) { i16_size = EDX; i16_mem = malloc(i16_size); memmov(i16_mem, ESI, i16_size); replace_2cols(i16_mem, i16_size, 0xffFFFfff, sc.light, 0xffCACBD6, sc.dark); } } DrawWideRectangle(_x+1, _y+1, TSZE, TSZE, 5, sc.light); DefineHiddenButton(_x, _y, TSZE+1, TSZE+1, _button_id); if (_icon_n==-1) { DrawBar(_x+6, _y+5, 16, 16, sc.light); DrawBar(_x+6, _y+7, 15, 3, sc.line); $add ecx,5*65536 $int 64 $add ecx,5*65536 $int 64 } else { if (i16_mem) PutPaletteImage(18*18*4*_icon_n + i16_mem, 18, 18, TSZE/2-9+2+_x, TSZE/2-9+1+_y+pressed, 32, 0); } if (!pressed) { DrawOvalBorder(_x, _y, TSZE, TSZE, lightest, sc.line, sc.light, sc.work); } else { DrawOvalBorder(_x, _y, TSZE, TSZE, sc.line, sc.light, sc.dark, sc.work); PutShadow(_x+1, _y+1, TSZE, TSZE, true, 2); } return _x; } */ #include #include #include #include #include #define TSZE 25 extern ksys_colors_table_t color_table; void replace_2cols(ksys_color_t* buff, uint32_t size, ksys_color_t col_in1, ksys_color_t col_out1, ksys_color_t col_in2, ksys_color_t col_out2){ uint32_t end_ptr = size + (uint32_t)buff; while ((uint32_t)buff < (uint32_t)end_ptr) { if (*buff == col_in1) *buff = col_out1; else if (*buff == col_in2) *buff = col_out1; buff++; }; return; } #define BT_HIDE 0x40000000 static void DefineHiddenButton(uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h, uint32_t _id) { _ksys_delete_button(_id); _ksys_define_button(_x, _y, _w, _h, _id + BT_HIDE, 0); return; } static void DrawWideRectangle(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t boder, ksys_color_t color1) { _ksys_draw_bar(x, y, w, boder, color1); _ksys_draw_bar(x, y+h-boder, w, boder, color1); _ksys_draw_bar(x, y+boder, boder, h-boder-boder, color1); _ksys_draw_bar(x+w-boder, y+boder, boder, h-boder-boder, color1); return; } static void DrawOvalBorder(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t light, ksys_color_t dark, ksys_color_t right, ksys_color_t dots) { _ksys_draw_bar(x+1, y, w, 1, light); _ksys_draw_bar(x+1, y+h+1, w, 1, dark); _ksys_draw_bar(x, y+1, 1, h-1, light); _ksys_draw_bar(x+w+1, y+2, 1, h-2, right); _ksys_draw_pixel(x, y, dots); _ksys_draw_pixel(x+w+1, y+h+1, dots); _ksys_draw_pixel(x, y+h+1, dots); _ksys_draw_pixel(x+w+1, y, dots); _ksys_draw_pixel(x, y+h, dark); _ksys_draw_pixel(x+w+1, y+1, light); _ksys_draw_pixel(x+w+1, y+h, dark); return; } ksys_color_t lightest = 0; void* i16_mem = NULL; void gui_draw_button_icon18(uint32_t button_id, uint16_t x, uint16_t y, uint32_t id_icon, int pressed){ uint32_t i16_size; if ((!lightest) || (lightest != color_table.grab_button_text)) { //old_work_light = sc.grab_button_text; lightest = color_table.grab_button_text;//MixColors(sc.light, 0xFFFfff, skin_is_dark()*155 + 20); void* buffer; int shm_size = _ksys_shm_open("ICONS18", KSYS_SHM_READ, 0, (char**)&buffer); if (shm_size) { i16_size = shm_size; if (i16_mem != 0) free(i16_mem); i16_mem = malloc(i16_size); memmove(i16_mem, buffer, i16_size); replace_2cols(i16_mem, i16_size, 0xffFFFfff, color_table.grab_button_text, 0xffCACBD6, color_table.grab_bar_button); } } DrawWideRectangle(x+1, y+1, TSZE, TSZE, 5, color_table.grab_button_text); DefineHiddenButton(x, y, TSZE+1, TSZE+1, button_id); if (id_icon == -1) { _ksys_draw_bar(x+6, y+5, 16, 16, color_table.grab_button_text); _ksys_draw_bar(x+6, y+7, 15, 3, color_table.work_graph); _ksys_draw_bar(x+6, y+7+5, 15, 3, color_table.work_graph); _ksys_draw_bar(x+6, y+7+10, 15, 3, color_table.work_graph); } else { if (i16_mem) ksys_draw_bitmap_palette(i16_mem + 18*18*4*id_icon, TSZE/2-9+2+x, TSZE/2-9+1+y+pressed, 18, 18, 32, NULL, 0); } if (!pressed) { DrawOvalBorder(x, y, TSZE, TSZE, lightest, color_table.work_graph, color_table.grab_button_text, color_table.work_area); } else { DrawOvalBorder(x, y, TSZE, TSZE, color_table.work_graph, color_table.grab_button_text, color_table.grab_bar_button, color_table.work_area); //PutShadow(x+1, y+1, TSZE, TSZE, true, 2); }; return ; } void write_text_utf8_center(uint32_t x, uint32_t y, int32_t w, const char* text, int32_t SSS) { int32_t tmp = w - utf8len(text)*8*(SSS+1); if (tmp < 0) tmp = 0; _ksys_draw_text(text, x+tmp/2, y, 0, ((0xB0 + SSS)<< 24)+ color_table.work_text); return; }