Allow getting the tree's drag property. This ensures we can see whether the current

drag is something we might need to display an icon for.

svn path=/trunk/netsurf/; revision=10917
This commit is contained in:
Chris Young 2010-10-29 17:40:36 +00:00
parent 802f58f10d
commit 25e9b79f5c
4 changed files with 37 additions and 12 deletions

View File

@ -512,7 +512,7 @@ void ami_drag_icon_show(struct Window *win, char *type)
ami_update_pointer(win, GUI_POINTER_DEFAULT);
}
if(type == "drawer") deftype = WBDRAWER;
if(!strcmp(type, "drawer")) deftype = WBDRAWER;
dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type,
ICONGETA_GetDefaultType, deftype,

View File

@ -265,6 +265,19 @@ void ami_tree_scroll(struct treeview_window *twin, int sx, int sy)
ami_tree_draw(twin);
}
void ami_tree_drag_icon_show(struct treeview_window *twin)
{
if(tree_node_is_folder(
tree_get_selected_node(
tree_get_root(twin->tree))))
{
ami_drag_icon_show(twin->win, "drawer");
}
else
{
ami_drag_icon_show(twin->win, "html");
}
}
void ami_tree_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg)
{
@ -688,8 +701,6 @@ BOOL ami_tree_event(struct treeview_window *twin)
{
int drag_x_move = 0, drag_y_move = 0;
/* TODO: Show drag icons on TREE_MOVE_DRAG start.
* Until then, the below line does nothing. */
ami_drag_icon_move();
if(twin->win->MouseX < bbox->Left)
@ -718,7 +729,8 @@ BOOL ami_tree_event(struct treeview_window *twin)
BROWSER_MOUSE_DRAG_ON;
if(twin->drag_x == 0) twin->drag_x = x;
if(twin->drag_y == 0) twin->drag_y = y;
if(tree_drag_status(twin->tree) == TREE_MOVE_DRAG)
ami_tree_drag_icon_show(twin);
}
else if(twin->mouse_state & BROWSER_MOUSE_PRESS_2)
{
@ -728,6 +740,8 @@ BOOL ami_tree_event(struct treeview_window *twin)
BROWSER_MOUSE_DRAG_ON;
if(twin->drag_x == 0) twin->drag_x = x;
if(twin->drag_y == 0) twin->drag_y = y;
if(tree_drag_status(twin->tree) == TREE_MOVE_DRAG)
ami_tree_drag_icon_show(twin);
}
else
{

View File

@ -40,13 +40,6 @@
#include "utils/utils.h"
#include "utils/url.h"
typedef enum {
TREE_NO_DRAG = 0,
TREE_SELECT_DRAG,
TREE_MOVE_DRAG
} tree_drag_type;
#define MAXIMUM_URL_LENGTH 1024
#define TREE_ICON_SIZE 16
@ -1430,6 +1423,18 @@ bool tree_is_edited(struct tree *tree)
}
/**
* Get the drag state of a tree
*
* \param tree the tree to get the state of
* \return drag type (defined in desktop/tree.h)
*/
tree_drag_type tree_drag_status(struct tree *tree)
{
return tree->drag;
}
/**
* Returns the first child of a node
*

View File

@ -63,6 +63,12 @@ struct tree;
struct node;
struct node_element;
typedef enum {
TREE_NO_DRAG = 0,
TREE_SELECT_DRAG,
TREE_MOVE_DRAG
} tree_drag_type;
typedef enum {
NODE_ELEMENT_TEXT, /**< Text only */
NODE_ELEMENT_TEXT_PLUS_ICON, /**< Text and icon */
@ -163,7 +169,7 @@ bool tree_update_element_text(struct tree *tree, struct node_element *element, c
const char *tree_node_element_get_text(struct node_element *element);
struct node *tree_get_root(struct tree *tree);
bool tree_is_edited(struct tree *tree);
tree_drag_type tree_drag_status(struct tree *tree);
/* functions for traversing the tree */
struct node *tree_node_get_child(struct node *node);