Skip to content

Commit

Permalink
the size of icons now depends on the # of slices
Browse files Browse the repository at this point in the history
  • Loading branch information
phillbush committed Jun 13, 2020
1 parent 633f4da commit 424f8d4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ struct Pie {
int innercircley;
int innercirclediameter;

int iconsize;

double separatorbeg;
double separatorend;
};
Expand Down Expand Up @@ -279,7 +277,6 @@ setuppie(void)
pie.border = border_pixels;
pie.diameter = diameter_pixels;
pie.radius = (pie.diameter + 1) / 2;
pie.iconsize = (pie.radius + 1) / 2;
fulldiameter = pie.diameter + (pie.border * 2);

/* set the separator beginning and end */
Expand Down Expand Up @@ -565,9 +562,21 @@ setupslices(struct Menu *menu)

/* create icon */
if (slice->file != NULL) {
int iconw, iconh;
int maxiconsize = (pie.radius + 1) / 2;
double sliceanglerad; /* intern angle of a slice */
int iconw, iconh; /* icon width and height */
int iconsize; /* requested icon size */
int x, y;

sliceanglerad = (slice->angle2 * M_PI) / (180 * 64);

x = pie.radius * 0.5 - (pie.radius * (cos(sliceanglerad) * 0.5));
y = pie.radius - pie.radius + (pie.radius * (sin(sliceanglerad) * 0.5));

iconsize = sqrt(x * x + y * y);
iconsize = MIN(maxiconsize, iconsize);

slice->icon = loadicon(slice->file, pie.iconsize, &iconw, &iconh);
slice->icon = loadicon(slice->file, iconsize, &iconw, &iconh);

slice->iconx = pie.radius + (pie.radius * (cos(anglerad) * 0.6)) - iconw / 2;
slice->icony = pie.radius - (pie.radius * (sin(anglerad) * 0.6)) - iconh / 2;
Expand Down

0 comments on commit 424f8d4

Please sign in to comment.