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

Side by Side Diff: chrome/browser/views/bookmark_table_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_TABLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ 6 #define CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_
7 7
8 #include "chrome/browser/bookmarks/bookmark_drag_data.h" 8 #include "chrome/browser/bookmarks/bookmark_drag_data.h"
9 #include "chrome/browser/bookmarks/bookmark_drop_info.h"
9 #include "chrome/views/menu.h" 10 #include "chrome/views/menu.h"
10 #include "chrome/views/table_view.h" 11 #include "chrome/views/table_view.h"
11 12
12 class BookmarkModel; 13 class BookmarkModel;
13 class BookmarkNode; 14 class BookmarkNode;
14 class BookmarkTableModel; 15 class BookmarkTableModel;
15 class OSExchangeData; 16 class OSExchangeData;
16 class PrefService; 17 class PrefService;
17 class Profile; 18 class Profile;
18 19
(...skipping 28 matching lines...) Expand all
47 void SaveColumnConfiguration(); 48 void SaveColumnConfiguration();
48 49
49 protected: 50 protected:
50 // Overriden to draw a drop indicator when dropping between rows. 51 // Overriden to draw a drop indicator when dropping between rows.
51 virtual void PostPaint(); 52 virtual void PostPaint();
52 53
53 // Overriden to start a drag. 54 // Overriden to start a drag.
54 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); 55 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
55 56
56 private: 57 private:
58 // DropPosition identifies where the drop should occur.
59 struct DropPosition {
60 DropPosition() : index(-1), on(false) {}
61 DropPosition(int index, bool on) : index(index), on(on) {}
62
63 bool equals(const DropPosition& position) const {
64 return index == position.index && on == position.on;
65 }
66
67 // The index into the table model as to where the drop should occur. This
68 // may == the row count of the table.
69 int index;
70
71 // Whether drop is on the item at the specified index. If false, the drop
72 // is at the specified index.
73 bool on;
74 };
75
57 // Information used when we're the drop target of a drag and drop operation. 76 // Information used when we're the drop target of a drag and drop operation.
58 struct DropInfo { 77 class DropInfo : public BookmarkDropInfo {
59 DropInfo() : drop_index(-1), drop_operation(0), drop_on(false) {} 78 public:
79 explicit DropInfo(BookmarkTableView* view)
80 : BookmarkDropInfo(view->GetNativeControlHWND(),
81 view->content_offset()),
82 view_(view) {}
60 83
61 BookmarkDragData drag_data; 84 // Overriden to invoke UpdateDropInfo.
85 virtual void Scrolled();
62 86
63 // Index into the table model of where the drop should occur. 87 // The position the drop is to occur at.
64 int drop_index; 88 void set_position(const DropPosition& position) {
89 position_ = position;
90 }
91 const DropPosition& position() { return position_; }
65 92
66 // The drop operation that should occur. 93 private:
67 int drop_operation; 94 DropPosition position_;
95 BookmarkTableView* view_;
68 96
69 // Whether the drop is on drop_index or before it. 97 DISALLOW_COPY_AND_ASSIGN(DropInfo);
70 bool drop_on;
71 }; 98 };
99 friend class DropInfo;
100
101 // Updates drop info. This is invoked both from OnDragUpdated and when we
102 // autoscroll during a drop.
103 int UpdateDropInfo();
72 104
73 // Starts a drop operation. 105 // Starts a drop operation.
74 void BeginDrag(); 106 void BeginDrag();
75 107
76 // Returns the drop operation for the specified index. 108 // Returns the drop operation for the specified position.
77 int CalculateDropOperation(const views::DropTargetEvent& event, 109 int CalculateDropOperation(const DropPosition& position);
78 int drop_index,
79 bool drop_on);
80 110
81 // Performs the drop operation. 111 // Performs the drop operation.
82 void OnPerformDropImpl(); 112 void OnPerformDropImpl();
83 113
84 // Sets the drop index. If index differs from the current drop index 114 // Sets the position of the drop. If this differs from the current position
85 // UpdateDropIndex is invoked for the old and new values. 115 // UpdateDropIndicator is invoked for old and new values.
86 void SetDropIndex(int index, bool drop_on); 116 void SetDropPosition(const DropPosition& position);
87 117
88 // Invoked from SetDropIndex to update the state for the specified index 118 // Invoked from SetDropPosition to update the visual indicator. |turn_on|
89 // and schedule a paint. If |turn_on| is true the highlight is being turned 119 // indicates whether the indicator is to be turned on or off.
90 // on for the specified index, otherwise it is being turned off. 120 void UpdateDropIndicator(const DropPosition& position, bool turn_on);
91 void UpdateDropIndex(int index, bool drop_on, bool turn_on);
92 121
93 // Determines the drop index for the specified location. 122 // Determines the drop position for the specified location.
94 int CalculateDropIndex(int y, bool* drop_on); 123 DropPosition CalculateDropPosition(int y);
95 124
96 // Returns the BookmarkNode the drop should occur on, or NULL if not over 125 // Returns the BookmarkNode the drop should occur on.
97 // a valid location. 126 BookmarkNode* GetDropParentAndIndex(const DropPosition& position,
98 BookmarkNode* GetDropParentAndIndex(int visual_drop_index,
99 bool drop_on,
100 int* index); 127 int* index);
101 128
102 // Returns the bounds of drop indicator shown when the drop is to occur 129 // Returns the bounds of drop indicator shown when the drop is to occur
103 // between rows (drop_on is false). 130 // between rows (drop_on is false).
104 RECT GetDropBetweenHighlightRect(int index); 131 RECT GetDropBetweenHighlightRect(int index);
105 132
106 // Resets the columns. BookmarkTableView shows different sets of columns. 133 // Resets the columns. BookmarkTableView shows different sets of columns.
107 // See ShowPathColumn for details. 134 // See ShowPathColumn for details.
108 void UpdateColumns(); 135 void UpdateColumns();
109 136
110 Profile* profile_; 137 Profile* profile_;
111 138
112 BookmarkNode* parent_node_; 139 BookmarkNode* parent_node_;
113 140
114 scoped_ptr<DropInfo> drop_info_; 141 scoped_ptr<DropInfo> drop_info_;
115 142
116 bool show_path_column_; 143 bool show_path_column_;
117 144
118 DISALLOW_COPY_AND_ASSIGN(BookmarkTableView); 145 DISALLOW_COPY_AND_ASSIGN(BookmarkTableView);
119 }; 146 };
120 147
121 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ 148 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698