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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.h

Issue 399173004: Adjust BrowserActionsContainer drag and drop to work for overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnurs + RTL fix Created 6 years, 5 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_
7 7
8 #include "base/observer_list.h" 8 #include "base/observer_list.h"
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" 9 #include "chrome/browser/extensions/extension_keybinding_registry.h"
10 #include "chrome/browser/extensions/extension_toolbar_model.h" 10 #include "chrome/browser/extensions/extension_toolbar_model.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Overridden from views::View: 284 // Overridden from views::View:
285 virtual void ViewHierarchyChanged( 285 virtual void ViewHierarchyChanged(
286 const ViewHierarchyChangedDetails& details) OVERRIDE; 286 const ViewHierarchyChangedDetails& details) OVERRIDE;
287 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 287 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
288 virtual void OnThemeChanged() OVERRIDE; 288 virtual void OnThemeChanged() OVERRIDE;
289 289
290 private: 290 private:
291 friend class BrowserActionView; // So it can access IconWidth(). 291 friend class BrowserActionView; // So it can access IconWidth().
292 friend class ShowFolderMenuTask; 292 friend class ShowFolderMenuTask;
293 293
294 // A struct representing the position at which an action will be dropped.
295 struct DropPosition;
296
294 typedef std::vector<BrowserActionView*> BrowserActionViews; 297 typedef std::vector<BrowserActionView*> BrowserActionViews;
295 298
296 // Returns the width of an icon, optionally with its padding. 299 // Returns the width of an icon, optionally with its padding.
297 static int IconWidth(bool include_padding); 300 static int IconWidth(bool include_padding);
298 301
299 // Returns the height of an icon. 302 // Returns the height of an icon.
300 static int IconHeight(); 303 static int IconHeight();
301 304
302 // extensions::ExtensionToolbarModel::Observer implementation. 305 // extensions::ExtensionToolbarModel::Observer implementation.
303 virtual void BrowserActionAdded(const extensions::Extension* extension, 306 virtual void BrowserActionAdded(const extensions::Extension* extension,
(...skipping 19 matching lines...) Expand all
323 void StopShowFolderDropMenuTimer(); 326 void StopShowFolderDropMenuTimer();
324 327
325 // Show the drop down folder after a slight delay. 328 // Show the drop down folder after a slight delay.
326 void StartShowFolderDropMenuTimer(); 329 void StartShowFolderDropMenuTimer();
327 330
328 // Show the overflow menu. 331 // Show the overflow menu.
329 void ShowDropFolder(); 332 void ShowDropFolder();
330 333
331 // Sets the drop indicator position (and schedules paint if the position has 334 // Sets the drop indicator position (and schedules paint if the position has
332 // changed). 335 // changed).
333 void SetDropIndicator(int x_pos); 336 void SetDropPosition(size_t row, size_t icon_in_row);
337
338 // Resets the drop position to NULL (removing the indicator).
339 void ResetDropPosition();
334 340
335 // Given a number of |icons| and whether to |display_chevron|, returns the 341 // Given a number of |icons| and whether to |display_chevron|, returns the
336 // amount of pixels needed to draw the entire container. For convenience, 342 // amount of pixels needed to draw the entire container. For convenience,
337 // callers can set |icons| to -1 to mean "all icons". 343 // callers can set |icons| to -1 to mean "all icons".
338 int IconCountToWidth(int icons, bool display_chevron) const; 344 int IconCountToWidth(int icons, bool display_chevron) const;
339 345
340 // Given a pixel width, returns the number of icons that fit. (This 346 // Given a pixel width, returns the number of icons that fit. (This
341 // automatically determines whether a chevron will be needed and includes it 347 // automatically determines whether a chevron will be needed and includes it
342 // in the calculation.) 348 // in the calculation.)
343 size_t WidthToIconCount(int pixels) const; 349 size_t WidthToIconCount(int pixels) const;
(...skipping 16 matching lines...) Expand all
360 bool ShouldDisplayBrowserAction(const extensions::Extension* extension); 366 bool ShouldDisplayBrowserAction(const extensions::Extension* extension);
361 367
362 // Show a popup. Returns true if a new popup was shown. Showing the popup will 368 // Show a popup. Returns true if a new popup was shown. Showing the popup will
363 // grant tab permissions if |grant_tab_permissions| is true. Only pass true 369 // grant tab permissions if |grant_tab_permissions| is true. Only pass true
364 // for this argument for popups triggered interactively, not popups triggered 370 // for this argument for popups triggered interactively, not popups triggered
365 // by an API. 371 // by an API.
366 bool ShowPopup(BrowserActionButton* button, 372 bool ShowPopup(BrowserActionButton* button,
367 ExtensionPopup::ShowAction show_action, 373 ExtensionPopup::ShowAction show_action,
368 bool grant_tab_permissions); 374 bool grant_tab_permissions);
369 375
376 // Return the index of the first visible icon.
377 size_t GetFirstVisibleIconIndex() const;
378
370 // Whether this container is in overflow mode (as opposed to in 'main' 379 // Whether this container is in overflow mode (as opposed to in 'main'
371 // mode). See class comments for details on the difference. 380 // mode). See class comments for details on the difference.
372 bool in_overflow_mode() const { return main_container_ != NULL; } 381 bool in_overflow_mode() const { return main_container_ != NULL; }
373 382
374 // The vector of browser actions (icons/image buttons for each action). Note 383 // The vector of browser actions (icons/image buttons for each action). Note
375 // that not every BrowserAction in the ToolbarModel will necessarily be in 384 // that not every BrowserAction in the ToolbarModel will necessarily be in
376 // this collection. Some extensions may be disabled in incognito windows. 385 // this collection. Some extensions may be disabled in incognito windows.
377 BrowserActionViews browser_action_views_; 386 BrowserActionViews browser_action_views_;
378 387
379 Profile* profile_; 388 Profile* profile_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 433
425 // This is used while the user is resizing (and when the animations are in 434 // This is used while the user is resizing (and when the animations are in
426 // progress) to know how wide the delta is between the current state and what 435 // progress) to know how wide the delta is between the current state and what
427 // we should draw. 436 // we should draw.
428 int resize_amount_; 437 int resize_amount_;
429 438
430 // Keeps track of the absolute pixel width the container should have when we 439 // Keeps track of the absolute pixel width the container should have when we
431 // are done animating. 440 // are done animating.
432 int animation_target_size_; 441 int animation_target_size_;
433 442
434 // The x position for where to draw the drop indicator. -1 if no indicator. 443 // The DropPosition for the current drag-and-drop operation, or NULL if there
435 int drop_indicator_position_; 444 // is none.
445 scoped_ptr<DropPosition> drop_position_;
Peter Kasting 2014/07/21 20:24:09 I wonder if instead of using NULL to mean "none",
Devlin 2014/07/22 17:30:47 I personally prefer the scoped ptr approach, becau
Peter Kasting 2014/07/22 18:21:11 Let me back up for a second. You start by saying
Devlin 2014/07/22 20:29:33 But, if we define a constructor (default or otherw
Peter Kasting 2014/07/22 21:10:00 Oof, I didn't recall that. It's funny too, we're
Devlin 2014/07/22 22:13:20 Aggregate initialization isn't too bad, but we can
436 446
437 // The class that registers for keyboard shortcuts for extension commands. 447 // The class that registers for keyboard shortcuts for extension commands.
438 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; 448 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_;
439 449
440 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; 450 base::WeakPtrFactory<BrowserActionsContainer> task_factory_;
441 451
442 // Handles delayed showing of the overflow menu when hovering. 452 // Handles delayed showing of the overflow menu when hovering.
443 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; 453 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_;
444 454
445 ObserverList<BrowserActionsContainerObserver> observers_; 455 ObserverList<BrowserActionsContainerObserver> observers_;
446 456
447 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); 457 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer);
448 }; 458 };
449 459
450 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ 460 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698