summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/bookmark_table_view.h
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-04 19:29:08 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-04 19:29:08 +0000
commitf28cbb7246977eb443650f7d2fc9675b573317b2 (patch)
treedda1262734dd45010df771821e869b687b9d1b6a /chrome/browser/views/bookmark_table_view.h
parent431c16ea953a80b9153ba9a8c0b17b07a96f4a24 (diff)
downloadchromium_src-f28cbb7246977eb443650f7d2fc9675b573317b2.zip
chromium_src-f28cbb7246977eb443650f7d2fc9675b573317b2.tar.gz
chromium_src-f28cbb7246977eb443650f7d2fc9675b573317b2.tar.bz2
Adds support for autoscrolling on drag to bookmark tree/table.
BUG=674 TEST=none Review URL: http://codereview.chromium.org/9042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_table_view.h')
-rw-r--r--chrome/browser/views/bookmark_table_view.h87
1 files changed, 57 insertions, 30 deletions
diff --git a/chrome/browser/views/bookmark_table_view.h b/chrome/browser/views/bookmark_table_view.h
index a01f1af..40dc81e 100644
--- a/chrome/browser/views/bookmark_table_view.h
+++ b/chrome/browser/views/bookmark_table_view.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
+#include "chrome/browser/bookmarks/bookmark_drop_info.h"
#include "chrome/views/menu.h"
#include "chrome/views/table_view.h"
@@ -54,49 +55,75 @@ class BookmarkTableView : public views::TableView {
virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
private:
- // Information used when we're the drop target of a drag and drop operation.
- struct DropInfo {
- DropInfo() : drop_index(-1), drop_operation(0), drop_on(false) {}
-
- BookmarkDragData drag_data;
-
- // Index into the table model of where the drop should occur.
- int drop_index;
-
- // The drop operation that should occur.
- int drop_operation;
+ // DropPosition identifies where the drop should occur.
+ struct DropPosition {
+ DropPosition() : index(-1), on(false) {}
+ DropPosition(int index, bool on) : index(index), on(on) {}
+
+ bool equals(const DropPosition& position) const {
+ return index == position.index && on == position.on;
+ }
+
+ // The index into the table model as to where the drop should occur. This
+ // may == the row count of the table.
+ int index;
+
+ // Whether drop is on the item at the specified index. If false, the drop
+ // is at the specified index.
+ bool on;
+ };
- // Whether the drop is on drop_index or before it.
- bool drop_on;
+ // Information used when we're the drop target of a drag and drop operation.
+ class DropInfo : public BookmarkDropInfo {
+ public:
+ explicit DropInfo(BookmarkTableView* view)
+ : BookmarkDropInfo(view->GetNativeControlHWND(),
+ view->content_offset()),
+ view_(view) {}
+
+ // Overriden to invoke UpdateDropInfo.
+ virtual void Scrolled();
+
+ // The position the drop is to occur at.
+ void set_position(const DropPosition& position) {
+ position_ = position;
+ }
+ const DropPosition& position() { return position_; }
+
+ private:
+ DropPosition position_;
+ BookmarkTableView* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(DropInfo);
};
+ friend class DropInfo;
+
+ // Updates drop info. This is invoked both from OnDragUpdated and when we
+ // autoscroll during a drop.
+ int UpdateDropInfo();
// Starts a drop operation.
void BeginDrag();
- // Returns the drop operation for the specified index.
- int CalculateDropOperation(const views::DropTargetEvent& event,
- int drop_index,
- bool drop_on);
+ // Returns the drop operation for the specified position.
+ int CalculateDropOperation(const DropPosition& position);
// Performs the drop operation.
void OnPerformDropImpl();
- // Sets the drop index. If index differs from the current drop index
- // UpdateDropIndex is invoked for the old and new values.
- void SetDropIndex(int index, bool drop_on);
+ // Sets the position of the drop. If this differs from the current position
+ // UpdateDropIndicator is invoked for old and new values.
+ void SetDropPosition(const DropPosition& position);
- // Invoked from SetDropIndex to update the state for the specified index
- // and schedule a paint. If |turn_on| is true the highlight is being turned
- // on for the specified index, otherwise it is being turned off.
- void UpdateDropIndex(int index, bool drop_on, bool turn_on);
+ // Invoked from SetDropPosition to update the visual indicator. |turn_on|
+ // indicates whether the indicator is to be turned on or off.
+ void UpdateDropIndicator(const DropPosition& position, bool turn_on);
- // Determines the drop index for the specified location.
- int CalculateDropIndex(int y, bool* drop_on);
+ // Determines the drop position for the specified location.
+ DropPosition CalculateDropPosition(int y);
- // Returns the BookmarkNode the drop should occur on, or NULL if not over
- // a valid location.
- BookmarkNode* GetDropParentAndIndex(int visual_drop_index,
- bool drop_on,
+ // Returns the BookmarkNode the drop should occur on.
+ BookmarkNode* GetDropParentAndIndex(const DropPosition& position,
int* index);
// Returns the bounds of drop indicator shown when the drop is to occur