summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-10-06 10:37:14 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-10-13 13:36:47 +0200
commit7bade294672a638bcd1b0451333be5bb948cbbf7 (patch)
treea44310f1ba962197bdda543a19d32c08b7929534
parent05094b91a070c0a498870a473b37732929289ca1 (diff)
Add support for left scrollbar
Implements support for placing the vertical scrollbar on the left side by setting scrollbar_on_left=YES on dillorc. By default, continues to be on the right side. See: https://www.toomanyatoms.com/software/mobilized_dillo.html Authored-By: dogma
-rw-r--r--ChangeLog1
-rw-r--r--dillorc3
-rw-r--r--doc/user_help.in.html5
-rw-r--r--dw/fltkflatview.cc5
-rw-r--r--dw/fltkflatview.hh1
-rw-r--r--dw/fltkpreview.cc5
-rw-r--r--dw/fltkpreview.hh1
-rw-r--r--dw/fltkviewport.cc65
-rw-r--r--dw/fltkviewport.hh3
-rw-r--r--dw/layout.cc2
-rw-r--r--dw/view.hh2
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h1
-rw-r--r--src/prefsparser.cc1
-rw-r--r--src/uicmd.cc1
15 files changed, 85 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index eae4c851..b6f9be06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@ dillo-3.2.0 [Not released yet]
Patches: Rodrigo Arias Mallo
+- Add primitive support for SVG using the nanosvg.h library.
- Add support for ch, rem, vw, vh, vmin and vmax CSS units.
+ - Allow placing the scrollbar on the left side.
Patches: dogma, Rodrigo Arias Mallo
+- Avoid expensive search for multipart/form-data boundaries.
Patches: Xavier Del Campo Romero, Rodrigo Arias Mallo
diff --git a/dillorc b/dillorc
index 4345eaba..99aa1e65 100644
--- a/dillorc
+++ b/dillorc
@@ -46,6 +46,9 @@
# height of the visible page area.
#scroll_step=100
+# Place the vertical scrollbar on the left side (default right).
+#scrollbar_on_left=NO
+
#-------------------------------------------------------------------------
# RENDERING SECTION
#-------------------------------------------------------------------------
diff --git a/doc/user_help.in.html b/doc/user_help.in.html
index 15113d29..a35bb63b 100644
--- a/doc/user_help.in.html
+++ b/doc/user_help.in.html
@@ -208,7 +208,10 @@ doesn't require a network connection.
<p>You can control the <b>size of a <em>step</em></b> by setting the
<code>scroll_step</code> option in the <a href="#dillorc">dillorc</a>
-configuration file. By default it will scroll 100 pixels per step.</p>
+configuration file. By default it will scroll 100 pixels per step. The vertical
+scrollbar can be positioned on the left side setting the
+<code>scrollbar_on_left</code> option to <code>YES</code>, by default it is on
+the right side.</p>
<h3 id="find-text">Find text</h3>
<p>
diff --git a/dw/fltkflatview.cc b/dw/fltkflatview.cc
index d40c59e5..b9223a4a 100644
--- a/dw/fltkflatview.cc
+++ b/dw/fltkflatview.cc
@@ -70,6 +70,11 @@ int FltkFlatView::getVScrollbarThickness ()
return 0;
}
+int FltkFlatView::getScrollbarOnLeft ()
+{
+ return 0;
+}
+
void FltkFlatView::scrollTo (int x, int y)
{
}
diff --git a/dw/fltkflatview.hh b/dw/fltkflatview.hh
index 8d84fda9..6016dac6 100644
--- a/dw/fltkflatview.hh
+++ b/dw/fltkflatview.hh
@@ -25,6 +25,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft ();
void scrollTo (int x, int y);
void setViewportSize (int width, int height,
int hScrollbarThickness, int vScrollbarThickness);
diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc
index ecb96f22..8a2a3587 100644
--- a/dw/fltkpreview.cc
+++ b/dw/fltkpreview.cc
@@ -95,6 +95,11 @@ int FltkPreview::getVScrollbarThickness ()
return 0;
}
+int FltkPreview::getScrollbarOnLeft ()
+{
+ return 0;
+}
+
void FltkPreview::scrollTo (int x, int y)
{
scrollX = x;
diff --git a/dw/fltkpreview.hh b/dw/fltkpreview.hh
index 2382b861..a92063fe 100644
--- a/dw/fltkpreview.hh
+++ b/dw/fltkpreview.hh
@@ -33,6 +33,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft ();
void scrollTo (int x, int y);
void scroll (dw::core::ScrollCommand cmd);
void setViewportSize (int width, int height,
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc
index 6d2c5ecd..28c4101c 100644
--- a/dw/fltkviewport.cc
+++ b/dw/fltkviewport.cc
@@ -116,10 +116,17 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation ()
vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
}
- hscrollbar->resize(x (), y () + h () - SCROLLBAR_THICKNESS,
- w () - hdiff, SCROLLBAR_THICKNESS);
- vscrollbar->resize(x () + w () - SCROLLBAR_THICKNESS, y (),
- SCROLLBAR_THICKNESS, h () - vdiff);
+ if (scrollbarOnLeft) {
+ hscrollbar->resize(x () + hdiff, y () + h () - SCROLLBAR_THICKNESS,
+ w () - hdiff, SCROLLBAR_THICKNESS);
+ vscrollbar->resize(x (), y (),
+ SCROLLBAR_THICKNESS, h () - vdiff);
+ } else {
+ hscrollbar->resize(x (), y () + h () - SCROLLBAR_THICKNESS,
+ w () - hdiff, SCROLLBAR_THICKNESS);
+ vscrollbar->resize(x () + w () - SCROLLBAR_THICKNESS, y (),
+ SCROLLBAR_THICKNESS, h () - vdiff);
+ }
//int X = x () + w () - SCROLLBAR_THICKNESS;
//int Y = y () + h () - SCROLLBAR_THICKNESS;
@@ -141,6 +148,8 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation ()
}
#endif
}
+
+ adjustScrollbarValues();
}
void FltkViewport::adjustScrollbarValues ()
@@ -222,17 +231,29 @@ void FltkViewport::draw ()
draw_child (*hscrollbar);
if (draw && vis_vs && vis_hs) {
fl_color(FL_BACKGROUND_COLOR);
- fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
+ if (scrollbarOnLeft) {
+ fl_rectf(x(), y()+h()-vis_hs, vis_vs, vis_hs);
+ } else {
+ fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
+ }
}
// main area
if (d == FL_DAMAGE_CHILD && (draw_vs || draw_hs)) {
_MSG("none\n");
} else if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) {
- fl_scroll(x(), y(), w() - vis_vs, h() - vis_hs,
+ int x = this->x();
+
+ if (scrollbarOnLeft)
+ x += vis_vs;
+ fl_scroll(x, y(), w() - vis_vs, h() - vis_hs,
-scrollDX, -scrollDY, draw_area, this);
_MSG("fl_scroll()\n");
} else {
- draw_area(this, x(), y(), w() - vis_vs, h() - vis_hs);
+ int x = this->x();
+
+ if (scrollbarOnLeft)
+ x += vis_vs;
+ draw_area(this, x, y(), w() - vis_vs, h() - vis_hs);
_MSG("draw_area()\n");
}
@@ -331,12 +352,27 @@ int FltkViewport::handle (int event)
break;
case FL_ENTER:
+ if (vscrollbar->visible() && Fl::event_inside(vscrollbar))
+ return vscrollbar->handle(event);
+ if (hscrollbar->visible() && Fl::event_inside(hscrollbar))
+ return hscrollbar->handle(event);
/* could be the result of, e.g., closing another window. */
mouse_x = Fl::event_x();
mouse_y = Fl::event_y();
positionChanged();
break;
+ case FL_MOVE:
+ /* Use LEAVE in order not to be over a link, etc., anymore. */
+ if (vscrollbar->visible() && Fl::event_inside(vscrollbar)) {
+ (void)FltkWidgetView::handle(FL_LEAVE);
+ return vscrollbar->handle(event);
+ }
+ if (hscrollbar->visible() && Fl::event_inside(hscrollbar)) {
+ (void)FltkWidgetView::handle(FL_LEAVE);
+ return hscrollbar->handle(event);
+ }
+ break;
case FL_LEAVE:
mouse_x = mouse_y = -1;
break;
@@ -438,13 +474,13 @@ void FltkViewport::scroll (core::ScrollCommand cmd)
} else if (cmd == core::SCREEN_RIGHT_CMD) {
scroll (w() - hscrollbar->linesize (), 0);
} else if (cmd == core::LINE_UP_CMD) {
- scroll (0, (int) -vscrollbar->linesize ());
+ scroll (0, -vscrollbar->linesize ());
} else if (cmd == core::LINE_DOWN_CMD) {
- scroll (0, (int) vscrollbar->linesize ());
+ scroll (0, vscrollbar->linesize ());
} else if (cmd == core::LEFT_CMD) {
- scroll ((int) -hscrollbar->linesize (), 0);
+ scroll (-hscrollbar->linesize (), 0);
} else if (cmd == core::RIGHT_CMD) {
- scroll ((int) hscrollbar->linesize (), 0);
+ scroll (hscrollbar->linesize (), 0);
} else if (cmd == core::TOP_CMD) {
scrollTo (scrollX, 0);
} else if (cmd == core::BOTTOM_CMD) {
@@ -478,6 +514,13 @@ void FltkViewport::selectionScroll (void *data)
Fl::repeat_timeout(0.025, selectionScroll, data);
}
+void FltkViewport::setScrollbarOnLeft (bool enable)
+{
+ scrollbarOnLeft = enable ? 1 : 0;
+ adjustScrollbarsAndGadgetsAllocation();
+ damage(FL_DAMAGE_ALL);
+}
+
void FltkViewport::setViewportSize (int width, int height,
int hScrollbarThickness,
int vScrollbarThickness)
diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh
index 1569a7d8..fdcbb3be 100644
--- a/dw/fltkviewport.hh
+++ b/dw/fltkviewport.hh
@@ -21,6 +21,7 @@ private:
int scrollX, scrollY;
int scrollDX, scrollDY;
+ int scrollbarOnLeft;
int hasDragScroll, dragScrolling, dragX, dragY;
int horScrolling, verScrolling;
@@ -64,6 +65,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft () {return scrollbarOnLeft; };
void scroll(int dx, int dy);
void scroll(dw::core::ScrollCommand cmd);
void scrollTo (int x, int y);
@@ -75,6 +77,7 @@ public:
GadgetOrientation gadgetOrientation);
void setDragScroll (bool enable) { hasDragScroll = enable ? 1 : 0; }
void addGadget (Fl_Widget *gadget);
+ void setScrollbarOnLeft (bool enable);
};
} // namespace fltk
diff --git a/dw/layout.cc b/dw/layout.cc
index ee54e892..4a5be74e 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -943,6 +943,8 @@ void Layout::resizeIdle ()
assert (topLevel->needsAllocate ());
allocation.x = allocation.y = 0;
+ if (usesViewport && view->getScrollbarOnLeft())
+ allocation.x += currVScrollbarThickness();
allocation.width = requisition.width;
allocation.ascent = requisition.ascent;
allocation.descent = requisition.descent;
diff --git a/dw/view.hh b/dw/view.hh
index 234cc9fb..995c2d9c 100644
--- a/dw/view.hh
+++ b/dw/view.hh
@@ -72,6 +72,8 @@ public:
*/
virtual int getVScrollbarThickness () = 0;
+ virtual int getScrollbarOnLeft () = 0;
+
/**
* \brief Scroll the vieport to the given position.
*
diff --git a/src/prefs.c b/src/prefs.c
index 6d265adc..29b4f349 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -91,6 +91,7 @@ void a_Prefs_init(void)
prefs.search_urls = dList_new(16);
dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL));
prefs.search_url_idx = 0;
+ prefs.scrollbar_on_left = FALSE;
prefs.show_back = TRUE;
prefs.show_bookmarks = TRUE;
prefs.show_clear_url = TRUE;
diff --git a/src/prefs.h b/src/prefs.h
index ce957327..f51d0a4c 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -77,6 +77,7 @@ typedef struct {
int32_t font_max_size;
int32_t font_min_size;
int32_t scroll_step;
+ bool_t scrollbar_on_left;
bool_t show_back;
bool_t show_forw;
bool_t show_home;
diff --git a/src/prefsparser.cc b/src/prefsparser.cc
index 70cb7e68..3669b8d4 100644
--- a/src/prefsparser.cc
+++ b/src/prefsparser.cc
@@ -200,6 +200,7 @@ void PrefsParser::parse(FILE *fp)
{ "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL, 0 },
{ "save_dir", &prefs.save_dir, PREFS_STRING, 0 },
{ "scroll_step", &prefs.scroll_step, PREFS_INT32, 0 },
+ { "scrollbar_on_left", &prefs.scrollbar_on_left, PREFS_BOOL, 0 },
{ "search_url", &prefs.search_urls, PREFS_STRINGS, 0 },
{ "show_back", &prefs.show_back, PREFS_BOOL, 0 },
{ "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL, 0 },
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 187aeabc..07593892 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -628,6 +628,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus)
viewport->box(FL_NO_BOX);
viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false);
viewport->setDragScroll (prefs.middle_click_drags_page ? true : false);
+ viewport->setScrollbarOnLeft (prefs.scrollbar_on_left ? true : false);
layout->attachView (viewport);
new_ui->set_render_layout(viewport);
viewport->setScrollStep(prefs.scroll_step);