summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2017-09-11 17:27:10 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2017-09-18 22:18:44 (GMT)
commitdb6b3441c412cdc2e6eb197f9601056c2c85dcf8 (patch)
tree8b307c2e8dff9fc00669736b1451f7c9864d271e
parent0a6e8fc0b072da21c7ec9c8d602b7ffad6bd4100 (diff)
downloadnetsurf-db6b3441c412cdc2e6eb197f9601056c2c85dcf8.tar.gz
netsurf-db6b3441c412cdc2e6eb197f9601056c2c85dcf8.tar.bz2
Treeview: Scroll to top when treeview search bar is modified.
-rw-r--r--desktop/treeview.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 85bc61d..3bbc839 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -364,6 +364,27 @@ static inline void treeview__cw_update_size(
/**
+ * Corewindow callback_wrapper: Scroll to top of window.
+ *
+ * \param[in] tree The treeview to scroll.
+ */
+static inline void treeview__cw_scroll_top(
+ const struct treeview *tree)
+{
+ struct rect r = {
+ .x0 = 0,
+ .y0 = 0,
+ .x1 = tree_g.window_padding,
+ .y1 = tree_g.line_height,
+ };
+
+ if (tree->cw_t != NULL) {
+ tree->cw_t->scroll_visible(tree->cw_h, &r);
+ }
+}
+
+
+/**
* Corewindow callback wrapper: Get window viewport dimensions
*
* \param[in] tree The treeview to get dimensions for.
@@ -1609,7 +1630,6 @@ static nserror treeview__search_walk_cb(
(struct treeview_node_entry *)n;
bool matched = false;
-
for (int i = 0; i < sw->tree->n_fields; i++) {
struct treeview_field *ef = &(sw->tree->fields[i + 1]);
if (ef->flags & TREE_FLAG_SEARCHABLE) {
@@ -1676,6 +1696,7 @@ static nserror treeview__search(
}
treeview__cw_update_size(tree, -1, height);
+ treeview__cw_scroll_top(tree);
return NSERROR_OK;
}