diff --git a/mpanel/CMakeLists.txt b/mpanel/CMakeLists.txt index 9de3605..039ab88 100644 --- a/mpanel/CMakeLists.txt +++ b/mpanel/CMakeLists.txt @@ -13,6 +13,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Linux) endif() add_subdirectory(separator) +add_subdirectory(startbutton) include(GNUInstallDirs) configure_file(mpanelrc.in mpanelrc) diff --git a/mpanel/mpanelrc.in b/mpanel/mpanelrc.in index f716ca1..effda28 100644 --- a/mpanel/mpanelrc.in +++ b/mpanel/mpanelrc.in @@ -1,4 +1,7 @@ Modules: ( + { + Type = "StartButton"; + }, { Type = "Separator"; } diff --git a/mpanel/startbutton/CMakeLists.txt b/mpanel/startbutton/CMakeLists.txt new file mode 100644 index 0000000..b5cb36e --- /dev/null +++ b/mpanel/startbutton/CMakeLists.txt @@ -0,0 +1,6 @@ +include(MDEBase) +include(MDEPkgConfig) +mde_setup_library(StartButtonModule ${CMAKE_INSTALL_LIBDIR}/mpanel) + +mde_pkg_config_add(StartButtonModule libconfig) + diff --git a/mpanel/startbutton/module.c b/mpanel/startbutton/module.c new file mode 100644 index 0000000..f067985 --- /dev/null +++ b/mpanel/startbutton/module.c @@ -0,0 +1,67 @@ +#include "config.h" + +#include + +#include +#include + +#define TriW 5 + +void module(MwWidget box, config_setting_t* setting) { + MwLLPixmap closed = NULL; + MwLLPixmap opened = NULL; + int w, h; + unsigned int ch; + unsigned char* rgb; + + if((rgb = stbi_load(ICON64DIR "/logo.png", &w, &h, &ch, 4)) != NULL) { + int bw = MwGetInteger(box, MwNheight) - MwDefaultBorderWidth(box) * 2; + unsigned char* data = malloc(bw * bw * 4); + unsigned char* save = malloc(bw * bw * 4); + int y, x; + int max = (TriW - 1) / 2; + + memset(data, 0, bw * bw * 4); + for(y = 0; y < h; y++) { + int fy = y * bw / h; + for(x = 0; x < w; x++) { + int fx = x * bw / w; + memcpy(&data[(fy * bw + fx) * 4], &rgb[(y * w + x) * 4], 4); + } + } + memcpy(save, data, bw * bw * 4); + + for(y = 0; y < max + 1; y++) { + int tw = y * 2 + 1; + int ix = w - TriW + (max - y); + + for(x = 0; x < tw; x++) { + data[4 * (y * bw + x + ix) + 3] = 255; + } + } + closed = MwLoadRaw(box, data, bw, bw); + + memcpy(data, save, bw * bw * 4); + + max = (TriW - 1) / 2; + for(y = 0; y < max + 1; y++) { + int tw = (max - y) * 2 + 1; + int ix = w - TriW + y; + + for(x = 0; x < tw; x++) { + data[4 * (y * bw + x + ix) + 3] = 255; + } + } + opened = MwLoadRaw(box, data, bw, bw); + + free(save); + free(data); + free(rgb); + } + + MwVaCreateWidget(MwButtonClass, "startbutton", box, 0, 0, 0, 0, + MwNfixedSize, MwGetInteger(box, MwNheight), + MwNflat, 1, + MwNpixmap, closed, + NULL); +} diff --git a/mpanel/startbutton/stb_image.c b/mpanel/startbutton/stb_image.c new file mode 100644 index 0000000..9177288 --- /dev/null +++ b/mpanel/startbutton/stb_image.c @@ -0,0 +1,2 @@ +#define STB_IMAGE_IMPLEMENTATION +#include