summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2017-09-14 19:07:42 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2017-09-18 22:18:44 (GMT)
commitf142b3684cd98ace5271c0a72600761585cdfa58 (patch)
treedf547244825638a438bbbfbe53c9d16498226ec9
parent45a7e6269b2328de9178af76ff4aed41c2e69129 (diff)
downloadnetsurf-f142b3684cd98ace5271c0a72600761585cdfa58.tar.gz
netsurf-f142b3684cd98ace5271c0a72600761585cdfa58.tar.bz2
Treeview: Track height of display in search view.
-rw-r--r--desktop/treeview.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/desktop/treeview.c b/desktop/treeview.c
index a6e3e60..029fd9d 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -218,6 +218,7 @@ struct treeview_search {
struct textarea *textarea; /**< Search box. */
bool active; /**< Whether the search box has focus. */
bool search; /**< Whether we have a search term. */
+ int height; /**< Current search display height. */
};
@@ -327,6 +328,20 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = {
/**
+ * Get the display height of the treeview data component of the display.
+ *
+ * \param[in] tree Treeview to get the height of.
+ * \return the display height in pixels.
+ */
+static inline int treeview__get_display_height(treeview *tree)
+{
+ return (tree->search.search == false) ?
+ tree->root->height :
+ tree->search.height;
+}
+
+
+/**
* Corewindow callback wrapper: Request a redraw of the window
*
* \param[in] tree The treeview to request redraw on.
@@ -1645,7 +1660,7 @@ static nserror treeview__search_walk_cb(
if (matched) {
n->flags |= TV_NFLAGS_MATCHED;
- sw->window_height += tree_g.line_height;
+ sw->window_height += n->height;
} else {
n->flags &= ~TV_NFLAGS_MATCHED;
}
@@ -1670,12 +1685,20 @@ static nserror treeview__search(
{
nserror err;
uint32_t height;
+ uint32_t prev_height = treeview__get_display_height(tree);
+ int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+ tree_g.line_height : 0;
struct treeview_search_walk_data sw = {
.len = len,
.text = text,
.tree = tree,
.window_height = 0,
};
+ struct rect r = {
+ .x0 = 0,
+ .y0 = search_height,
+ .x1 = REDRAW_MAX,
+ };
assert(text[len] == '\0');
@@ -1686,6 +1709,7 @@ static nserror treeview__search(
}
if (len > 0) {
+ tree->search.height = sw.window_height;
tree->search.search = true;
height = sw.window_height;
} else {
@@ -1693,7 +1717,9 @@ static nserror treeview__search(
height = tree->root->height;
}
- treeview__cw_update_size(tree, -1, height);
+ r.y1 = ((height > prev_height) ? height : prev_height) + search_height;
+ treeview__cw_invalidate_area(tree, &r);
+ treeview__cw_update_size(tree, -1, height + search_height);
treeview__cw_scroll_top(tree);
return NSERROR_OK;
@@ -2565,7 +2591,7 @@ static void treeview_redraw_search(
count++;
inset = x + tree_g.window_padding;
- height = tree_g.line_height;
+ height = node->height;
if ((render_y + height) < r->y0) {
/* This node's line is above clip region */
@@ -4469,7 +4495,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y)
}
}
- if (y > tree->root->height + search_height) {
+ if (y > treeview__get_display_height(tree) + search_height) {
/* Below tree */
r.x0 = 0;
@@ -4560,13 +4586,14 @@ int treeview_get_height(treeview *tree)
{
int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
tree_g.line_height : 0;
+ int height = treeview__get_display_height(tree);
assert(tree != NULL);
assert(tree->root != NULL);
- treeview__cw_update_size(tree, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, height);
- return tree->root->height + search_height;
+ return height + search_height;
}