Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/42459f72c1f0e3dcdc1686447f1522c4fe9e3134
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/42459f72c1f0e3dcdc1686447f1522c4fe9e3134
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/42459f72c1f0e3dcdc1686447f1522c4fe9e3134

The branch, master has been updated
       via  42459f72c1f0e3dcdc1686447f1522c4fe9e3134 (commit)
       via  341cfc115b6a022ef9d3d9e8f909bdd4539f0f93 (commit)
      from  57a6328b141f1f46099ee3c9379b43205c8771d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=42459f72c1f0e3dcdc1686447f1522c4fe9e3134
commit 42459f72c1f0e3dcdc1686447f1522c4fe9e3134
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Treeview: Allow dragging selection to a selected target.
    
    This can be used to consolidate a scattered selection at
    drop target when the the drop target happens to be part
    of the selection.

diff --git a/desktop/treeview.c b/desktop/treeview.c
index c44845e..48422e8 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -3030,6 +3030,7 @@ struct treeview_selection_walk_data {
                } drag;
                struct {
                        treeview_node *prev;
+                       treeview_node *fixed;
                } yank;
                struct {
                        treeview_node *n;
@@ -3132,6 +3133,10 @@ treeview_node_selection_walk_cb(treeview_node *n,
                        treeview_node *p = n->parent;
                        int h = 0;
 
+                       if (n == sw->data.yank.fixed) {
+                               break;
+                       }
+
                        if (treeview_unlink_node(n))
                                h = n->height;
 
@@ -3361,13 +3366,15 @@ static void treeview_commit_selection_drag(treeview 
*tree)
 /**
  * Yank a selection to the node move list.
  *
- * \param tree Treeview object to yank selection from
+ * \param tree   Treeview object to yank selection from
+ * \param fixed  Treeview node that should not be yanked
  */
-static void treeview_move_yank_selection(treeview *tree)
+static void treeview_move_yank_selection(treeview *tree, treeview_node *fixed)
 {
        struct treeview_selection_walk_data sw;
 
        sw.purpose = TREEVIEW_WALK_YANK_SELECTION;
+       sw.data.yank.fixed = fixed;
        sw.data.yank.prev = NULL;
        sw.tree = tree;
 
@@ -3541,16 +3548,17 @@ static nserror treeview_move_selection(treeview *tree, 
struct rect *rect)
                parent = relation->parent;
        }
 
-       /* The node that we're moving selection to can't itself be selected */
-       assert(!(relation->flags & TV_NFLAGS_SELECTED));
-
        /* Move all selected nodes from treeview to tree->move.root */
-       treeview_move_yank_selection(tree);
+       treeview_move_yank_selection(tree, relation);
 
        /* Move all nodes on tree->move.root to target location */
        for (node = tree->move.root; node != NULL; node = next) {
                next = node->next_sib;
 
+               if (node == relation) {
+                       continue;
+               }
+
                if (!(parent->flags & TV_NFLAGS_EXPANDED)) {
                        if (node->flags & TV_NFLAGS_EXPANDED)
                                treeview_node_contract_internal(tree, node);


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=341cfc115b6a022ef9d3d9e8f909bdd4539f0f93
commit 341cfc115b6a022ef9d3d9e8f909bdd4539f0f93
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Treeview: Various changes to redraw rectangle for search bar.

diff --git a/desktop/treeview.c b/desktop/treeview.c
index 928a696..c44845e 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -333,7 +333,7 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] 
= {
  * \param[in] tree  Treeview to get the height of.
  * \return the display height in pixels.
  */
-static inline int treeview__get_display_height(treeview *tree)
+static inline int treeview__get_display_height(const treeview *tree)
 {
        return (tree->search.search == false) ?
                        tree->root->height :
@@ -501,9 +501,8 @@ static inline treeview_node * 
treeview_node_next(treeview_node *node, bool full)
  */
 static treeview_node * treeview_y_node(treeview *tree, int target_y)
 {
+       int y = (tree->flags & TREEVIEW_SEARCHABLE) ? tree_g.line_height : 0;
        treeview_node *n;
-       int y = 0;
-       int h;
 
        assert(tree != NULL);
        assert(tree->root != NULL);
@@ -511,7 +510,7 @@ static treeview_node * treeview_y_node(treeview *tree, int 
target_y)
        n = treeview_node_next(tree->root, false);
 
        while (n != NULL) {
-               h = (n->type == TREE_NODE_ENTRY) ?
+               int h = (n->type == TREE_NODE_ENTRY) ?
                        n->height : tree_g.line_height;
                if (target_y >= y && target_y < y + h)
                        return n;
@@ -531,10 +530,12 @@ static treeview_node * treeview_y_node(treeview *tree, 
int target_y)
  * \param node Node to get position of
  * \return node's y position
  */
-static int treeview_node_y(treeview *tree, treeview_node *node)
+static int treeview_node_y(
+               const treeview *tree,
+               const treeview_node *node)
 {
        treeview_node *n;
-       int y = 0;
+       int y = (tree->flags & TREEVIEW_SEARCHABLE) ? tree_g.line_height : 0;
 
        assert(tree != NULL);
        assert(tree->root != NULL);
@@ -553,6 +554,31 @@ static int treeview_node_y(treeview *tree, treeview_node 
*node)
 
 
 /**
+ * Redraw tree from given node to the bottom.
+ *
+ * \param[in] tree  Tree to redraw from node in.
+ * \param[in] node  Node to redraw from.
+ */
+static void treeview__redraw_from_node(
+               const treeview *tree,
+               const treeview_node *node)
+{
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
+       struct rect r = {
+               .x0 = 0,
+               .y0 = treeview_node_y(tree, node),
+               .x1 = REDRAW_MAX,
+               .y1 = treeview__get_display_height(tree) + search_height,
+       };
+
+       assert(tree != NULL);
+
+       treeview__cw_invalidate_area(tree, &r);
+}
+
+
+/**
  * The treeview walk mode.  Controls which nodes are visited in a walk.
  */
 enum treeview_walk_mode {
@@ -2175,17 +2201,13 @@ treeview_node_expand_internal(treeview *tree, 
treeview_node *node)
 nserror treeview_node_expand(treeview *tree, treeview_node *node)
 {
        nserror res;
-       struct rect r;
 
        res = treeview_node_expand_internal(tree, node);
+       NSLOG(netsurf, INFO, "Expanding!");
        if (res == NSERROR_OK) {
                /* expansion was successful, attempt redraw */
-               r.x0 = 0;
-               r.y0 = treeview_node_y(tree, node);
-               r.x1 = REDRAW_MAX;
-               r.y1 = treeview__get_display_height(tree);
-
-               treeview__cw_invalidate_area(tree, &r);
+               treeview__redraw_from_node(tree, node);
+               NSLOG(netsurf, INFO, "Expanded!");
        }
 
        return res;
@@ -2289,19 +2311,15 @@ treeview_node_contract_internal(treeview *tree, 
treeview_node *node)
 nserror treeview_node_contract(treeview *tree, treeview_node *node)
 {
        nserror res;
-       struct rect r;
 
        assert(tree != NULL);
 
        res = treeview_node_contract_internal(tree, node);
+       NSLOG(netsurf, INFO, "Contracting!");
        if (res == NSERROR_OK) {
                /* successful contraction, request redraw */
-               r.x0 = 0;
-               r.y0 = treeview_node_y(tree, node);
-               r.x1 = REDRAW_MAX;
-               r.y1 = tree->root->height;
-
-               treeview__cw_invalidate_area(tree, &r);
+               treeview__redraw_from_node(tree, node);
+               NSLOG(netsurf, INFO, "Contracted!");
        }
 
        return res;
@@ -2311,6 +2329,8 @@ nserror treeview_node_contract(treeview *tree, 
treeview_node *node)
 /* Exported interface, documented in treeview.h */
 nserror treeview_contract(treeview *tree, bool all)
 {
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
        struct treeview_contract_data data;
        bool selected;
        treeview_node *n;
@@ -2322,7 +2342,7 @@ nserror treeview_contract(treeview *tree, bool all)
        r.x0 = 0;
        r.y0 = 0;
        r.x1 = REDRAW_MAX;
-       r.y1 = tree->root->height;
+       r.y1 = tree->root->height + search_height;
 
        data.tree = tree;
        data.only_entries = !all;
@@ -3769,7 +3789,9 @@ treeview_keyboard_navigation(treeview *tree, uint32_t 
key, struct rect *rect)
                .n_selected = 0,
                .prev_n_selected = 0
        };
-       int h = tree->root->height;
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
+       int h = treeview__get_display_height(tree) + search_height;
        bool redraw = false;
 
        /* Fill out the nav. state struct, by examining the current selection
@@ -3853,8 +3875,8 @@ treeview_keyboard_navigation(treeview *tree, uint32_t 
key, struct rect *rect)
        rect->x0 = 0;
        rect->y0 = 0;
        rect->x1 = REDRAW_MAX;
-       if (tree->root->height > h)
-               rect->y1 = tree->root->height;
+       if (treeview__get_display_height(tree) + search_height > h)
+               rect->y1 = treeview__get_display_height(tree) + search_height;
        else
                rect->y1 = h;
        redraw = true;
@@ -4290,6 +4312,7 @@ struct treeview_mouse_action {
        int x;
        int y;
        int current_y;  /* Y coordinate value of top of current node */
+       int search_height;
 };
 
 
@@ -4477,7 +4500,8 @@ treeview_node_mouse_action_cb(treeview_node *node,
        if (((node->type == TREE_NODE_FOLDER) &&
             (ma->mouse & BROWSER_MOUSE_DOUBLE_CLICK) && click) ||
            (part == TV_NODE_PART_TOGGLE && click)) {
-               int h = ma->tree->root->height;
+               int h = treeview__get_display_height(ma->tree) +
+                               ma->search_height;
 
                /* Clear any existing selection */
                redraw |= treeview_clear_selection(ma->tree, &r);
@@ -4495,7 +4519,13 @@ treeview_node_mouse_action_cb(treeview_node *node,
                /* Set up redraw */
                if (!redraw || r.y0 > ma->current_y)
                        r.y0 = ma->current_y;
-               r.y1 = h > ma->tree->root->height ? h : ma->tree->root->height;
+               if (h > treeview__get_display_height(ma->tree) +
+                               ma->search_height) {
+                       r.y1 = h;
+               } else {
+                       r.y1 = treeview__get_display_height(ma->tree) +
+                               ma->search_height;
+               }
                redraw = true;
 
        } else if ((node->type == TREE_NODE_ENTRY) &&
@@ -4734,13 +4764,14 @@ treeview_mouse_action(treeview *tree, 
browser_mouse_state mouse, int x, int y)
 
        } else {
                /* On tree */
-               struct treeview_mouse_action ma;
-
-               ma.tree = tree;
-               ma.mouse = mouse;
-               ma.x = x;
-               ma.y = y;
-               ma.current_y = search_height;
+               struct treeview_mouse_action ma = {
+                       ma.tree = tree,
+                       ma.mouse = mouse,
+                       ma.x = x,
+                       ma.y = y,
+                       ma.current_y = search_height,
+                       ma.search_height = search_height,
+               };
 
                treeview_walk_internal(tree, tree->root,
                                TREEVIEW_WALK_MODE_DISPLAY, NULL,


-----------------------------------------------------------------------

Summary of changes:
 desktop/treeview.c |  117 ++++++++++++++++++++++++++++++++++------------------
 1 file changed, 78 insertions(+), 39 deletions(-)

diff --git a/desktop/treeview.c b/desktop/treeview.c
index 928a696..48422e8 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -333,7 +333,7 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] 
= {
  * \param[in] tree  Treeview to get the height of.
  * \return the display height in pixels.
  */
-static inline int treeview__get_display_height(treeview *tree)
+static inline int treeview__get_display_height(const treeview *tree)
 {
        return (tree->search.search == false) ?
                        tree->root->height :
@@ -501,9 +501,8 @@ static inline treeview_node * 
treeview_node_next(treeview_node *node, bool full)
  */
 static treeview_node * treeview_y_node(treeview *tree, int target_y)
 {
+       int y = (tree->flags & TREEVIEW_SEARCHABLE) ? tree_g.line_height : 0;
        treeview_node *n;
-       int y = 0;
-       int h;
 
        assert(tree != NULL);
        assert(tree->root != NULL);
@@ -511,7 +510,7 @@ static treeview_node * treeview_y_node(treeview *tree, int 
target_y)
        n = treeview_node_next(tree->root, false);
 
        while (n != NULL) {
-               h = (n->type == TREE_NODE_ENTRY) ?
+               int h = (n->type == TREE_NODE_ENTRY) ?
                        n->height : tree_g.line_height;
                if (target_y >= y && target_y < y + h)
                        return n;
@@ -531,10 +530,12 @@ static treeview_node * treeview_y_node(treeview *tree, 
int target_y)
  * \param node Node to get position of
  * \return node's y position
  */
-static int treeview_node_y(treeview *tree, treeview_node *node)
+static int treeview_node_y(
+               const treeview *tree,
+               const treeview_node *node)
 {
        treeview_node *n;
-       int y = 0;
+       int y = (tree->flags & TREEVIEW_SEARCHABLE) ? tree_g.line_height : 0;
 
        assert(tree != NULL);
        assert(tree->root != NULL);
@@ -553,6 +554,31 @@ static int treeview_node_y(treeview *tree, treeview_node 
*node)
 
 
 /**
+ * Redraw tree from given node to the bottom.
+ *
+ * \param[in] tree  Tree to redraw from node in.
+ * \param[in] node  Node to redraw from.
+ */
+static void treeview__redraw_from_node(
+               const treeview *tree,
+               const treeview_node *node)
+{
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
+       struct rect r = {
+               .x0 = 0,
+               .y0 = treeview_node_y(tree, node),
+               .x1 = REDRAW_MAX,
+               .y1 = treeview__get_display_height(tree) + search_height,
+       };
+
+       assert(tree != NULL);
+
+       treeview__cw_invalidate_area(tree, &r);
+}
+
+
+/**
  * The treeview walk mode.  Controls which nodes are visited in a walk.
  */
 enum treeview_walk_mode {
@@ -2175,17 +2201,13 @@ treeview_node_expand_internal(treeview *tree, 
treeview_node *node)
 nserror treeview_node_expand(treeview *tree, treeview_node *node)
 {
        nserror res;
-       struct rect r;
 
        res = treeview_node_expand_internal(tree, node);
+       NSLOG(netsurf, INFO, "Expanding!");
        if (res == NSERROR_OK) {
                /* expansion was successful, attempt redraw */
-               r.x0 = 0;
-               r.y0 = treeview_node_y(tree, node);
-               r.x1 = REDRAW_MAX;
-               r.y1 = treeview__get_display_height(tree);
-
-               treeview__cw_invalidate_area(tree, &r);
+               treeview__redraw_from_node(tree, node);
+               NSLOG(netsurf, INFO, "Expanded!");
        }
 
        return res;
@@ -2289,19 +2311,15 @@ treeview_node_contract_internal(treeview *tree, 
treeview_node *node)
 nserror treeview_node_contract(treeview *tree, treeview_node *node)
 {
        nserror res;
-       struct rect r;
 
        assert(tree != NULL);
 
        res = treeview_node_contract_internal(tree, node);
+       NSLOG(netsurf, INFO, "Contracting!");
        if (res == NSERROR_OK) {
                /* successful contraction, request redraw */
-               r.x0 = 0;
-               r.y0 = treeview_node_y(tree, node);
-               r.x1 = REDRAW_MAX;
-               r.y1 = tree->root->height;
-
-               treeview__cw_invalidate_area(tree, &r);
+               treeview__redraw_from_node(tree, node);
+               NSLOG(netsurf, INFO, "Contracted!");
        }
 
        return res;
@@ -2311,6 +2329,8 @@ nserror treeview_node_contract(treeview *tree, 
treeview_node *node)
 /* Exported interface, documented in treeview.h */
 nserror treeview_contract(treeview *tree, bool all)
 {
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
        struct treeview_contract_data data;
        bool selected;
        treeview_node *n;
@@ -2322,7 +2342,7 @@ nserror treeview_contract(treeview *tree, bool all)
        r.x0 = 0;
        r.y0 = 0;
        r.x1 = REDRAW_MAX;
-       r.y1 = tree->root->height;
+       r.y1 = tree->root->height + search_height;
 
        data.tree = tree;
        data.only_entries = !all;
@@ -3010,6 +3030,7 @@ struct treeview_selection_walk_data {
                } drag;
                struct {
                        treeview_node *prev;
+                       treeview_node *fixed;
                } yank;
                struct {
                        treeview_node *n;
@@ -3112,6 +3133,10 @@ treeview_node_selection_walk_cb(treeview_node *n,
                        treeview_node *p = n->parent;
                        int h = 0;
 
+                       if (n == sw->data.yank.fixed) {
+                               break;
+                       }
+
                        if (treeview_unlink_node(n))
                                h = n->height;
 
@@ -3341,13 +3366,15 @@ static void treeview_commit_selection_drag(treeview 
*tree)
 /**
  * Yank a selection to the node move list.
  *
- * \param tree Treeview object to yank selection from
+ * \param tree   Treeview object to yank selection from
+ * \param fixed  Treeview node that should not be yanked
  */
-static void treeview_move_yank_selection(treeview *tree)
+static void treeview_move_yank_selection(treeview *tree, treeview_node *fixed)
 {
        struct treeview_selection_walk_data sw;
 
        sw.purpose = TREEVIEW_WALK_YANK_SELECTION;
+       sw.data.yank.fixed = fixed;
        sw.data.yank.prev = NULL;
        sw.tree = tree;
 
@@ -3521,16 +3548,17 @@ static nserror treeview_move_selection(treeview *tree, 
struct rect *rect)
                parent = relation->parent;
        }
 
-       /* The node that we're moving selection to can't itself be selected */
-       assert(!(relation->flags & TV_NFLAGS_SELECTED));
-
        /* Move all selected nodes from treeview to tree->move.root */
-       treeview_move_yank_selection(tree);
+       treeview_move_yank_selection(tree, relation);
 
        /* Move all nodes on tree->move.root to target location */
        for (node = tree->move.root; node != NULL; node = next) {
                next = node->next_sib;
 
+               if (node == relation) {
+                       continue;
+               }
+
                if (!(parent->flags & TV_NFLAGS_EXPANDED)) {
                        if (node->flags & TV_NFLAGS_EXPANDED)
                                treeview_node_contract_internal(tree, node);
@@ -3769,7 +3797,9 @@ treeview_keyboard_navigation(treeview *tree, uint32_t 
key, struct rect *rect)
                .n_selected = 0,
                .prev_n_selected = 0
        };
-       int h = tree->root->height;
+       int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ?
+                       tree_g.line_height : 0;
+       int h = treeview__get_display_height(tree) + search_height;
        bool redraw = false;
 
        /* Fill out the nav. state struct, by examining the current selection
@@ -3853,8 +3883,8 @@ treeview_keyboard_navigation(treeview *tree, uint32_t 
key, struct rect *rect)
        rect->x0 = 0;
        rect->y0 = 0;
        rect->x1 = REDRAW_MAX;
-       if (tree->root->height > h)
-               rect->y1 = tree->root->height;
+       if (treeview__get_display_height(tree) + search_height > h)
+               rect->y1 = treeview__get_display_height(tree) + search_height;
        else
                rect->y1 = h;
        redraw = true;
@@ -4290,6 +4320,7 @@ struct treeview_mouse_action {
        int x;
        int y;
        int current_y;  /* Y coordinate value of top of current node */
+       int search_height;
 };
 
 
@@ -4477,7 +4508,8 @@ treeview_node_mouse_action_cb(treeview_node *node,
        if (((node->type == TREE_NODE_FOLDER) &&
             (ma->mouse & BROWSER_MOUSE_DOUBLE_CLICK) && click) ||
            (part == TV_NODE_PART_TOGGLE && click)) {
-               int h = ma->tree->root->height;
+               int h = treeview__get_display_height(ma->tree) +
+                               ma->search_height;
 
                /* Clear any existing selection */
                redraw |= treeview_clear_selection(ma->tree, &r);
@@ -4495,7 +4527,13 @@ treeview_node_mouse_action_cb(treeview_node *node,
                /* Set up redraw */
                if (!redraw || r.y0 > ma->current_y)
                        r.y0 = ma->current_y;
-               r.y1 = h > ma->tree->root->height ? h : ma->tree->root->height;
+               if (h > treeview__get_display_height(ma->tree) +
+                               ma->search_height) {
+                       r.y1 = h;
+               } else {
+                       r.y1 = treeview__get_display_height(ma->tree) +
+                               ma->search_height;
+               }
                redraw = true;
 
        } else if ((node->type == TREE_NODE_ENTRY) &&
@@ -4734,13 +4772,14 @@ treeview_mouse_action(treeview *tree, 
browser_mouse_state mouse, int x, int y)
 
        } else {
                /* On tree */
-               struct treeview_mouse_action ma;
-
-               ma.tree = tree;
-               ma.mouse = mouse;
-               ma.x = x;
-               ma.y = y;
-               ma.current_y = search_height;
+               struct treeview_mouse_action ma = {
+                       ma.tree = tree,
+                       ma.mouse = mouse,
+                       ma.x = x,
+                       ma.y = y,
+                       ma.current_y = search_height,
+                       ma.search_height = search_height,
+               };
 
                treeview_walk_internal(tree, tree->root,
                                TREEVIEW_WALK_MODE_DISPLAY, NULL,


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to