add the ability to full screen an image + code cleanup
images are drawn quite slowly, something needs to be done about that soon
This commit is contained in:
parent
b730dd6fa9
commit
15141c230d
|
@ -500,6 +500,13 @@ spmenu = {
|
||||||
function = "toggleimg";
|
function = "toggleimg";
|
||||||
argument = "0";
|
argument = "0";
|
||||||
},
|
},
|
||||||
|
// f: Toggle image full screen mode
|
||||||
|
{ mode = 0;
|
||||||
|
modifier = "None";
|
||||||
|
key = "f";
|
||||||
|
function = "togglefullimg";
|
||||||
|
argument = "0";
|
||||||
|
},
|
||||||
// h: Flip image horizontally
|
// h: Flip image horizontally
|
||||||
{ mode = 0;
|
{ mode = 0;
|
||||||
modifier = "None";
|
modifier = "None";
|
||||||
|
|
|
@ -41,6 +41,7 @@ static Key keys[] = {
|
||||||
{ 0, Shift, XK_1, setimggaps, {.i = -100 } },
|
{ 0, Shift, XK_1, setimggaps, {.i = -100 } },
|
||||||
{ 0, Shift, XK_2, setimggaps, {.i = +100 } },
|
{ 0, Shift, XK_2, setimggaps, {.i = +100 } },
|
||||||
{ 0, 0, XK_t, toggleimg, {0} },
|
{ 0, 0, XK_t, toggleimg, {0} },
|
||||||
|
{ 0, 0, XK_f, togglefullimg, {0} },
|
||||||
{ 0, 0, XK_p, paste, {.i = 2 } },
|
{ 0, 0, XK_p, paste, {.i = 2 } },
|
||||||
{ 0, 0, XK_h, flipimg, {.i = 1 } },
|
{ 0, 0, XK_h, flipimg, {.i = 1 } },
|
||||||
{ 0, 0, XK_v, flipimg, {.i = 0 } },
|
{ 0, 0, XK_v, flipimg, {.i = 0 } },
|
||||||
|
|
21
libs/arg.c
21
libs/arg.c
|
@ -403,6 +403,25 @@ void toggleimg(Arg *arg) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void togglefullimg(Arg *arg) {
|
||||||
|
#if USEIMAGE
|
||||||
|
fullscreen = image ? !fullscreen : 0;
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
ow = imagewidth;
|
||||||
|
oh = imageheight;
|
||||||
|
|
||||||
|
imagewidth = mw;
|
||||||
|
imageheight = mh;
|
||||||
|
} else {
|
||||||
|
imagewidth = ow;
|
||||||
|
imageheight = oh;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawmenu();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void defaultimg(Arg *arg) {
|
void defaultimg(Arg *arg) {
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
|
|
||||||
|
@ -419,6 +438,7 @@ void defaultimg(Arg *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setlines(Arg *arg) {
|
void setlines(Arg *arg) {
|
||||||
|
if (fullscreen) return;
|
||||||
lines += arg->i;
|
lines += arg->i;
|
||||||
if (lines < 0) lines = 0;
|
if (lines < 0) lines = 0;
|
||||||
|
|
||||||
|
@ -428,6 +448,7 @@ void setlines(Arg *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setcolumns(Arg *arg) {
|
void setcolumns(Arg *arg) {
|
||||||
|
if (fullscreen) return;
|
||||||
columns += arg->i;
|
columns += arg->i;
|
||||||
if (columns < 1) columns = 1;
|
if (columns < 1) columns = 1;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ static void quit(Arg *arg);
|
||||||
static void complete(Arg *arg);
|
static void complete(Arg *arg);
|
||||||
static void setimgsize(Arg *arg);
|
static void setimgsize(Arg *arg);
|
||||||
static void toggleimg(Arg *arg);
|
static void toggleimg(Arg *arg);
|
||||||
|
static void togglefullimg(Arg *arg);
|
||||||
static void defaultimg(Arg *arg);
|
static void defaultimg(Arg *arg);
|
||||||
static void rotateimg(Arg *arg);
|
static void rotateimg(Arg *arg);
|
||||||
static void flipimg(Arg *arg);
|
static void flipimg(Arg *arg);
|
||||||
|
|
|
@ -356,6 +356,7 @@ static FuncList fl[] = {
|
||||||
{ "setimgsize", setimgsize },
|
{ "setimgsize", setimgsize },
|
||||||
{ "setimgsize", setimgsize },
|
{ "setimgsize", setimgsize },
|
||||||
{ "toggleimg", toggleimg },
|
{ "toggleimg", toggleimg },
|
||||||
|
{ "togglefullimg", togglefullimg },
|
||||||
{ "defaultimg", defaultimg },
|
{ "defaultimg", defaultimg },
|
||||||
{ "rotateimg", rotateimg },
|
{ "rotateimg", rotateimg },
|
||||||
{ "flipimg", flipimg },
|
{ "flipimg", flipimg },
|
||||||
|
|
13
libs/draw.c
13
libs/draw.c
|
@ -488,31 +488,32 @@ void drawmenu(void) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!hideprompt) {
|
if (!hideprompt && !fullscreen) {
|
||||||
w = promptw;
|
w = promptw;
|
||||||
x = drawprompt(x, y, w);
|
x = drawprompt(x, y, w);
|
||||||
}
|
}
|
||||||
if (!hideinput) {
|
|
||||||
|
if (!hideinput && !fullscreen) {
|
||||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
x = drawinput(x, y, w);
|
x = drawinput(x, y, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||||
|
|
||||||
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
||||||
if (!hideitem) drawitem(x, y, w);
|
if (!hideitem) drawitem(x, y, w);
|
||||||
|
|
||||||
if (!hidematchcount) {
|
if (!hidematchcount && !fullscreen) {
|
||||||
w = numberWidth;
|
w = numberWidth;
|
||||||
drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidemode) {
|
if (!hidemode && !fullscreen) {
|
||||||
w = modeWidth;
|
w = modeWidth;
|
||||||
drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidecaps) {
|
if (!hidecaps && !fullscreen) {
|
||||||
w = capsWidth;
|
w = capsWidth;
|
||||||
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||||
}
|
}
|
||||||
|
|
19
libs/img.c
19
libs/img.c
|
@ -4,7 +4,7 @@ void setimagesize(int width, int height) {
|
||||||
int oiw = 0;
|
int oiw = 0;
|
||||||
|
|
||||||
// this makes sure we cannot scale the image up or down too much
|
// this makes sure we cannot scale the image up or down too much
|
||||||
if ((!image && height < imageheight) || (!image && width < imagewidth) || (width < 0) || width > mw || hideimage) return;
|
if ((!image && height < imageheight) || (!image && width < imagewidth) || (width < 0) || width > mw || hideimage || fullscreen) return;
|
||||||
|
|
||||||
// original width/height
|
// original width/height
|
||||||
oih = imageheight;
|
oih = imageheight;
|
||||||
|
@ -94,24 +94,31 @@ void drawimage(void) {
|
||||||
xta += menumarginh;
|
xta += menumarginh;
|
||||||
wta += menumarginv;
|
wta += menumarginv;
|
||||||
|
|
||||||
if (mh != bh + height + imagegaps * 2 - wtr) { // menu height cannot be smaller than image height
|
if (mh != bh + height + leftmargin * 2 - wtr && !fullscreen) { // menu height cannot be smaller than image height
|
||||||
resizetoimageheight(height);
|
resizetoimageheight(height);
|
||||||
|
} else if (mh != bh + height + leftmargin * 2 - wtr && fullscreen) {
|
||||||
|
resizetoimageheight(height-bh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we're covering all the area
|
||||||
|
if (fullscreen) {
|
||||||
|
xta = wta = wtr = leftmargin = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render image
|
// render image
|
||||||
if (!imageposition && image) { // top mode = 0
|
if (!imageposition && image) { // top mode = 0
|
||||||
if (height > width)
|
if (height > width)
|
||||||
width = height;
|
width = height;
|
||||||
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, wta+imagegaps);
|
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, wta+leftmargin);
|
||||||
} else if (imageposition == 1 && image) { // bottom mode = 1
|
} else if (imageposition == 1 && image) { // bottom mode = 1
|
||||||
if (height > width)
|
if (height > width)
|
||||||
width = height;
|
width = height;
|
||||||
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, mh-height-imagegaps);
|
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, mh-height-leftmargin);
|
||||||
} else if (imageposition == 2 && image) { // center mode = 2
|
} else if (imageposition == 2 && image) { // center mode = 2
|
||||||
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (mh-wta-height)/2+wta);
|
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (mh-wta-height)/2+wta);
|
||||||
} else if (image) { // top center
|
} else if (image) { // top center
|
||||||
int minh = MIN(height, mh-bh-imagegaps*2);
|
int minh = MIN(height, mh-bh-leftmargin*2);
|
||||||
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+imagegaps);
|
imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+leftmargin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
spmenu.c
3
spmenu.c
|
@ -183,7 +183,10 @@ static int longestedge = 0;
|
||||||
static int imagew = 0;
|
static int imagew = 0;
|
||||||
static int imageh = 0;
|
static int imageh = 0;
|
||||||
static int imageg = 0;
|
static int imageg = 0;
|
||||||
|
static int ow = 0;
|
||||||
|
static int oh = 0;
|
||||||
#endif
|
#endif
|
||||||
|
static int fullscreen = 0;
|
||||||
|
|
||||||
// config file
|
// config file
|
||||||
#if USECONFIG
|
#if USECONFIG
|
||||||
|
|
Loading…
Reference in a new issue