[PATCH] Toolbar button to control zoom level
Hi, Here is an updated patch with a better icon and fixed tooltip. Hopefully somebody finds it useful :) diff -u ./pixmaps.h mod/pixmaps.h --- ./pixmaps.h Sat Jul 6 18:03:43 2024 +++ mod/pixmaps.h Sat Jul 6 18:23:27 2024 @@ -1410,6 +1410,28 @@ }; /* XPM */ +static const char *const zoom_xpm[] = { +"16 16 2 1", +" c None", +"@ c gray70", +" ", +" @@@@@@ ", +" @ @ ", +" @ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@@@@@ @ ", +" @ @@@@@@@@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@ ", +" @@@@@@ @@@", +" @@", +" "}; + +/* XPM */ static const char *const new_s_xpm[] = { "11 11 35 1", " c None", diff -u ./ui.cc mod/ui.cc --- ./ui.cc Sat Jul 6 18:26:52 2024 +++ mod/ui.cc Sat Jul 6 18:03:57 2024 @@ -38,7 +38,7 @@ struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, - *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, + *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, *ImgZoom, *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn, *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn; }; @@ -51,6 +51,7 @@ new Fl_Pixmap(save_xpm), new Fl_Pixmap(bm_xpm), new Fl_Pixmap(tools_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), new Fl_Pixmap(search_xpm), new Fl_Pixmap(help_xpm), @@ -70,6 +71,7 @@ new Fl_Pixmap(save_s_xpm), new Fl_Pixmap(bm_s_xpm), new Fl_Pixmap(tools_s_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), standard_icons.ImgSearch, standard_icons.ImgHelp, @@ -356,6 +358,13 @@ wid->y() + wid->h()); } break; + case UI_ZOOM: + if (b == FL_LEFT_MOUSE) { + a_UIcmd_zoom_in(a_UIcmd_get_bw_by_widget(wid)); + } else if (b == FL_RIGHT_MOUSE) { + a_UIcmd_zoom_out(a_UIcmd_get_bw_by_widget(wid)); + } + break; default: break; } @@ -433,6 +442,7 @@ Stop = make_button("Stop", icons->ImgStop, icons->ImgStopIn, UI_STOP); Bookmarks = make_button("Book", icons->ImgBook, NULL, UI_BOOK); Tools = make_button("Tools", icons->ImgTools, NULL, UI_TOOLS); + Zoom = make_button("Zoom", icons->ImgZoom, NULL, UI_ZOOM); Back->set_tooltip("Previous page"); Forw->set_tooltip("Next page"); @@ -442,6 +452,7 @@ Stop->set_tooltip("Stop loading"); Bookmarks->set_tooltip("View bookmarks"); Tools->set_tooltip("Settings"); + Zoom->set_tooltip("Zoom in: left-click, Zoom out: right-click"); } /** diff -u ./ui.hh mod/ui.hh --- ./ui.hh Sat Jul 6 18:03:43 2024 +++ mod/ui.hh Sat Jul 6 18:03:57 2024 @@ -23,6 +23,7 @@ UI_STOP, UI_BOOK, UI_TOOLS, + UI_ZOOM, UI_CLEAR, UI_SEARCH } UIButton; @@ -125,7 +126,7 @@ CustGroupVertical *TopGroup; CustButton *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, - *Tools, *Clear, *Search, *Help, *BugMeter, *FileButton; + *Tools, *Zoom, *Clear, *Search, *Help, *BugMeter, *FileButton; CustGroupHorizontal *LocBar, *NavBar, *StatusBar; Fl_Input *Location; CustProgressBox *PProg, *IProg; -Alex
Hi Rodrigo and alex, both your patches work on fresh source and the zoom button works nicely (left mouse click for zoom out and right mouse click for zoom in Rodrigos patch applied in dillo-3.1.1 patching file src/bw.c patching file src/bw.h patching file src/keys.cc patching file src/keys.hh patching file src/prefs.c patching file src/prefs.h patching file src/styleengine.cc patching file src/ui.cc Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] n Skipping patch. 2 out of 2 hunks ignored -- saving rejects to file src/ui.cc.rej alex's patch applied in dillo-3.1.1/src patching file src/uicmd.cc patching file src/uicmd.hh patching file pixmaps.h patching file ui.cc patching file ui.hh all that is needed now is the 'magnifying glass' icon above the word Zoom 'borrowed' from the 'search button' :) On Sun, 7 Jul 2024 21:02:19 +0200 <a1ex@dismail.de> wrote:
Hi,
Here is an updated patch with a better icon and fixed tooltip. Hopefully somebody finds it useful :)
diff -u ./pixmaps.h mod/pixmaps.h --- ./pixmaps.h Sat Jul 6 18:03:43 2024 +++ mod/pixmaps.h Sat Jul 6 18:23:27 2024 @@ -1410,6 +1410,28 @@ };
/* XPM */ +static const char *const zoom_xpm[] = { +"16 16 2 1", +" c None", +"@ c gray70", +" ", +" @@@@@@ ", +" @ @ ", +" @ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@@@@@ @ ", +" @ @@@@@@@@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@ ", +" @@@@@@ @@@", +" @@", +" "}; + +/* XPM */ static const char *const new_s_xpm[] = { "11 11 35 1", " c None", diff -u ./ui.cc mod/ui.cc --- ./ui.cc Sat Jul 6 18:26:52 2024 +++ mod/ui.cc Sat Jul 6 18:03:57 2024 @@ -38,7 +38,7 @@
struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, - *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, + *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, *ImgZoom, *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn, *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn; }; @@ -51,6 +51,7 @@ new Fl_Pixmap(save_xpm), new Fl_Pixmap(bm_xpm), new Fl_Pixmap(tools_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), new Fl_Pixmap(search_xpm), new Fl_Pixmap(help_xpm), @@ -70,6 +71,7 @@ new Fl_Pixmap(save_s_xpm), new Fl_Pixmap(bm_s_xpm), new Fl_Pixmap(tools_s_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), standard_icons.ImgSearch, standard_icons.ImgHelp, @@ -356,6 +358,13 @@ wid->y() + wid->h()); } break; + case UI_ZOOM: + if (b == FL_LEFT_MOUSE) { + a_UIcmd_zoom_in(a_UIcmd_get_bw_by_widget(wid)); + } else if (b == FL_RIGHT_MOUSE) { + a_UIcmd_zoom_out(a_UIcmd_get_bw_by_widget(wid)); + } + break; default: break; } @@ -433,6 +442,7 @@ Stop = make_button("Stop", icons->ImgStop, icons->ImgStopIn, UI_STOP); Bookmarks = make_button("Book", icons->ImgBook, NULL, UI_BOOK); Tools = make_button("Tools", icons->ImgTools, NULL, UI_TOOLS); + Zoom = make_button("Zoom", icons->ImgZoom, NULL, UI_ZOOM);
Back->set_tooltip("Previous page"); Forw->set_tooltip("Next page"); @@ -442,6 +452,7 @@ Stop->set_tooltip("Stop loading"); Bookmarks->set_tooltip("View bookmarks"); Tools->set_tooltip("Settings"); + Zoom->set_tooltip("Zoom in: left-click, Zoom out: right-click"); }
/** diff -u ./ui.hh mod/ui.hh --- ./ui.hh Sat Jul 6 18:03:43 2024 +++ mod/ui.hh Sat Jul 6 18:03:57 2024 @@ -23,6 +23,7 @@ UI_STOP, UI_BOOK, UI_TOOLS, + UI_ZOOM, UI_CLEAR, UI_SEARCH } UIButton; @@ -125,7 +126,7 @@
CustGroupVertical *TopGroup; CustButton *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, - *Tools, *Clear, *Search, *Help, *BugMeter, *FileButton; + *Tools, *Zoom, *Clear, *Search, *Help, *BugMeter, *FileButton; CustGroupHorizontal *LocBar, *NavBar, *StatusBar; Fl_Input *Location; CustProgressBox *PProg, *IProg;
-Alex
Hi,
Here is an updated patch with a better icon and fixed tooltip. Hopefully somebody finds it useful :)
Thanks! I applied it from the attached file, like this: $ cd src $ md5sum /tmp/zoom-button.patch c8d48b41f30ba889ddd610860ecdc310 /tmp/patches/zoom-button.patch $ patch -p1 < /tmp/zoom-button.patch patching file pixmaps.h patching file ui.cc patching file ui.hh In the future, please perform the diffs from the top level directory, like so: $ diff -up dillo-orig/ dillo-mod/ (Or better, via "git format-patch" if you use git)
all that is needed now is the 'magnifying glass' icon above the word Zoom 'borrowed' from the 'search button' :)
There is a button there, but with the default Dillo options the color of the icon is very similar to the background (attached screenshot) and is barely visible. I think Alex may be using a different color scheme. I'm thinking if we could hide the save button by default and put the zoom there instead, as save is available from the page menu either way, and I think the zoom button would be used more frequently. We probably should add a "show_zoom" preference too in dillorc. Also we may want to use the middle click to reset the zoom level. Best, Rodrigo.
On Sat, 13 Jul 2024 11:07:10 +0200 Rodrigo Arias <rodarima@gmail.com> wrote:
all that is needed now is the 'magnifying glass' icon above the word Zoom 'borrowed' from the 'search button' :)
There is a button there, but with the default Dillo options the color of the icon is very similar to the background (attached screenshot) and is barely visible. I think Alex may be using a different color scheme.
You are correct. The patch was just a proof of concept, and I didn't spend too much time on the icon. Since there appears to be interest in this feature, I will work on a more complete patch which will address that, and the items mentioned below.
I'm thinking if we could hide the save button by default and put the zoom there instead, as save is available from the page menu either way, and I think the zoom button would be used more frequently.
We probably should add a "show_zoom" preference too in dillorc. Also we may want to use the middle click to reset the zoom level.
Agreed! Thanks, Alex
Hi just a suggestion when zooming in and out - is it possible to keep the center in the center - currently the center moves down when zooming in and up when zooming out On Sun, 7 Jul 2024 21:02:19 +0200 <a1ex@dismail.de> wrote:
Hi,
Here is an updated patch with a better icon and fixed tooltip. Hopefully somebody finds it useful :)
diff -u ./pixmaps.h mod/pixmaps.h --- ./pixmaps.h Sat Jul 6 18:03:43 2024 +++ mod/pixmaps.h Sat Jul 6 18:23:27 2024 @@ -1410,6 +1410,28 @@ };
/* XPM */ +static const char *const zoom_xpm[] = { +"16 16 2 1", +" c None", +"@ c gray70", +" ", +" @@@@@@ ", +" @ @ ", +" @ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@@@@@ @ ", +" @ @@@@@@@@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@ @ ", +" @ @@@@ ", +" @@@@@@ @@@", +" @@", +" "}; + +/* XPM */ static const char *const new_s_xpm[] = { "11 11 35 1", " c None", diff -u ./ui.cc mod/ui.cc --- ./ui.cc Sat Jul 6 18:26:52 2024 +++ mod/ui.cc Sat Jul 6 18:03:57 2024 @@ -38,7 +38,7 @@
struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, - *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, + *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, *ImgZoom, *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn, *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn; }; @@ -51,6 +51,7 @@ new Fl_Pixmap(save_xpm), new Fl_Pixmap(bm_xpm), new Fl_Pixmap(tools_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), new Fl_Pixmap(search_xpm), new Fl_Pixmap(help_xpm), @@ -70,6 +71,7 @@ new Fl_Pixmap(save_s_xpm), new Fl_Pixmap(bm_s_xpm), new Fl_Pixmap(tools_s_xpm), + new Fl_Pixmap(zoom_xpm), new Fl_Pixmap(new_s_xpm), standard_icons.ImgSearch, standard_icons.ImgHelp, @@ -356,6 +358,13 @@ wid->y() + wid->h()); } break; + case UI_ZOOM: + if (b == FL_LEFT_MOUSE) { + a_UIcmd_zoom_in(a_UIcmd_get_bw_by_widget(wid)); + } else if (b == FL_RIGHT_MOUSE) { + a_UIcmd_zoom_out(a_UIcmd_get_bw_by_widget(wid)); + } + break; default: break; } @@ -433,6 +442,7 @@ Stop = make_button("Stop", icons->ImgStop, icons->ImgStopIn, UI_STOP); Bookmarks = make_button("Book", icons->ImgBook, NULL, UI_BOOK); Tools = make_button("Tools", icons->ImgTools, NULL, UI_TOOLS); + Zoom = make_button("Zoom", icons->ImgZoom, NULL, UI_ZOOM);
Back->set_tooltip("Previous page"); Forw->set_tooltip("Next page"); @@ -442,6 +452,7 @@ Stop->set_tooltip("Stop loading"); Bookmarks->set_tooltip("View bookmarks"); Tools->set_tooltip("Settings"); + Zoom->set_tooltip("Zoom in: left-click, Zoom out: right-click"); }
/** diff -u ./ui.hh mod/ui.hh --- ./ui.hh Sat Jul 6 18:03:43 2024 +++ mod/ui.hh Sat Jul 6 18:03:57 2024 @@ -23,6 +23,7 @@ UI_STOP, UI_BOOK, UI_TOOLS, + UI_ZOOM, UI_CLEAR, UI_SEARCH } UIButton; @@ -125,7 +126,7 @@
CustGroupVertical *TopGroup; CustButton *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, - *Tools, *Clear, *Search, *Help, *BugMeter, *FileButton; + *Tools, *Zoom, *Clear, *Search, *Help, *BugMeter, *FileButton; CustGroupHorizontal *LocBar, *NavBar, *StatusBar; Fl_Input *Location; CustProgressBox *PProg, *IProg;
-Alex
participants (3)
-
a1ex@dismail.de
-
pastebin@gmx.com
-
Rodrigo Arias