Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/views/bookmark_folder_tree_view.h

Issue 9042: Adds support for autoscrolling on drag to bookmark tree/table.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ 5 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ 6 #define CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_
7 7
8 #include "base/timer.h"
8 #include "chrome/browser/bookmarks/bookmark_drag_data.h" 9 #include "chrome/browser/bookmarks/bookmark_drag_data.h"
10 #include "chrome/browser/bookmarks/bookmark_drop_info.h"
9 #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" 11 #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h"
10 #include "chrome/views/tree_view.h" 12 #include "chrome/views/tree_view.h"
11 13
12 class BookmarkModel; 14 class BookmarkModel;
13 class BookmarkNode; 15 class BookmarkNode;
14 class OSExchangeData; 16 class OSExchangeData;
15 class Profile; 17 class Profile;
16 18
17 // BookmarkFolderTreeView is used to show the contents of a 19 // BookmarkFolderTreeView is used to show the contents of a
18 // BookmarkFolderTreeModel and provides drag and drop support. 20 // BookmarkFolderTreeModel and provides drag and drop support.
(...skipping 11 matching lines...) Expand all
30 // Returns the selected node as a BookmarkNode. This returns NULL if the 32 // Returns the selected node as a BookmarkNode. This returns NULL if the
31 // selected node is not of type BookmarkFolderTreeModel::BOOKMARK or 33 // selected node is not of type BookmarkFolderTreeModel::BOOKMARK or
32 // nothing is selected. 34 // nothing is selected.
33 BookmarkNode* GetSelectedBookmarkNode(); 35 BookmarkNode* GetSelectedBookmarkNode();
34 36
35 protected: 37 protected:
36 // Overriden to start a drag. 38 // Overriden to start a drag.
37 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); 39 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
38 40
39 private: 41 private:
42 // DropPosition identifies where the drop should occur. A DropPosition
43 // consists of the following: the parent FolderNode the drop is to occur at,
44 // whether the drop is on the parent, and the index into the parent the drop
45 // should occur at.
46 //
47 // WARNING: the index is in terms of the BookmarkFolderTreeModel, which is
48 // not the same as the BookmarkModel.
49 struct DropPosition {
50 DropPosition() : parent(NULL), index(-1), on(false) {}
51 DropPosition(FolderNode* parent, int index, bool on)
52 : parent(parent),
53 index(index),
54 on(on) {}
55
56 // Returns true if |position| equals this.
57 bool equals(const DropPosition& position) const {
58 return (position.parent == parent && position.index == index &&
59 position.on == on);
60 }
61
62 FolderNode* parent;
63 int index;
64 bool on;
65 };
66
40 // Provides information used during a drop. 67 // Provides information used during a drop.
41 struct DropInfo { 68 class DropInfo : public BookmarkDropInfo {
42 DropInfo() 69 public:
43 : drop_parent(NULL), 70 explicit DropInfo(BookmarkFolderTreeView* view)
44 only_folders(true), 71 : BookmarkDropInfo(view->GetNativeControlHWND(), 0),
45 drop_index(-1), 72 view_(view),
46 drop_operation(0), 73 only_folders_(true) {}
47 drop_on(false) {}
48 74
49 // Parent the mouse is over. 75 virtual void Scrolled();
50 FolderNode* drop_parent;
51 76
52 // Drag data. 77 // Does drag_data consists of folders only?
53 BookmarkDragData drag_data; 78 void set_only_folders(bool only_folders) { only_folders_ = only_folders; }
79 bool only_folders() const { return only_folders_; }
54 80
55 // Does drag_data consists of folders only. 81 // Position of the drop.
56 bool only_folders; 82 void set_position(const DropPosition& position) { position_ = position; }
83 const DropPosition& position() const { return position_; }
57 84
58 // If drop_on is false, this is the index to add the child. 85 private:
59 // WARNING: this index is in terms of the BookmarkFolderTreeModel, which is 86 BookmarkFolderTreeView* view_;
60 // not the same as the BookmarkModel. 87 DropPosition position_;
61 int drop_index; 88 bool only_folders_;
62 89
63 // Operation for the drop. 90 DISALLOW_COPY_AND_ASSIGN(DropInfo);
64 int drop_operation; 91 };
92 friend class DropInfo;
65 93
66 // Is the user dropping on drop_parent? If false, the mouse is positioned 94 // Updates drop info. This is invoked both from OnDragUpdated and when we
67 // such that the drop should insert the data at position drop_index in 95 // autoscroll during a drop.
68 // drop_parent. 96 int UpdateDropInfo();
69 bool drop_on;
70 };
71 97
72 // Starts a drag operation for the specified node. 98 // Starts a drag operation for the specified node.
73 void BeginDrag(BookmarkNode* node); 99 void BeginDrag(BookmarkNode* node);
74 100
75 // Calculates the drop parent. Returns NULL if not over a valid drop 101 // Calculates the drop position.
76 // location. See DropInfos documentation for a description of |drop_index| 102 DropPosition CalculateDropPosition(int y, bool only_folders);
77 // and |drop_on|.
78 FolderNode* CalculateDropParent(int y,
79 bool only_folders,
80 int* drop_index,
81 bool* drop_on);
82 103
83 // Determines the appropriate drop operation. This returns DRAG_NONE 104 // Determines the appropriate drop operation. This returns DRAG_NONE
84 // if the location is not valid. 105 // if the position is not valid.
85 int CalculateDropOperation(const views::DropTargetEvent& event, 106 int CalculateDropOperation(const DropPosition& position);
86 FolderNode* drop_parent,
87 int drop_index,
88 bool drop_on);
89 107
90 // Performs the drop operation. 108 // Performs the drop operation.
91 void OnPerformDropImpl(); 109 void OnPerformDropImpl();
92 110
93 // Sets the parent of the drop operation. 111 // Sets the drop position.
94 void SetDropParent(FolderNode* node, int drop_index, bool drop_on); 112 void SetDropPosition(const DropPosition& position);
95 113
96 // Returns the model as a BookmarkFolderTreeModel. 114 // Returns the model as a BookmarkFolderTreeModel.
97 BookmarkFolderTreeModel* folder_model() const; 115 BookmarkFolderTreeModel* folder_model() const;
98 116
99 // Converts FolderNode into a BookmarkNode. 117 // Converts FolderNode into a BookmarkNode.
100 BookmarkNode* TreeNodeAsBookmarkNode(FolderNode* node); 118 BookmarkNode* TreeNodeAsBookmarkNode(FolderNode* node);
101 119
102 // Converts an index in terms of the BookmarkFolderTreeModel to an index 120 // Converts an index in terms of the BookmarkFolderTreeModel to an index
103 // in terms of the BookmarkModel. 121 // in terms of the BookmarkModel.
104 int FolderIndexToBookmarkIndex(FolderNode* node, int index, bool drop_on); 122 int FolderIndexToBookmarkIndex(FolderNode* node, int index, bool drop_on);
ncarter (slow) 2008/11/04 18:39:47 This could be made to take a DropPosition too.
105 123
106 Profile* profile_; 124 Profile* profile_;
107 125
108 // Non-null during a drop. 126 // Non-null during a drop.
109 scoped_ptr<DropInfo> drop_info_; 127 scoped_ptr<DropInfo> drop_info_;
110 128
111 // Did we originate the drag? 129 // Did we originate the drag?
112 bool is_dragging_; 130 bool is_dragging_;
113 131
114 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderTreeView); 132 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderTreeView);
115 }; 133 };
116 134
117 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ 135 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698