startbutton
This commit is contained in:
parent
57a32b56b1
commit
ac809775c8
5 changed files with 79 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(separator)
|
add_subdirectory(separator)
|
||||||
|
add_subdirectory(startbutton)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
configure_file(mpanelrc.in mpanelrc)
|
configure_file(mpanelrc.in mpanelrc)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
Modules: (
|
Modules: (
|
||||||
|
{
|
||||||
|
Type = "StartButton";
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Type = "Separator";
|
Type = "Separator";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
mpanel/startbutton/CMakeLists.txt
Normal file
6
mpanel/startbutton/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
include(MDEBase)
|
||||||
|
include(MDEPkgConfig)
|
||||||
|
mde_setup_library(StartButtonModule ${CMAKE_INSTALL_LIBDIR}/mpanel)
|
||||||
|
|
||||||
|
mde_pkg_config_add(StartButtonModule libconfig)
|
||||||
|
|
||||||
67
mpanel/startbutton/module.c
Normal file
67
mpanel/startbutton/module.c
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
#include <libconfig.h>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
2
mpanel/startbutton/stb_image.c
Normal file
2
mpanel/startbutton/stb_image.c
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include <stb_image.h>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue