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

Unified Diff: chrome/browser/ui/panels/panel_drag_gtk.h

Issue 10020057: Resize support for detached GTK Panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/panels/panel_drag_gtk.h
diff --git a/chrome/browser/ui/panels/panel_drag_gtk.h b/chrome/browser/ui/panels/panel_drag_gtk.h
new file mode 100644
index 0000000000000000000000000000000000000000..474a994d0c726f3f8701c97156eec77f6f6a2638
--- /dev/null
+++ b/chrome/browser/ui/panels/panel_drag_gtk.h
@@ -0,0 +1,97 @@
+// Copyright (c) 2012 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_UI_PANELS_PANEL_DRAG_GTK_H_
+#define CHROME_BROWSER_UI_PANELS_PANEL_DRAG_GTK_H_
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ui/base/gtk/gtk_signal.h"
+
+class Panel;
+class PanelDragDelegate;
+
+// Class for GTK handling of move-drag and resize-drag on a panel.
+// Only one type of drag may be active at any time.
+// Dragging only begins if the mouse is moved beyond the drag threshold.
+// If mouse is released without exceeding the drag threshold, the mouse
+// press and release is treated as a mouse click.
+class PanelDragGtk {
dcheng 2012/04/12 00:12:45 Given that this is named drag_helper_ in PanelBrow
+ public:
+ explicit PanelDragGtk(Panel* panel);
+ ~PanelDragGtk();
+
+ GtkWidget* widget() const { return drag_widget_; }
+
+ // Sets up mouse and keyboard events processing while the mouse
+ // is pressed on a window edge.
+ // |event| is the mouse press event.
+ // |cursor| is the cursor to display during the drag.
+ // |edge| is the window edge from which to resize the panel.
+ void InitialWindowEdgeMousePress(GdkEventButton* event, GdkCursor* cursor,
+ GdkWindowEdge& edge);
+
+ // Sets up mouse and keyboard events processing while the mouse is
+ // pressed on the titlebar.
+ // |event| is the mouse press event.
+ // |titlebar_widget| should handle the mouse release event if the mouse
+ // is released without exceeding the drag threshold (a mouse click).
+ void InitialTitlebarMousePress(GdkEventButton* event,
+ GtkWidget* titlebar_widget);
+
+ private:
+ enum DragState {
+ NOT_DRAGGING,
+ DRAG_IN_PROGRESS
+ };
+
+ // Callbacks for GTK mouse and key events.
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnMouseMoveEvent,
+ GdkEventMotion*);
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnButtonPressEvent,
+ GdkEventButton*);
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnButtonReleaseEvent,
+ GdkEventButton*);
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnKeyPressEvent,
+ GdkEventKey*);
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnKeyReleaseEvent,
+ GdkEventKey*);
+ CHROMEGTK_CALLBACK_1(PanelDragGtk, gboolean, OnGrabBrokenEvent,
+ GdkEventGrabBroken*);
+
+ // Utility to dcheck a bunch of state to ensure a clean slate.
+ // Returns true only if all the dchecks pass.
+ bool AssertCleanState();
+
+ void GrabPointerAndKeyboard(GdkEventButton* event,
+ GdkCursor* cursor);
+
+ // Ends any drag that is currently in progress (if any).
+ // Also resets all drag state.
+ void EndDrag(bool canceled);
+
+ // Weak pointer to the panel being dragged.
+ Panel* panel_;
+
+ // Invisible event box to receive mouse and key events.
+ GtkWidget* drag_widget_;
+
+ DragState drag_state_;
+
+ // A copy of the initial button press event.
+ GdkEvent* initial_mouse_down_;
+
+ // Widget that should process the mouse click if mouse is released
+ // without exceeding the drag threshold. May be NULL if no click
+ // handling is necessary.
+ GtkWidget* click_handler_;
+
+ // Delegate for processing drag depends on actual type of drag.
+ PanelDragDelegate* drag_delegate_;
dcheng 2012/04/12 00:12:45 Nit: DISABLE_COPY_AND_ASSIGN
jennb 2012/04/12 18:00:24 Done.
+};
+
+#endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_GTK_H_

Powered by Google App Engine
This is Rietveld 408576698