diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-29 23:38:06 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-29 23:38:06 +0000 |
commit | 7f856bee73ffdccdbbbbbab4cb79185290d38359 (patch) | |
tree | a837328e08a113abdc70b2fc0ae2f2a4a3f804eb /chrome/browser/views/bookmark_table_view.h | |
parent | 281fe14063dd8fb81cea102f5abb7b82f407c3d1 (diff) | |
download | chromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.zip chromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.tar.gz chromium_src-7f856bee73ffdccdbbbbbab4cb79185290d38359.tar.bz2 |
First cut at the bookmark manager. There are still a fair number of
rough edges, but I'm at a good point where I want to land what I
have. Here's what is left:
. Flicker on show, likely the result of restoring window placement.
. tree flickers when dragging splitter.
. table/tree need to autoscroll when drop cursor held at bottom of view.
. prompts for deleting.
. When you move an item the table snaps to the top, this is because
I'm sending out model changed. need a better notification.
. Operations in menu to add need to change selection.
. Remember split location.
I would have preferred to split this up into a couple of reviews, but
everything is intertwined now. Sorry.
BUG=674
TEST=don't test the bookmark manager yet, but make sure bookmark bar
still works.
Review URL: http://codereview.chromium.org/8197
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_table_view.h')
-rw-r--r-- | chrome/browser/views/bookmark_table_view.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_table_view.h b/chrome/browser/views/bookmark_table_view.h new file mode 100644 index 0000000..a01f1af --- /dev/null +++ b/chrome/browser/views/bookmark_table_view.h @@ -0,0 +1,121 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ +#define CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ + +#include "chrome/browser/bookmarks/bookmark_drag_data.h" +#include "chrome/views/menu.h" +#include "chrome/views/table_view.h" + +class BookmarkModel; +class BookmarkNode; +class BookmarkTableModel; +class OSExchangeData; +class PrefService; +class Profile; + +// A TableView implementation that shows a BookmarkTableModel. +// BookmarkTableView provides drag and drop support as well as showing a +// separate set of columns when showing search results. +class BookmarkTableView : public views::TableView { + public: + BookmarkTableView(Profile* profile, BookmarkTableModel* model); + + static void RegisterUserPrefs(PrefService* prefs); + + // Drag and drop methods. + virtual bool CanDrop(const OSExchangeData& data); + virtual void OnDragEntered(const views::DropTargetEvent& event); + virtual int OnDragUpdated(const views::DropTargetEvent& event); + virtual void OnDragExited(); + virtual int OnPerformDrop(const views::DropTargetEvent& event); + + // Sets the parent of the nodes being displayed. For search and recently + // found results |parent| is NULL. + void set_parent_node(BookmarkNode* parent) { parent_node_ = parent; } + + // Sets whether the path column should be shown. The path column is shown + // for search results and recently bookmarked. + void SetShowPathColumn(bool show_path_column); + + // The model as a BookmarkTableModel. + BookmarkTableModel* bookmark_table_model() const; + + // Saves the widths of the table columns. + void SaveColumnConfiguration(); + + protected: + // Overriden to draw a drop indicator when dropping between rows. + virtual void PostPaint(); + + // Overriden to start a drag. + 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; + + // Whether the drop is on drop_index or before it. + bool drop_on; + }; + + // 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); + + // 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); + + // 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); + + // Determines the drop index for the specified location. + int CalculateDropIndex(int y, bool* drop_on); + + // 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, + int* index); + + // Returns the bounds of drop indicator shown when the drop is to occur + // between rows (drop_on is false). + RECT GetDropBetweenHighlightRect(int index); + + // Resets the columns. BookmarkTableView shows different sets of columns. + // See ShowPathColumn for details. + void UpdateColumns(); + + Profile* profile_; + + BookmarkNode* parent_node_; + + scoped_ptr<DropInfo> drop_info_; + + bool show_path_column_; + + DISALLOW_COPY_AND_ASSIGN(BookmarkTableView); +}; + +#endif // CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ |