summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/info_bubble_gtk.h
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-24 03:19:13 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-24 03:19:13 +0000
commit73142769aac422267b84568000a5cc2a4b024f3d (patch)
tree27f651de1d3656bf505814acfbc7abdd08d2f547 /chrome/browser/gtk/info_bubble_gtk.h
parent92416a93858d7d21044296ec6b7b2440be3ac1bf (diff)
downloadchromium_src-73142769aac422267b84568000a5cc2a4b024f3d.zip
chromium_src-73142769aac422267b84568000a5cc2a4b024f3d.tar.gz
chromium_src-73142769aac422267b84568000a5cc2a4b024f3d.tar.bz2
GTK: Try to position info bubbles onscreen.
I didn't go so far as to add support for arrows-on-the-bottom in this change; I'm just making the bubble extend left or right as needed. I'll add a parameter to specify the default arrow location (needed for browser action popups) in another CL. Tested by: - dragging a window to the right edge of the screen and confirming that bookmark bubbles open extended to the left - opening a bookmark bubble, using a little X program to move the Chrome window to the right side of the screen (can't drag it there since the pointer is grabbed), and confirming that the bubble gets updated to extend to the left - running in Arabic and confirming that bubbles extend to the left by default but get switched to extend to the right as needed BUG=23373 TEST=see above Review URL: http://codereview.chromium.org/316006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/info_bubble_gtk.h')
-rw-r--r--chrome/browser/gtk/info_bubble_gtk.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/gtk/info_bubble_gtk.h b/chrome/browser/gtk/info_bubble_gtk.h
index a92cd3b..876cb9c 100644
--- a/chrome/browser/gtk/info_bubble_gtk.h
+++ b/chrome/browser/gtk/info_bubble_gtk.h
@@ -72,6 +72,18 @@ class InfoBubbleGtk : public NotificationObserver {
void HandlePointerAndKeyboardUngrabbedByContent();
private:
+ // Where should the arrow be placed relative to the bubble?
+ enum ArrowLocationGtk {
+ // TODO(derat): Support placing arrows on the bottoms of the bubbles.
+ ARROW_LOCATION_TOP_LEFT,
+ ARROW_LOCATION_TOP_RIGHT,
+ };
+
+ enum FrameType {
+ FRAME_MASK,
+ FRAME_STROKE,
+ };
+
explicit InfoBubbleGtk(GtkThemeProvider* provider);
virtual ~InfoBubbleGtk();
@@ -80,6 +92,29 @@ class InfoBubbleGtk : public NotificationObserver {
const gfx::Rect& rect,
GtkWidget* content);
+ // Make the points for our polygon frame, either for fill (the mask), or for
+ // when we stroke the border.
+ static std::vector<GdkPoint> MakeFramePolygonPoints(
+ ArrowLocationGtk arrow_location,
+ int width,
+ int height,
+ FrameType type);
+
+ // Get the location where the arrow should be placed (which is a function of
+ // whether the user's language is LTR/RTL and of the direction that the bubble
+ // should be facing to fit onscreen). |arrow_x| is the X component in screen
+ // coordinates of the point at which the bubble's arrow should be aimed, and
+ // |width| is the bubble's width.
+ static ArrowLocationGtk GetArrowLocation(int arrow_x, int width);
+
+ // Updates |arrow_location_| based on the toplevel window's current position
+ // and the bubble's size. If the location changes, moves and reshapes the
+ // window and returns true.
+ bool UpdateArrowLocation();
+
+ // Reshapes the window and updates |mask_region_|.
+ void UpdateWindowShape();
+
// Calculate the current screen position for the bubble's window (per
// |toplevel_window_|'s position as of its most-recent ConfigureNotify event
// and |rect_|) and move it there.
@@ -108,6 +143,13 @@ class InfoBubbleGtk : public NotificationObserver {
}
gboolean HandleEscape();
+ static gboolean HandleExposeThunk(GtkWidget* widget,
+ GdkEventExpose* event,
+ gpointer user_data) {
+ return reinterpret_cast<InfoBubbleGtk*>(user_data)->HandleExpose();
+ }
+ gboolean HandleExpose();
+
static void HandleSizeAllocateThunk(GtkWidget* widget,
GtkAllocation* allocation,
gpointer user_data) {
@@ -176,6 +218,9 @@ class InfoBubbleGtk : public NotificationObserver {
// not).
GdkRegion* mask_region_;
+ // Where should the arrow be drawn relative to the bubble?
+ ArrowLocationGtk arrow_location_;
+
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(InfoBubbleGtk);