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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 7605009: Implement drag and drop testing in a platform independent way. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a build error on mac only. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/panels/panel_browser_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 303
304 Browser* PanelBrowserView::GetPanelBrowser() const { 304 Browser* PanelBrowserView::GetPanelBrowser() const {
305 return browser(); 305 return browser();
306 } 306 }
307 307
308 void PanelBrowserView::DestroyPanelBrowser() { 308 void PanelBrowserView::DestroyPanelBrowser() {
309 DestroyBrowser(); 309 DestroyBrowser();
310 } 310 }
311 311
312 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() {
313 return this;
314 }
315
316 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { 312 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const {
317 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); 313 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView());
318 } 314 }
319 315
320 bool PanelBrowserView::OnTitleBarMousePressed(const views::MouseEvent& event) { 316 bool PanelBrowserView::OnTitleBarMousePressed(const gfx::Point& location) {
321 if (!event.IsOnlyLeftMouseButton())
322 return false;
323 mouse_pressed_ = true; 317 mouse_pressed_ = true;
324 mouse_pressed_point_ = event.location(); 318 mouse_pressed_point_ = location;
325 mouse_dragging_ = false; 319 mouse_dragging_ = false;
326 return true; 320 return true;
327 } 321 }
328 322
329 bool PanelBrowserView::OnTitleBarMouseDragged(const views::MouseEvent& event) { 323 bool PanelBrowserView::OnTitleBarMouseDragged(const gfx::Point& location) {
330 if (!mouse_pressed_) 324 if (!mouse_pressed_)
331 return false; 325 return false;
332 326
333 // We do not allow dragging vertically. 327 // We do not allow dragging vertically.
334 int delta_x = event.location().x() - mouse_pressed_point_.x(); 328 int delta_x = location.x() - mouse_pressed_point_.x();
335 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) { 329 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) {
336 panel_->manager()->StartDragging(panel_.get()); 330 panel_->manager()->StartDragging(panel_.get());
337 mouse_dragging_ = true; 331 mouse_dragging_ = true;
338 } 332 }
339 if (mouse_dragging_) 333 if (mouse_dragging_)
340 panel_->manager()->Drag(delta_x); 334 panel_->manager()->Drag(delta_x);
341 return true; 335 return true;
342 } 336 }
343 337
344 bool PanelBrowserView::OnTitleBarMouseReleased(const views::MouseEvent& event) { 338 bool PanelBrowserView::OnTitleBarMouseReleased() {
345 if (mouse_dragging_) 339 if (mouse_dragging_)
346 return EndDragging(false); 340 return EndDragging(false);
347 341
348 // Do not minimize the panel when we just clear the attention state. This is 342 // Do not minimize the panel when we just clear the attention state. This is
349 // a hack to prevent the panel from being minimized when the user clicks on 343 // a hack to prevent the panel from being minimized when the user clicks on
350 // the title-bar to clear the attention. 344 // the title-bar to clear the attention.
351 if (panel_->expansion_state() == Panel::EXPANDED && 345 if (panel_->expansion_state() == Panel::EXPANDED &&
352 base::TimeTicks::Now() < attention_cleared_time_ + 346 base::TimeTicks::Now() < attention_cleared_time_ +
353 kSuspendMinimizeOnClickIntervalMs) { 347 kSuspendMinimizeOnClickIntervalMs) {
354 return true; 348 return true;
(...skipping 15 matching lines...) Expand all
370 if (!mouse_pressed_) 364 if (!mouse_pressed_)
371 return false; 365 return false;
372 mouse_pressed_ = false; 366 mouse_pressed_ = false;
373 367
374 if (!mouse_dragging_) 368 if (!mouse_dragging_)
375 cancelled = true; 369 cancelled = true;
376 mouse_dragging_ = false; 370 mouse_dragging_ = false;
377 panel_->manager()->EndDragging(cancelled); 371 panel_->manager()->EndDragging(cancelled);
378 return true; 372 return true;
379 } 373 }
374
375 // NativePanelTesting implementation.
376 class NativePanelTestingWin : public NativePanelTesting {
377 public:
378 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view);
379
380 private:
381 virtual void PressLeftMouseButtonTitlebar(
382 const gfx::Point& point) OVERRIDE;
383 virtual void ReleaseMouseButtonTitlebar() OVERRIDE;
384 virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE;
385 virtual void CancelDragTitlebar() OVERRIDE;
386 virtual void FinishDragTitlebar() OVERRIDE;
387
388 PanelBrowserView* panel_browser_view_;
389 };
390
391 // static
392 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) {
393 return new NativePanelTestingWin(static_cast<PanelBrowserView*>(
394 native_panel));
395 }
396
397 NativePanelTestingWin::NativePanelTestingWin(
398 PanelBrowserView* panel_browser_view) :
399 panel_browser_view_(panel_browser_view) {
400 }
401
402 void NativePanelTestingWin::PressLeftMouseButtonTitlebar(
403 const gfx::Point& point) {
404 panel_browser_view_->OnTitleBarMousePressed(point);
405 }
406
407 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() {
408 panel_browser_view_->OnTitleBarMouseReleased();
409 }
410
411 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) {
412 gfx::Rect current_bounds = panel_browser_view_->panel()->GetRestoredBounds();
413 panel_browser_view_->OnTitleBarMouseDragged(gfx::Point(
414 current_bounds.x() + delta_x, current_bounds.y() + delta_y));
415 }
416
417 void NativePanelTestingWin::CancelDragTitlebar() {
418 panel_browser_view_->OnTitleBarMouseCaptureLost();
419 }
420
421 void NativePanelTestingWin::FinishDragTitlebar() {
422 panel_browser_view_->OnTitleBarMouseReleased();
423 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.h ('k') | chrome/browser/ui/panels/panel_browser_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698