summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc2
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--ui/views/bubble/border_contents_view.cc (renamed from views/bubble/border_contents_view.cc)0
-rw-r--r--ui/views/bubble/border_contents_view.h88
-rw-r--r--ui/views/bubble/bubble_border.cc (renamed from views/bubble/bubble_border.cc)0
-rw-r--r--ui/views/bubble/bubble_border.h183
-rw-r--r--ui/views/bubble/bubble_delegate.cc (renamed from views/bubble/bubble_delegate.cc)0
-rw-r--r--ui/views/bubble/bubble_delegate.h153
-rw-r--r--ui/views/bubble/bubble_delegate_unittest.cc (renamed from views/bubble/bubble_delegate_unittest.cc)0
-rw-r--r--ui/views/bubble/bubble_frame_view.cc (renamed from views/bubble/bubble_frame_view.cc)0
-rw-r--r--ui/views/bubble/bubble_frame_view.h57
-rw-r--r--ui/views/bubble/bubble_frame_view_unittest.cc (renamed from views/bubble/bubble_frame_view_unittest.cc)0
-rw-r--r--ui/views/events/event.cc (renamed from views/events/event.cc)0
-rw-r--r--ui/views/events/event.h415
-rw-r--r--ui/views/events/event_aura.cc (renamed from views/events/event_aura.cc)0
-rw-r--r--ui/views/events/event_gtk.cc (renamed from views/events/event_gtk.cc)0
-rw-r--r--ui/views/events/event_unittest.cc (renamed from views/events/event_unittest.cc)0
-rw-r--r--ui/views/events/event_wayland.cc (renamed from views/events/event_wayland.cc)0
-rw-r--r--ui/views/events/event_win.cc (renamed from views/events/event_win.cc)0
-rw-r--r--ui/views/events/event_x.cc (renamed from views/events/event_x.cc)0
-rw-r--r--ui/views/focus/accelerator_handler.h61
-rw-r--r--ui/views/focus/accelerator_handler_aura.cc (renamed from views/focus/accelerator_handler_aura.cc)0
-rw-r--r--ui/views/focus/accelerator_handler_gtk.cc (renamed from views/focus/accelerator_handler_gtk.cc)0
-rw-r--r--ui/views/focus/accelerator_handler_gtk_unittest.cc (renamed from views/focus/accelerator_handler_gtk_unittest.cc)0
-rw-r--r--ui/views/focus/accelerator_handler_touch.cc (renamed from views/focus/accelerator_handler_touch.cc)0
-rw-r--r--ui/views/focus/accelerator_handler_wayland.cc (renamed from views/focus/accelerator_handler_wayland.cc)0
-rw-r--r--ui/views/focus/accelerator_handler_win.cc (renamed from views/focus/accelerator_handler_win.cc)0
-rw-r--r--ui/views/focus/external_focus_tracker.cc (renamed from views/focus/external_focus_tracker.cc)0
-rw-r--r--ui/views/focus/external_focus_tracker.h78
-rw-r--r--ui/views/focus/focus_manager.cc (renamed from views/focus/focus_manager.cc)0
-rw-r--r--ui/views/focus/focus_manager.h283
-rw-r--r--ui/views/focus/focus_manager_factory.cc (renamed from views/focus/focus_manager_factory.cc)0
-rw-r--r--ui/views/focus/focus_manager_factory.h41
-rw-r--r--ui/views/focus/focus_manager_unittest.cc (renamed from views/focus/focus_manager_unittest.cc)0
-rw-r--r--ui/views/focus/focus_search.cc (renamed from views/focus/focus_search.cc)2
-rw-r--r--ui/views/focus/focus_search.h122
-rw-r--r--ui/views/focus/view_storage.cc (renamed from views/focus/view_storage.cc)2
-rw-r--r--ui/views/focus/view_storage.h70
-rw-r--r--ui/views/focus/widget_focus_manager.cc (renamed from views/focus/widget_focus_manager.cc)0
-rw-r--r--ui/views/focus/widget_focus_manager.h82
-rw-r--r--ui/views/layout/box_layout.cc (renamed from views/layout/box_layout.cc)0
-rw-r--r--ui/views/layout/box_layout.h62
-rw-r--r--ui/views/layout/box_layout_unittest.cc (renamed from views/layout/box_layout_unittest.cc)0
-rw-r--r--ui/views/layout/fill_layout.cc (renamed from views/layout/fill_layout.cc)0
-rw-r--r--ui/views/layout/fill_layout.h36
-rw-r--r--ui/views/layout/grid_layout.cc (renamed from views/layout/grid_layout.cc)0
-rw-r--r--ui/views/layout/grid_layout.h371
-rw-r--r--ui/views/layout/grid_layout_unittest.cc (renamed from views/layout/grid_layout_unittest.cc)0
-rw-r--r--ui/views/layout/layout_constants.h71
-rw-r--r--ui/views/layout/layout_manager.cc (renamed from views/layout/layout_manager.cc)0
-rw-r--r--ui/views/layout/layout_manager.h61
-rw-r--r--views/bubble/border_contents_view.h80
-rw-r--r--views/bubble/bubble_border.h175
-rw-r--r--views/bubble/bubble_delegate.h145
-rw-r--r--views/bubble/bubble_frame_view.h49
-rw-r--r--views/events/event.h407
-rw-r--r--views/focus/accelerator_handler.h53
-rw-r--r--views/focus/external_focus_tracker.h70
-rw-r--r--views/focus/focus_manager.h275
-rw-r--r--views/focus/focus_manager_factory.h33
-rw-r--r--views/focus/focus_search.h120
-rw-r--r--views/focus/view_storage.h62
-rw-r--r--views/focus/widget_focus_manager.h74
-rw-r--r--views/layout/box_layout.h56
-rw-r--r--views/layout/fill_layout.h28
-rw-r--r--views/layout/grid_layout.h363
-rw-r--r--views/layout/layout_constants.h63
-rw-r--r--views/layout/layout_manager.h59
-rw-r--r--views/views.gyp120
69 files changed, 2339 insertions, 2135 deletions
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index deda118..f5ba3c6 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -1035,7 +1035,7 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(
return false;
#else
// This method is not used for Linux ports. See FocusManager::OnKeyEvent() in
- // src/views/focus/focus_manager.cc for details.
+ // src/ui/views/focus/focus_manager.cc for details.
return false;
#endif
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 456dac7..a9cc2c7 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2205,7 +2205,7 @@
'sources!': [
'browser/ui/gtk/tabs/tab_renderer_gtk_unittest.cc',
'browser/renderer_host/gtk_key_bindings_handler_unittest.cc',
- '../views/focus/accelerator_handler_gtk_unittest.cc',
+ '../ui/views/focus/accelerator_handler_gtk_unittest.cc',
],
}],
['toolkit_uses_gtk == 1 or chromeos==1 or (OS=="linux" and use_aura==1)', {
diff --git a/views/bubble/border_contents_view.cc b/ui/views/bubble/border_contents_view.cc
index 67c893a..67c893a 100644
--- a/views/bubble/border_contents_view.cc
+++ b/ui/views/bubble/border_contents_view.cc
diff --git a/ui/views/bubble/border_contents_view.h b/ui/views/bubble/border_contents_view.h
new file mode 100644
index 0000000..696dd26
--- /dev/null
+++ b/ui/views/bubble/border_contents_view.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2011 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 UI_VIEWS_BUBBLE_BORDER_CONTENTS_VIEW_H_
+#define UI_VIEWS_BUBBLE_BORDER_CONTENTS_VIEW_H_
+#pragma once
+
+#include "views/bubble/bubble_border.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "views/view.h"
+
+namespace views {
+
+// This is used to paint the border and background of the Bubble.
+class VIEWS_EXPORT BorderContentsView : public View {
+ public:
+ BorderContentsView();
+ BorderContentsView(int top_margin,
+ int left_margin,
+ int bottom_margin,
+ int right_margin);
+
+ // Must be called before this object can be used.
+ void Init();
+
+ // Sets the background color.
+ void SetBackgroundColor(SkColor color);
+
+ // Sets the bubble alignment.
+ void SetAlignment(views::BubbleBorder::BubbleAlignment alignment);
+
+ // Given the size of the contents and the rect to point at, returns the bounds
+ // of both the border and the contents inside the bubble.
+ // |arrow_location| specifies the preferred location for the arrow
+ // anchor. If the bubble does not fit on the monitor and
+ // |allow_bubble_offscreen| is false, the arrow location may change so the
+ // bubble shows entirely.
+ virtual void SizeAndGetBounds(
+ const gfx::Rect& position_relative_to, // In screen coordinates
+ BubbleBorder::ArrowLocation arrow_location,
+ bool allow_bubble_offscreen,
+ const gfx::Size& contents_size,
+ gfx::Rect* contents_bounds, // Returned in window coordinates
+ gfx::Rect* window_bounds); // Returned in screen coordinates
+
+ // Sets content margins.
+ void set_content_margins(const gfx::Insets& margins) {
+ content_margins_ = margins;
+ }
+
+ // Accessor for |content_margins_|.
+ const gfx::Insets& content_margins() const {
+ return content_margins_;
+ }
+
+ protected:
+ virtual ~BorderContentsView();
+
+ // Returns the bounds for the monitor showing the specified |rect|.
+ virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect);
+
+ BubbleBorder* bubble_border() const { return bubble_border_; }
+
+ private:
+ // Changes |arrow_location| to its mirrored version, vertically if |vertical|
+ // is true, horizontally otherwise, if |window_bounds| don't fit in
+ // |monitor_bounds|.
+ void MirrorArrowIfOffScreen(
+ bool vertical,
+ const gfx::Rect& position_relative_to,
+ const gfx::Rect& monitor_bounds,
+ const gfx::Size& local_contents_size,
+ BubbleBorder::ArrowLocation* arrow_location,
+ gfx::Rect* window_bounds);
+
+ // The bubble border.
+ BubbleBorder* bubble_border_;
+
+ // Margins between the content and the inside of the border, in pixels.
+ gfx::Insets content_margins_;
+
+ DISALLOW_COPY_AND_ASSIGN(BorderContentsView);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BUBBLE_BORDER_CONTENTS_VIEW_H_
diff --git a/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc
index 368b0be..368b0be 100644
--- a/views/bubble/bubble_border.cc
+++ b/ui/views/bubble/bubble_border.cc
diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h
new file mode 100644
index 0000000..09e20bb
--- /dev/null
+++ b/ui/views/bubble/bubble_border.h
@@ -0,0 +1,183 @@
+// Copyright (c) 2011 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 UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_
+#define UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_
+#pragma once
+
+#include "views/background.h"
+#include "views/border.h"
+
+class SkBitmap;
+
+namespace views {
+
+// Renders a border, with optional arrow, and a custom dropshadow.
+// This can be used to produce floating "bubble" objects with rounded corners.
+class VIEWS_EXPORT BubbleBorder : public views::Border {
+ public:
+ // Possible locations for the (optional) arrow.
+ // 0 bit specifies left or right.
+ // 1 bit specifies top or bottom.
+ // 2 bit specifies horizontal or vertical.
+ enum ArrowLocation {
+ TOP_LEFT = 0,
+ TOP_RIGHT = 1,
+ BOTTOM_LEFT = 2,
+ BOTTOM_RIGHT = 3,
+ LEFT_TOP = 4,
+ RIGHT_TOP = 5,
+ LEFT_BOTTOM = 6,
+ RIGHT_BOTTOM = 7,
+ NONE = 8, // No arrow. Positioned under the supplied rect.
+ FLOAT = 9 // No arrow. Centered over the supplied rect.
+ };
+
+ enum Shadow {
+ SHADOW = 0,
+ NO_SHADOW = 1
+ };
+
+ // The position of the bubble in relation to the anchor.
+ enum BubbleAlignment {
+ // The tip of the arrow points to the middle of the anchor.
+ ALIGN_ARROW_TO_MID_ANCHOR,
+ // The edge nearest to the arrow is lined up with the edge of the anchor.
+ ALIGN_EDGE_TO_ANCHOR_EDGE
+ };
+
+ BubbleBorder(ArrowLocation arrow_location, Shadow shadow);
+
+ // Returns the radius of the corner of the border.
+ static int GetCornerRadius() {
+ // We can't safely calculate a border radius by comparing the sizes of the
+ // side and corner images, because either may have been extended in various
+ // directions in order to do more subtle dropshadow fading or other effects.
+ // So we hardcode the most accurate value.
+ return 4;
+ }
+
+ // Sets the location for the arrow.
+ void set_arrow_location(ArrowLocation arrow_location) {
+ arrow_location_ = arrow_location;
+ }
+ ArrowLocation arrow_location() const { return arrow_location_; }
+
+ // Sets the alignment.
+ void set_alignment(BubbleAlignment alignment) { alignment_ = alignment; }
+ BubbleAlignment alignment() const { return alignment_; }
+
+ static ArrowLocation horizontal_mirror(ArrowLocation loc) {
+ return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1);
+ }
+
+ static ArrowLocation vertical_mirror(ArrowLocation loc) {
+ return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 2);
+ }
+
+ static bool has_arrow(ArrowLocation loc) {
+ return loc >= NONE ? false : true;
+ }
+
+ static bool is_arrow_on_left(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 1);
+ }
+
+ static bool is_arrow_on_top(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 2);
+ }
+
+ static bool is_arrow_on_horizontal(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 4);
+ }
+
+ // Sets the background color for the arrow body. This is irrelevant if you do
+ // not also set the arrow location to something other than NONE.
+ void set_background_color(SkColor background_color) {
+ background_color_ = background_color;
+ }
+ SkColor background_color() const { return background_color_; }
+
+ // For borders with an arrow, gives the desired bounds (in screen coordinates)
+ // given the rect to point to and the size of the contained contents. This
+ // depends on the arrow location, so if you change that, you should call this
+ // again to find out the new coordinates.
+ gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
+ const gfx::Size& contents_size) const;
+
+ // Sets a fixed offset for the arrow from the beginning of corresponding edge.
+ // The arrow will still point to the same location but the bubble will shift
+ // location to make that happen. Returns actuall arrow offset, in case of
+ // overflow it differ from desired.
+ int SetArrowOffset(int offset, const gfx::Size& contents_size);
+
+ // Overridden from views::Border:
+ virtual void GetInsets(gfx::Insets* insets) const;
+
+ private:
+ struct BorderImages;
+
+ // Loads images if necessary.
+ static BorderImages* GetBorderImages(Shadow shadow);
+
+ virtual ~BubbleBorder();
+
+ // Overridden from views::Border:
+ virtual void Paint(const views::View& view, gfx::Canvas* canvas) const;
+
+ void DrawEdgeWithArrow(gfx::Canvas* canvas,
+ bool is_horizontal,
+ SkBitmap* edge,
+ SkBitmap* arrow,
+ int start_x,
+ int start_y,
+ int before_arrow,
+ int after_arrow,
+ int offset) const;
+
+ void DrawArrowInterior(gfx::Canvas* canvas,
+ bool is_horizontal,
+ int tip_x,
+ int tip_y,
+ int shift_x,
+ int shift_y) const;
+
+ // Border graphics.
+ struct BorderImages* images_;
+
+ // Image bundles.
+ static struct BorderImages* normal_images_;
+ static struct BorderImages* shadow_images_;
+
+ // Minimal offset of the arrow from the closet edge of bounding rect.
+ int arrow_offset_;
+
+ // If specified, overrides the pre-calculated |arrow_offset_| of the arrow.
+ int override_arrow_offset_;
+
+ ArrowLocation arrow_location_;
+ BubbleAlignment alignment_;
+ SkColor background_color_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
+};
+
+// A Background that clips itself to the specified BubbleBorder and uses
+// the background color of the BubbleBorder.
+class VIEWS_EXPORT BubbleBackground : public views::Background {
+ public:
+ explicit BubbleBackground(BubbleBorder* border) : border_(border) {}
+
+ // Background overrides.
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const;
+
+ private:
+ BubbleBorder* border_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleBackground);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_
diff --git a/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index b3baea4..b3baea4 100644
--- a/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
diff --git a/ui/views/bubble/bubble_delegate.h b/ui/views/bubble/bubble_delegate.h
new file mode 100644
index 0000000..a21bfab
--- /dev/null
+++ b/ui/views/bubble/bubble_delegate.h
@@ -0,0 +1,153 @@
+// Copyright (c) 2011 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 UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
+#define UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
+#pragma once
+
+#include "base/gtest_prod_util.h"
+#include "ui/base/animation/animation_delegate.h"
+#include "views/bubble/bubble_border.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
+
+namespace ui {
+class SlideAnimation;
+} // namespace ui
+
+namespace views {
+
+class BubbleFrameView;
+
+// BubbleDelegateView creates frame and client views for bubble Widgets.
+// BubbleDelegateView itself is the client's contents view.
+//
+///////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
+ public ui::AnimationDelegate,
+ public Widget::Observer {
+ public:
+ BubbleDelegateView();
+ BubbleDelegateView(View* anchor_view,
+ BubbleBorder::ArrowLocation arrow_location,
+ const SkColor& color);
+ virtual ~BubbleDelegateView();
+
+ // Create and initialize the bubble Widget(s) with proper bounds.
+ static Widget* CreateBubble(BubbleDelegateView* bubble_delegate);
+
+ // WidgetDelegate overrides:
+ virtual View* GetInitiallyFocusedView() OVERRIDE;
+ virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE;
+ virtual View* GetContentsView() OVERRIDE;
+ virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
+
+ // Widget::Observer overrides:
+ virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE;
+
+ bool close_on_esc() const { return close_on_esc_; }
+ void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; }
+
+ bool close_on_deactivate() const { return close_on_deactivate_; }
+ void set_close_on_deactivate(bool close_on_deactivate) {
+ close_on_deactivate_ = close_on_deactivate;
+ }
+
+ bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; }
+ void set_allow_bubble_offscreen(bool allow_bubble_offscreen) {
+ allow_bubble_offscreen_ = allow_bubble_offscreen;
+ }
+
+ View* anchor_view() const { return anchor_view_; }
+
+ bool use_focusless() const { return use_focusless_; }
+ void set_use_focusless(bool use_focusless) {
+ use_focusless_ = use_focusless;
+ }
+
+ // Get the arrow's anchor point in screen space.
+ virtual gfx::Point GetAnchorPoint();
+
+ // Get the arrow's location on the bubble.
+ virtual BubbleBorder::ArrowLocation GetArrowLocation() const;
+
+ // Get the color used for the background and border.
+ virtual SkColor GetColor() const;
+
+ // Show the bubble's widget (and |border_widget_| on Windows).
+ void Show();
+
+ // Fade the bubble in or out via Widget transparency.
+ // Fade in calls Widget::Show; fade out calls Widget::Close upon completion.
+ void StartFade(bool fade_in);
+
+ // Reset fade and opacity of bubble. Restore the opacity of the
+ // bubble to the setting before StartFade() was called.
+ void ResetFade();
+
+ protected:
+ // View overrides:
+ virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
+
+ // ui::AnimationDelegate overrides:
+ virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
+ virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
+
+ // Perform view initialization on the contents for bubble sizing.
+ virtual void Init();
+
+ // Resizes and potentially moves the Bubble to best accommodate the
+ // contents preferred size.
+ void SizeToContents();
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, NonClientHitTest);
+ FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate);
+
+ BubbleFrameView* GetBubbleFrameView() const;
+
+ // Get bubble bounds from the anchor point and client view's preferred size.
+ gfx::Rect GetBubbleBounds();
+
+#if defined(OS_WIN) && !defined(USE_AURA)
+ // Get bounds for the Windows-only widget that hosts the bubble's contents.
+ gfx::Rect GetBubbleClientBounds() const;
+#endif
+
+ // Fade animation for bubble.
+ scoped_ptr<ui::SlideAnimation> fade_animation_;
+
+ // Flags controlling bubble closure on the escape key and deactivation.
+ bool close_on_esc_;
+ bool close_on_deactivate_;
+
+ // Whether the bubble is allowed to be displayed offscreen, or if auto
+ // re-positioning should be performed.
+ bool allow_bubble_offscreen_;
+
+ // The view hosting this bubble; the arrow is anchored to this view.
+ View* anchor_view_;
+
+ // The arrow's location on the bubble.
+ BubbleBorder::ArrowLocation arrow_location_;
+
+ // The background color of the bubble.
+ SkColor color_;
+
+ // Original opacity of the bubble.
+ int original_opacity_;
+
+ // The widget hosting the border for this bubble (non-Aura Windows only).
+ Widget* border_widget_;
+
+ // Create a popup window for focusless bubbles on Linux/ChromeOS.
+ // These bubbles are not interactive and should not gain focus.
+ bool use_focusless_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
diff --git a/views/bubble/bubble_delegate_unittest.cc b/ui/views/bubble/bubble_delegate_unittest.cc
index f6d256a..f6d256a 100644
--- a/views/bubble/bubble_delegate_unittest.cc
+++ b/ui/views/bubble/bubble_delegate_unittest.cc
diff --git a/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
index 85e1f6e..85e1f6e 100644
--- a/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
diff --git a/ui/views/bubble/bubble_frame_view.h b/ui/views/bubble/bubble_frame_view.h
new file mode 100644
index 0000000..f134725
--- /dev/null
+++ b/ui/views/bubble/bubble_frame_view.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 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 UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
+#define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
+#pragma once
+
+#include "base/gtest_prod_util.h"
+#include "ui/views/window/non_client_view.h"
+#include "views/bubble/bubble_border.h"
+
+namespace views {
+
+class BorderContentsView;
+
+// BubbleFrameView to render BubbleBorder.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView {
+ public:
+ BubbleFrameView(BubbleBorder::ArrowLocation location,
+ const gfx::Size& client_size,
+ SkColor color,
+ bool allow_bubble_offscreen);
+ virtual ~BubbleFrameView();
+
+ // NonClientFrameView overrides:
+ virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
+ virtual gfx::Rect GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const OVERRIDE;
+ virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
+ virtual void GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) OVERRIDE {}
+ virtual void EnableClose(bool enable) OVERRIDE {}
+ virtual void ResetWindowControls() OVERRIDE {}
+ virtual void UpdateWindowIcon() OVERRIDE {}
+
+ // View overrides:
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ // Accessor for bubble border inside border contents.
+ BubbleBorder* bubble_border() const;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, GetBoundsForClientView);
+
+ BorderContentsView* border_contents_;
+ BubbleBorder::ArrowLocation location_;
+ bool allow_bubble_offscreen_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleFrameView);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
diff --git a/views/bubble/bubble_frame_view_unittest.cc b/ui/views/bubble/bubble_frame_view_unittest.cc
index 6699bfd..6699bfd 100644
--- a/views/bubble/bubble_frame_view_unittest.cc
+++ b/ui/views/bubble/bubble_frame_view_unittest.cc
diff --git a/views/events/event.cc b/ui/views/events/event.cc
index 67d165e..67d165e 100644
--- a/views/events/event.cc
+++ b/ui/views/events/event.cc
diff --git a/ui/views/events/event.h b/ui/views/events/event.h
new file mode 100644
index 0000000..bcf57c5
--- /dev/null
+++ b/ui/views/events/event.h
@@ -0,0 +1,415 @@
+// Copyright (c) 2011 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 UI_VIEWS_EVENTS_EVENT_H_
+#define UI_VIEWS_EVENTS_EVENT_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/time.h"
+#include "ui/base/events.h"
+#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/gfx/point.h"
+#include "views/views_export.h"
+
+namespace ui {
+class OSExchangeData;
+}
+
+#if defined(USE_AURA)
+namespace aura {
+class Event;
+}
+#endif
+
+// TODO(msw): Remove GTK support from views event code when possible.
+#if defined(TOOLKIT_USES_GTK)
+typedef union _GdkEvent GdkEvent;
+#endif
+
+namespace views {
+
+#if defined(USE_AURA)
+typedef aura::Event* NativeEvent;
+#else
+typedef base::NativeEvent NativeEvent;
+#endif
+
+class View;
+
+namespace internal {
+class NativeWidgetView;
+class RootView;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Event class
+//
+// An event encapsulates an input event that can be propagated into view
+// hierarchies. An event has a type, some flags and a time stamp.
+//
+// Each major event type has a corresponding Event subclass.
+//
+// Events are immutable but support copy
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT Event {
+ public:
+ const NativeEvent& native_event() const { return native_event_; }
+#if defined(TOOLKIT_USES_GTK)
+ GdkEvent* gdk_event() const { return gdk_event_; }
+#endif
+ ui::EventType type() const { return type_; }
+ const base::Time& time_stamp() const { return time_stamp_; }
+ int flags() const { return flags_; }
+ void set_flags(int flags) { flags_ = flags; }
+
+ // The following methods return true if the respective keys were pressed at
+ // the time the event was created.
+ bool IsShiftDown() const { return (flags_ & ui::EF_SHIFT_DOWN) != 0; }
+ bool IsControlDown() const { return (flags_ & ui::EF_CONTROL_DOWN) != 0; }
+ bool IsCapsLockDown() const { return (flags_ & ui::EF_CAPS_LOCK_DOWN) != 0; }
+ bool IsAltDown() const { return (flags_ & ui::EF_ALT_DOWN) != 0; }
+
+ bool IsMouseEvent() const {
+ return type_ == ui::ET_MOUSE_PRESSED ||
+ type_ == ui::ET_MOUSE_DRAGGED ||
+ type_ == ui::ET_MOUSE_RELEASED ||
+ type_ == ui::ET_MOUSE_MOVED ||
+ type_ == ui::ET_MOUSE_ENTERED ||
+ type_ == ui::ET_MOUSE_EXITED ||
+ type_ == ui::ET_MOUSEWHEEL;
+ }
+
+ bool IsTouchEvent() const {
+ return type_ == ui::ET_TOUCH_RELEASED ||
+ type_ == ui::ET_TOUCH_PRESSED ||
+ type_ == ui::ET_TOUCH_MOVED ||
+ type_ == ui::ET_TOUCH_STATIONARY ||
+ type_ == ui::ET_TOUCH_CANCELLED;
+ }
+
+ protected:
+ Event(ui::EventType type, int flags);
+ Event(const NativeEvent& native_event, ui::EventType type, int flags);
+#if defined(TOOLKIT_USES_GTK)
+ Event(GdkEvent* gdk_event, ui::EventType type, int flags);
+#endif
+
+ Event(const Event& model)
+ : native_event_(model.native_event()),
+#if defined(TOOLKIT_USES_GTK)
+ gdk_event_(model.gdk_event_),
+#endif
+ type_(model.type()),
+ time_stamp_(model.time_stamp()),
+ flags_(model.flags()) {
+ }
+
+ void set_type(ui::EventType type) { type_ = type; }
+
+ private:
+ void operator=(const Event&);
+
+ NativeEvent native_event_;
+#if defined(TOOLKIT_USES_GTK)
+ GdkEvent* gdk_event_;
+#endif
+ ui::EventType type_;
+ base::Time time_stamp_;
+ int flags_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// LocatedEvent class
+//
+// A generic event that is used for any events that is located at a specific
+// position in the screen.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT LocatedEvent : public Event {
+ public:
+ int x() const { return location_.x(); }
+ int y() const { return location_.y(); }
+ const gfx::Point& location() const { return location_; }
+
+ protected:
+ explicit LocatedEvent(const NativeEvent& native_event);
+#if defined(TOOLKIT_USES_GTK)
+ explicit LocatedEvent(GdkEvent* gdk_event);
+#endif
+
+ // TODO(msw): Kill this legacy constructor when we update uses.
+ // Simple initialization from cracked metadata.
+ LocatedEvent(ui::EventType type, const gfx::Point& location, int flags);
+
+ // Create a new LocatedEvent which is identical to the provided model.
+ // If source / target views are provided, the model location will be converted
+ // from |source| coordinate system to |target| coordinate system.
+ LocatedEvent(const LocatedEvent& model, View* source, View* target);
+
+ // This constructor is to allow converting the location of an event from the
+ // widget's coordinate system to the RootView's coordinate system.
+ LocatedEvent(const LocatedEvent& model, View* root);
+
+ gfx::Point location_;
+};
+
+class TouchEvent;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MouseEvent class
+//
+// A mouse event is used for any input event related to the mouse.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT MouseEvent : public LocatedEvent {
+ public:
+ explicit MouseEvent(const NativeEvent& native_event);
+#if defined(TOOLKIT_USES_GTK)
+ explicit MouseEvent(GdkEvent* gdk_event);
+#endif
+
+ // Create a new MouseEvent which is identical to the provided model.
+ // If source / target views are provided, the model location will be converted
+ // from |source| coordinate system to |target| coordinate system.
+ MouseEvent(const MouseEvent& model, View* source, View* target);
+
+ // Creates a new MouseEvent from a TouchEvent. The location of the TouchEvent
+ // is the same as the MouseEvent. Other attributes (e.g. type, flags) are
+ // mapped from the TouchEvent to appropriate MouseEvent attributes.
+ // GestureManager uses this to convert TouchEvents that are not handled by any
+ // view.
+ explicit MouseEvent(const TouchEvent& touch);
+
+ // TODO(msw): Kill this legacy constructor when we update uses.
+ // Create a new mouse event
+ MouseEvent(ui::EventType type, int x, int y, int flags)
+ : LocatedEvent(type, gfx::Point(x, y), flags) {
+ }
+
+ // Conveniences to quickly test what button is down
+ bool IsOnlyLeftMouseButton() const {
+ return (flags() & ui::EF_LEFT_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_MIDDLE_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
+ }
+
+ bool IsLeftMouseButton() const {
+ return (flags() & ui::EF_LEFT_BUTTON_DOWN) != 0;
+ }
+
+ bool IsOnlyMiddleMouseButton() const {
+ return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
+ }
+
+ bool IsMiddleMouseButton() const {
+ return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) != 0;
+ }
+
+ bool IsOnlyRightMouseButton() const {
+ return (flags() & ui::EF_RIGHT_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN));
+ }
+
+ bool IsRightMouseButton() const {
+ return (flags() & ui::EF_RIGHT_BUTTON_DOWN) != 0;
+ }
+
+ protected:
+ MouseEvent(const MouseEvent& model, View* root)
+ : LocatedEvent(model, root) {
+ }
+
+ private:
+ friend class internal::NativeWidgetView;
+ friend class internal::RootView;
+
+ DISALLOW_COPY_AND_ASSIGN(MouseEvent);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// TouchEvent class
+//
+// A touch event is generated by touch screen and advanced track
+// pad devices. There is a deliberate direct correspondence between
+// TouchEvent and PlatformTouchPoint.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT TouchEvent : public LocatedEvent {
+ public:
+ explicit TouchEvent(const NativeEvent& native_event);
+
+ // Create a new touch event.
+ TouchEvent(ui::EventType type,
+ int x,
+ int y,
+ int flags,
+ int touch_id,
+ float radius_x,
+ float radius_y,
+ float angle,
+ float force);
+
+ // Create a new TouchEvent which is identical to the provided model.
+ // If source / target views are provided, the model location will be converted
+ // from |source| coordinate system to |target| coordinate system.
+ TouchEvent(const TouchEvent& model, View* source, View* target);
+
+ int identity() const { return touch_id_; }
+
+ float radius_x() const { return radius_x_; }
+ float radius_y() const { return radius_y_; }
+ float rotation_angle() const { return rotation_angle_; }
+ float force() const { return force_; }
+
+ private:
+ friend class internal::NativeWidgetView;
+ friend class internal::RootView;
+
+ TouchEvent(const TouchEvent& model, View* root);
+
+ // The identity (typically finger) of the touch starting at 0 and incrementing
+ // for each separable additional touch that the hardware can detect.
+ const int touch_id_;
+
+ // Radius of the X (major) axis of the touch ellipse. 1.0 if unknown.
+ const float radius_x_;
+
+ // Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown.
+ const float radius_y_;
+
+ // Angle of the major axis away from the X axis. Default 0.0.
+ const float rotation_angle_;
+
+ // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
+ const float force_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchEvent);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// KeyEvent class
+//
+// KeyEvent encapsulates keyboard input events - key press and release.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT KeyEvent : public Event {
+ public:
+ explicit KeyEvent(const NativeEvent& native_event);
+#if defined(TOOLKIT_USES_GTK)
+ explicit KeyEvent(GdkEvent* gdk_event);
+#endif
+
+ // Creates a new KeyEvent synthetically (i.e. not in response to an input
+ // event from the host environment). This is typically only used in testing as
+ // some metadata obtainable from the underlying native event is not present.
+ // It's also used by input methods to fabricate keyboard events.
+ KeyEvent(ui::EventType type,
+ ui::KeyboardCode key_code,
+ int event_flags);
+
+ ui::KeyboardCode key_code() const { return key_code_; }
+
+ // These setters allow an I18N virtual keyboard to fabricate a keyboard event
+ // which does not have a corresponding ui::KeyboardCode (example: U+00E1 Latin
+ // small letter A with acute, U+0410 Cyrillic capital letter A.)
+ // GetCharacter() and GetUnmodifiedCharacter() return the character.
+ void set_character(uint16 character) { character_ = character; }
+ void set_unmodified_character(uint16 unmodified_character) {
+ unmodified_character_ = unmodified_character;
+ }
+
+ // Gets the character generated by this key event. It only supports Unicode
+ // BMP characters.
+ uint16 GetCharacter() const;
+
+ // Gets the character generated by this key event ignoring concurrently-held
+ // modifiers (except shift).
+ uint16 GetUnmodifiedCharacter() const;
+
+ private:
+ ui::KeyboardCode key_code_;
+
+ uint16 character_;
+ uint16 unmodified_character_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyEvent);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MouseWheelEvent class
+//
+// A MouseWheelEvent is used to propagate mouse wheel user events.
+// Note: e.GetOffset() > 0 means scroll up / left.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT MouseWheelEvent : public MouseEvent {
+ public:
+ // See |offset| for details.
+ static const int kWheelDelta;
+
+ explicit MouseWheelEvent(const NativeEvent& native_event);
+#if defined(TOOLKIT_USES_GTK)
+ explicit MouseWheelEvent(GdkEvent* gdk_event);
+#endif
+
+ // The amount to scroll. This is in multiples of kWheelDelta.
+ int offset() const { return offset_; }
+
+ private:
+ friend class internal::RootView;
+ friend class internal::NativeWidgetView;
+
+ MouseWheelEvent(const MouseWheelEvent& model, View* root)
+ : MouseEvent(model, root),
+ offset_(model.offset_) {
+ }
+
+ int offset_;
+
+ DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// DropTargetEvent class
+//
+// A DropTargetEvent is sent to the view the mouse is over during a drag and
+// drop operation.
+//
+////////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT DropTargetEvent : public LocatedEvent {
+ public:
+ DropTargetEvent(const ui::OSExchangeData& data,
+ int x,
+ int y,
+ int source_operations)
+ : LocatedEvent(ui::ET_DROP_TARGET_EVENT, gfx::Point(x, y), 0),
+ data_(data),
+ source_operations_(source_operations) {
+ // TODO(msw): Hook up key state flags for CTRL + drag and drop, etc.
+ }
+
+ const ui::OSExchangeData& data() const { return data_; }
+ int source_operations() const { return source_operations_; }
+
+ private:
+ // Data associated with the drag/drop session.
+ const ui::OSExchangeData& data_;
+
+ // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
+ int source_operations_;
+
+ DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_EVENTS_EVENT_H_
diff --git a/views/events/event_aura.cc b/ui/views/events/event_aura.cc
index a4d3169..a4d3169 100644
--- a/views/events/event_aura.cc
+++ b/ui/views/events/event_aura.cc
diff --git a/views/events/event_gtk.cc b/ui/views/events/event_gtk.cc
index fb0c88a..fb0c88a 100644
--- a/views/events/event_gtk.cc
+++ b/ui/views/events/event_gtk.cc
diff --git a/views/events/event_unittest.cc b/ui/views/events/event_unittest.cc
index 211877d..211877d 100644
--- a/views/events/event_unittest.cc
+++ b/ui/views/events/event_unittest.cc
diff --git a/views/events/event_wayland.cc b/ui/views/events/event_wayland.cc
index 44998e6..44998e6 100644
--- a/views/events/event_wayland.cc
+++ b/ui/views/events/event_wayland.cc
diff --git a/views/events/event_win.cc b/ui/views/events/event_win.cc
index 03b855e..03b855e 100644
--- a/views/events/event_win.cc
+++ b/ui/views/events/event_win.cc
diff --git a/views/events/event_x.cc b/ui/views/events/event_x.cc
index 1c9e330..1c9e330 100644
--- a/views/events/event_x.cc
+++ b/ui/views/events/event_x.cc
diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h
new file mode 100644
index 0000000..c0f9591
--- /dev/null
+++ b/ui/views/focus/accelerator_handler.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
+#define UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
+#pragma once
+
+#include "build/build_config.h"
+
+#if defined(TOOLKIT_USES_GTK)
+#include <gdk/gdk.h>
+#endif
+
+#include <set>
+#include <vector>
+
+#include "base/message_loop.h"
+#include "views/views_export.h"
+
+namespace views {
+
+#if defined(TOUCH_UI) || defined(USE_AURA)
+#if defined(USE_X11) && !defined(USE_WAYLAND)
+// Dispatch an XEvent to the RootView. Return true if the event was dispatched
+// and handled, false otherwise.
+bool VIEWS_EXPORT DispatchXEvent(XEvent* xevent);
+#endif // USE_X11 && !USE_WAYLAND
+#endif // TOUCH_UI || USE_AURA
+
+// This class delegates the key messages to the associated FocusManager class
+// for the window that is receiving these messages for accelerator processing.
+class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher {
+ public:
+ AcceleratorHandler();
+
+ // Dispatcher method. This returns true if an accelerator was processed by the
+ // focus manager
+#if defined(OS_WIN)
+ virtual bool Dispatch(const MSG& msg);
+#elif defined(USE_WAYLAND)
+ virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(
+ base::wayland::WaylandEvent* ev);
+#elif defined(TOUCH_UI) || defined(USE_AURA)
+ virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xev);
+#else
+ virtual bool Dispatch(GdkEvent* event);
+#endif
+
+ private:
+#if defined(OS_WIN)
+ // The keys currently pressed and consumed by the FocusManager.
+ std::set<WPARAM> pressed_keys_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorHandler);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
diff --git a/views/focus/accelerator_handler_aura.cc b/ui/views/focus/accelerator_handler_aura.cc
index ab552899..ab552899 100644
--- a/views/focus/accelerator_handler_aura.cc
+++ b/ui/views/focus/accelerator_handler_aura.cc
diff --git a/views/focus/accelerator_handler_gtk.cc b/ui/views/focus/accelerator_handler_gtk.cc
index fab3b86..fab3b86 100644
--- a/views/focus/accelerator_handler_gtk.cc
+++ b/ui/views/focus/accelerator_handler_gtk.cc
diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/ui/views/focus/accelerator_handler_gtk_unittest.cc
index 098325d..098325d 100644
--- a/views/focus/accelerator_handler_gtk_unittest.cc
+++ b/ui/views/focus/accelerator_handler_gtk_unittest.cc
diff --git a/views/focus/accelerator_handler_touch.cc b/ui/views/focus/accelerator_handler_touch.cc
index 1c4c9b3..1c4c9b3 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/ui/views/focus/accelerator_handler_touch.cc
diff --git a/views/focus/accelerator_handler_wayland.cc b/ui/views/focus/accelerator_handler_wayland.cc
index a8963ee..a8963ee 100644
--- a/views/focus/accelerator_handler_wayland.cc
+++ b/ui/views/focus/accelerator_handler_wayland.cc
diff --git a/views/focus/accelerator_handler_win.cc b/ui/views/focus/accelerator_handler_win.cc
index 8f2c8e8..8f2c8e8 100644
--- a/views/focus/accelerator_handler_win.cc
+++ b/ui/views/focus/accelerator_handler_win.cc
diff --git a/views/focus/external_focus_tracker.cc b/ui/views/focus/external_focus_tracker.cc
index 193b57e..193b57e 100644
--- a/views/focus/external_focus_tracker.cc
+++ b/ui/views/focus/external_focus_tracker.cc
diff --git a/ui/views/focus/external_focus_tracker.h b/ui/views/focus/external_focus_tracker.h
new file mode 100644
index 0000000..0ea1479
--- /dev/null
+++ b/ui/views/focus/external_focus_tracker.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
+#define UI_VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
+#pragma once
+
+#include "views/focus/focus_manager.h"
+
+namespace views {
+
+class View;
+class ViewStorage;
+
+// ExternalFocusTracker tracks the last focused view which belongs to the
+// provided focus manager and is not either the provided parent view or one of
+// its descendants. This is generally used if the parent view want to return
+// focus to some other view once it is dismissed. The parent view and the focus
+// manager must exist for the duration of the tracking. If the focus manager
+// must be deleted before this object is deleted, make sure to call
+// SetFocusManager(NULL) first.
+//
+// Typical use: When a view is added to the view hierarchy, it instantiates an
+// ExternalFocusTracker and passes in itself and its focus manager. Then,
+// when that view wants to return focus to the last focused view which is not
+// itself and not a descandant of itself, (usually when it is being closed)
+// it calls FocusLastFocusedExternalView.
+class VIEWS_EXPORT ExternalFocusTracker : public FocusChangeListener {
+ public:
+ ExternalFocusTracker(View* parent_view, FocusManager* focus_manager);
+
+ virtual ~ExternalFocusTracker();
+ // FocusChangeListener implementation.
+ virtual void OnWillChangeFocus(View* focused_before, View* focused_now);
+ virtual void OnDidChangeFocus(View* focused_before, View* focused_now);
+
+ // Focuses last focused view which is not a child of parent view and is not
+ // parent view itself. Returns true if focus for a view was requested, false
+ // otherwise.
+ void FocusLastFocusedExternalView();
+
+ // Sets the focus manager whose focus we are tracking. |focus_manager| can
+ // be NULL, but no focus changes will be tracked. This is useful if the focus
+ // manager went away, but you might later want to start tracking with a new
+ // manager later, or call FocusLastFocusedExternalView to focus the previous
+ // view.
+ void SetFocusManager(FocusManager* focus_manager);
+
+ private:
+ // Store the provided view. This view will be focused when
+ // FocusLastFocusedExternalView is called.
+ void StoreLastFocusedView(View* view);
+
+ // Store the currently focused view for our view manager and register as a
+ // listener for future focus changes.
+ void StartTracking();
+
+ // Focus manager which we are a listener for.
+ FocusManager* focus_manager_;
+
+ // ID of the last focused view, which we store in view_storage_.
+ int last_focused_view_storage_id_;
+
+ // Used to store the last focused view which is not a child of
+ // ExternalFocusTracker.
+ ViewStorage* view_storage_;
+
+ // The parent view of views which we should not track focus changes to. We
+ // also do not track changes to parent_view_ itself.
+ View* parent_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExternalFocusTracker);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
diff --git a/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc
index 3ee0755..3ee0755 100644
--- a/views/focus/focus_manager.cc
+++ b/ui/views/focus/focus_manager.cc
diff --git a/ui/views/focus/focus_manager.h b/ui/views/focus/focus_manager.h
new file mode 100644
index 0000000..0fdecc1
--- /dev/null
+++ b/ui/views/focus/focus_manager.h
@@ -0,0 +1,283 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
+#define UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
+#pragma once
+
+#include <list>
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "ui/base/models/accelerator.h"
+#include "ui/gfx/native_widget_types.h"
+#include "views/views_export.h"
+#include "views/events/event.h"
+
+// The FocusManager class is used to handle focus traversal, store/restore
+// focused views and handle keyboard accelerators.
+//
+// There are 2 types of focus:
+// - the native focus, which is the focus that an gfx::NativeView has.
+// - the view focus, which is the focus that a views::View has.
+//
+// Each native view must register with their Focus Manager so the focus manager
+// gets notified when they are focused (and keeps track of the native focus) and
+// as well so that the tab key events can be intercepted.
+// They can provide when they register a View that is kept in synch in term of
+// focus. This is used in NativeControl for example, where a View wraps an
+// actual native window.
+// This is already done for you if you subclass the NativeControl class or if
+// you use the NativeViewHost class.
+//
+// When creating a top window (derived from views::Widget) that is not a child
+// window, it creates and owns a FocusManager to manage the focus for itself and
+// all its child windows.
+//
+// The FocusTraversable interface exposes the methods a class should implement
+// in order to be able to be focus traversed when tab key is pressed.
+// RootViews implement FocusTraversable.
+// The FocusManager contains a top FocusTraversable instance, which is the top
+// RootView.
+//
+// If you just use views, then the focus traversal is handled for you by the
+// RootView. The default traversal order is the order in which the views have
+// been added to their container. You can modify this order by using the View
+// method SetNextFocusableView().
+//
+// If you are embedding a native view containing a nested RootView (for example
+// by adding a NativeControl that contains a NativeWidgetWin as its native
+// component), then you need to:
+// - override the View::GetFocusTraversable() method in your outer component.
+// It should return the RootView of the inner component. This is used when
+// the focus traversal traverse down the focus hierarchy to enter the nested
+// RootView. In the example mentioned above, the NativeControl overrides
+// GetFocusTraversable() and returns hwnd_view_container_->GetRootView().
+// - call Widget::SetFocusTraversableParent() on the nested RootView and point
+// it to the outer RootView. This is used when the focus goes out of the
+// nested RootView. In the example:
+// hwnd_view_container_->GetWidget()->SetFocusTraversableParent(
+// native_control->GetRootView());
+// - call RootView::SetFocusTraversableParentView() on the nested RootView with
+// the parent view that directly contains the native window. This is needed
+// when traversing up from the nested RootView to know which view to start
+// with when going to the next/previous view.
+// In our example:
+// hwnd_view_container_->GetWidget()->SetFocusTraversableParent(
+// native_control);
+//
+// Note that FocusTraversable do not have to be RootViews: AccessibleToolbarView
+// is FocusTraversable.
+
+namespace ui {
+class AcceleratorTarget;
+class AcceleratorManager;
+}
+
+namespace views {
+
+class FocusSearch;
+class RootView;
+class View;
+class Widget;
+
+// The FocusTraversable interface is used by components that want to process
+// focus traversal events (due to Tab/Shift-Tab key events).
+class VIEWS_EXPORT FocusTraversable {
+ public:
+ // Return a FocusSearch object that implements the algorithm to find
+ // the next or previous focusable view.
+ virtual FocusSearch* GetFocusSearch() = 0;
+
+ // Should return the parent FocusTraversable.
+ // The top RootView which is the top FocusTraversable returns NULL.
+ virtual FocusTraversable* GetFocusTraversableParent() = 0;
+
+ // This should return the View this FocusTraversable belongs to.
+ // It is used when walking up the view hierarchy tree to find which view
+ // should be used as the starting view for finding the next/previous view.
+ virtual View* GetFocusTraversableParentView() = 0;
+
+ protected:
+ virtual ~FocusTraversable() {}
+};
+
+// This interface should be implemented by classes that want to be notified when
+// the focus is about to change. See the Add/RemoveFocusChangeListener methods.
+class VIEWS_EXPORT FocusChangeListener {
+ public:
+ // No change to focus state has occurred yet when this function is called.
+ virtual void OnWillChangeFocus(View* focused_before, View* focused_now) = 0;
+
+ // Called after focus state has changed.
+ virtual void OnDidChangeFocus(View* focused_before, View* focused_now) = 0;
+
+ protected:
+ virtual ~FocusChangeListener() {}
+};
+
+class VIEWS_EXPORT FocusManager {
+ public:
+ // The reason why the focus changed.
+ enum FocusChangeReason {
+ // The focus changed because the user traversed focusable views using
+ // keys like Tab or Shift+Tab.
+ kReasonFocusTraversal,
+
+ // The focus changed due to restoring the focus.
+ kReasonFocusRestore,
+
+ // The focus changed due to a click or a shortcut to jump directly to
+ // a particular view.
+ kReasonDirectFocusChange
+ };
+
+ explicit FocusManager(Widget* widget);
+ virtual ~FocusManager();
+
+ // Processes the passed key event for accelerators and tab traversal.
+ // Returns false if the event has been consumed and should not be processed
+ // further.
+ bool OnKeyEvent(const KeyEvent& event);
+
+ // Returns true is the specified is part of the hierarchy of the window
+ // associated with this FocusManager.
+ bool ContainsView(View* view);
+
+ // Advances the focus (backward if reverse is true).
+ void AdvanceFocus(bool reverse);
+
+ // The FocusManager keeps track of the focused view within a RootView.
+ View* GetFocusedView() { return focused_view_; }
+ const View* GetFocusedView() const { return focused_view_; }
+
+ // Low-level methods to force the focus to change (and optionally provide
+ // a reason). If the focus change should only happen if the view is
+ // currenty focusable, enabled, and visible, call view->RequestFocus().
+ void SetFocusedViewWithReason(View* view, FocusChangeReason reason);
+ void SetFocusedView(View* view) {
+ SetFocusedViewWithReason(view, kReasonDirectFocusChange);
+ }
+
+ // Get the reason why the focus most recently changed.
+ FocusChangeReason focus_change_reason() const {
+ return focus_change_reason_;
+ }
+
+ // Clears the focused view. The window associated with the top root view gets
+ // the native focus (so we still get keyboard events).
+ void ClearFocus();
+
+ // Validates the focused view, clearing it if the window it belongs too is not
+ // attached to the window hierarchy anymore.
+ void ValidateFocusedView();
+
+ // Stores and restores the focused view. Used when the window becomes
+ // active/inactive.
+ void StoreFocusedView();
+ void RestoreFocusedView();
+
+ // Clears the stored focused view.
+ void ClearStoredFocusedView();
+
+ // Returns true if in the process of changing the focused view.
+ bool is_changing_focus() const { return is_changing_focus_; }
+
+ // Register a keyboard accelerator for the specified target. If multiple
+ // targets are registered for an accelerator, a target registered later has
+ // higher priority.
+ // Note that we are currently limited to accelerators that are either:
+ // - a key combination including Ctrl or Alt
+ // - the escape key
+ // - the enter key
+ // - any F key (F1, F2, F3 ...)
+ // - any browser specific keys (as available on special keyboards)
+ void RegisterAccelerator(const ui::Accelerator& accelerator,
+ ui::AcceleratorTarget* target);
+
+ // Unregister the specified keyboard accelerator for the specified target.
+ void UnregisterAccelerator(const ui::Accelerator& accelerator,
+ ui::AcceleratorTarget* target);
+
+ // Unregister all keyboard accelerator for the specified target.
+ void UnregisterAccelerators(ui::AcceleratorTarget* target);
+
+ // Activate the target associated with the specified accelerator.
+ // First, AcceleratorPressed handler of the most recently registered target
+ // is called, and if that handler processes the event (i.e. returns true),
+ // this method immediately returns. If not, we do the same thing on the next
+ // target, and so on.
+ // Returns true if an accelerator was activated.
+ bool ProcessAccelerator(const ui::Accelerator& accelerator);
+
+ // Called by a RootView when a view within its hierarchy is removed
+ // from its parent. This will only be called by a RootView in a
+ // hierarchy of Widgets that this FocusManager is attached to the
+ // parent Widget of.
+ void ViewRemoved(View* removed);
+
+ // Adds/removes a listener. The FocusChangeListener is notified every time
+ // the focused view is about to change.
+ void AddFocusChangeListener(FocusChangeListener* listener);
+ void RemoveFocusChangeListener(FocusChangeListener* listener);
+
+ // Returns the AcceleratorTarget that should be activated for the specified
+ // keyboard accelerator, or NULL if no view is registered for that keyboard
+ // accelerator.
+ ui::AcceleratorTarget* GetCurrentTargetForAccelerator(
+ const ui::Accelerator& accelertor) const;
+
+ // Sets the focus to the specified native view.
+ virtual void FocusNativeView(gfx::NativeView native_view);
+
+ // Clears the native view having the focus.
+ virtual void ClearNativeFocus();
+
+ // Convenience method that returns true if the passed |key_event| should
+ // trigger tab traversal (if it is a TAB key press with or without SHIFT
+ // pressed).
+ static bool IsTabTraversalKeyEvent(const KeyEvent& key_event);
+
+ private:
+ // Returns the next focusable view.
+ View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop);
+
+ // Returns the focusable view found in the FocusTraversable specified starting
+ // at the specified view. This traverses down along the FocusTraversable
+ // hierarchy.
+ // Returns NULL if no focusable view were found.
+ View* FindFocusableView(FocusTraversable* focus_traversable,
+ View* starting_view,
+ bool reverse);
+
+ // The top-level Widget this FocusManager is associated with.
+ Widget* widget_;
+
+ // The view that currently is focused.
+ View* focused_view_;
+
+ // The AcceleratorManager this FocusManager is associated with.
+ scoped_ptr<ui::AcceleratorManager> accelerator_manager_;
+
+ // The storage id used in the ViewStorage to store/restore the view that last
+ // had focus.
+ int stored_focused_view_storage_id_;
+
+ // The reason why the focus most recently changed.
+ FocusChangeReason focus_change_reason_;
+
+ // The list of registered FocusChange listeners.
+ ObserverList<FocusChangeListener, true> focus_change_listeners_;
+
+ // See description above getter.
+ bool is_changing_focus_;
+
+ DISALLOW_COPY_AND_ASSIGN(FocusManager);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
diff --git a/views/focus/focus_manager_factory.cc b/ui/views/focus/focus_manager_factory.cc
index 457f60b..457f60b 100644
--- a/views/focus/focus_manager_factory.cc
+++ b/ui/views/focus/focus_manager_factory.cc
diff --git a/ui/views/focus/focus_manager_factory.h b/ui/views/focus/focus_manager_factory.h
new file mode 100644
index 0000000..7aae11d
--- /dev/null
+++ b/ui/views/focus/focus_manager_factory.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_
+#define UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "views/views_export.h"
+
+namespace views {
+
+class FocusManager;
+class Widget;
+
+// A factory to create FocusManager. This is used in unit tests
+// to inject a custom factory.
+class VIEWS_EXPORT FocusManagerFactory {
+ public:
+ // Create a FocusManager for the given |widget| using installe Factory.
+ static FocusManager* Create(Widget* widget);
+
+ // Installs FocusManagerFactory. If |factory| is NULL, it resets
+ // to the default factory which creates plain FocusManager.
+ static void Install(FocusManagerFactory* factory);
+
+ protected:
+ FocusManagerFactory();
+ virtual ~FocusManagerFactory();
+
+ // Create a FocusManager for the given |widget|.
+ virtual FocusManager* CreateFocusManager(Widget* widget) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FocusManagerFactory);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_
diff --git a/views/focus/focus_manager_unittest.cc b/ui/views/focus/focus_manager_unittest.cc
index d4372f2..d4372f2 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/ui/views/focus/focus_manager_unittest.cc
diff --git a/views/focus/focus_search.cc b/ui/views/focus/focus_search.cc
index cbb95c5..eac3f21 100644
--- a/views/focus/focus_search.cc
+++ b/ui/views/focus/focus_search.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
diff --git a/ui/views/focus/focus_search.h b/ui/views/focus/focus_search.h
new file mode 100644
index 0000000..9fe37a0
--- /dev/null
+++ b/ui/views/focus/focus_search.h
@@ -0,0 +1,122 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_FOCUS_SEARCH_H_
+#define UI_VIEWS_FOCUS_FOCUS_SEARCH_H_
+#pragma once
+
+#include "views/view.h"
+
+namespace views {
+
+class FocusTraversable;
+
+// FocusSearch is an object that implements the algorithm to find the
+// next view to focus.
+class VIEWS_EXPORT FocusSearch {
+ public:
+ // The direction in which the focus traversal is going.
+ // TODO (jcampan): add support for lateral (left, right) focus traversal. The
+ // goal is to switch to focusable views on the same level when using the arrow
+ // keys (ala Windows: in a dialog box, arrow keys typically move between the
+ // dialog OK, Cancel buttons).
+ enum Direction {
+ UP = 0,
+ DOWN
+ };
+
+ // Constructor.
+ // - |root| is the root of the view hierarchy to traverse. Focus will be
+ // trapped inside.
+ // - |cycle| should be true if you want FindNextFocusableView to cycle back
+ // to the first view within this root when the traversal reaches
+ // the end. If this is true, then if you pass a valid starting
+ // view to FindNextFocusableView you will always get a valid view
+ // out, even if it's the same view.
+ // - |accessibility_mode| should be true if full keyboard accessibility is
+ // needed and you want to check IsAccessibilityFocusableInRootView(),
+ // rather than IsFocusableInRootView().
+ FocusSearch(View* root, bool cycle, bool accessibility_mode);
+ virtual ~FocusSearch() {}
+
+ // Finds the next view that should be focused and returns it. If a
+ // FocusTraversable is found while searching for the focusable view,
+ // returns NULL and sets |focus_traversable| to the FocusTraversable
+ // and |focus_traversable_view| to the view associated with the
+ // FocusTraversable.
+ //
+ // Return NULL if the end of the focus loop is reached, unless this object
+ // was initialized with |cycle|=true, in which case it goes back to the
+ // beginning when it reaches the end of the traversal.
+ // - |starting_view| is the view that should be used as the starting point
+ // when looking for the previous/next view. It may be NULL (in which case
+ // the first/last view should be used depending if normal/reverse).
+ // - |reverse| whether we should find the next (reverse is false) or the
+ // previous (reverse is true) view.
+ // - |direction| specifies whether we are traversing down (meaning we should
+ // look into child views) or traversing up (don't look at child views).
+ // - |check_starting_view| is true if starting_view may obtain the next focus.
+ // - |focus_traversable| is set to the focus traversable that should be
+ // traversed if one is found (in which case the call returns NULL).
+ // - |focus_traversable_view| is set to the view associated with the
+ // FocusTraversable set in the previous parameter (it is used as the
+ // starting view when looking for the next focusable view).
+ virtual View* FindNextFocusableView(View* starting_view,
+ bool reverse,
+ Direction direction,
+ bool check_starting_view,
+ FocusTraversable** focus_traversable,
+ View** focus_traversable_view);
+
+ private:
+ // Convenience method that returns true if a view is focusable and does not
+ // belong to the specified group.
+ bool IsViewFocusableCandidate(View* v, int skip_group_id);
+
+ // Convenience method; returns true if a view is not NULL and is focusable
+ // (checking IsAccessibilityFocusableInRootView() if accessibility_mode_ is
+ // true).
+ bool IsFocusable(View* v);
+
+ // Returns the view selected for the group of the selected view. If the view
+ // does not belong to a group or if no view is selected in the group, the
+ // specified view is returned.
+ View* FindSelectedViewForGroup(View* view);
+
+ // Get the parent, but stay within the root. Returns NULL if asked for
+ // the parent of root_.
+ View* GetParent(View* view);
+
+ // Returns the next focusable view or view containing a FocusTraversable
+ // (NULL if none was found), starting at the starting_view.
+ // |check_starting_view|, |can_go_up| and |can_go_down| controls the
+ // traversal of the views hierarchy. |skip_group_id| specifies a group_id,
+ // -1 means no group. All views from a group are traversed in one pass.
+ View* FindNextFocusableViewImpl(View* starting_view,
+ bool check_starting_view,
+ bool can_go_up,
+ bool can_go_down,
+ int skip_group_id,
+ FocusTraversable** focus_traversable,
+ View** focus_traversable_view);
+
+ // Same as FindNextFocusableViewImpl but returns the previous focusable view.
+ View* FindPreviousFocusableViewImpl(View* starting_view,
+ bool check_starting_view,
+ bool can_go_up,
+ bool can_go_down,
+ int skip_group_id,
+ FocusTraversable** focus_traversable,
+ View** focus_traversable_view);
+
+ View* root_;
+ bool cycle_;
+ bool accessibility_mode_;
+
+ DISALLOW_COPY_AND_ASSIGN(FocusSearch);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_FOCUS_SEARCH_H_
diff --git a/views/focus/view_storage.cc b/ui/views/focus/view_storage.cc
index 17d3f8e..3b9ec10 100644
--- a/views/focus/view_storage.cc
+++ b/ui/views/focus/view_storage.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
diff --git a/ui/views/focus/view_storage.h b/ui/views/focus/view_storage.h
new file mode 100644
index 0000000..7d748e2
--- /dev/null
+++ b/ui/views/focus/view_storage.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_VIEW_STORAGE_H_
+#define UI_VIEWS_FOCUS_VIEW_STORAGE_H_
+#pragma once
+
+#include "base/memory/singleton.h"
+#include "views/view.h"
+
+// This class is a simple storage place for storing/retrieving views. It is
+// used for example in the FocusManager to store/restore focused views when the
+// main window becomes active/inactive.
+// It automatically removes a view from the storage if the view is removed from
+// the tree hierarchy.
+//
+// To use it, you first need to create a view storage id that can then be used
+// to store/retrieve views.
+
+namespace views {
+
+class VIEWS_EXPORT ViewStorage {
+ public:
+ // Returns the global ViewStorage instance.
+ // It is guaranted to be non NULL.
+ static ViewStorage* GetInstance();
+
+ // Returns a unique storage id that can be used to store/retrieve views.
+ int CreateStorageID();
+
+ // Associates |view| with the specified |storage_id|.
+ void StoreView(int storage_id, View* view);
+
+ // Returns the view associated with |storage_id| if any, NULL otherwise.
+ View* RetrieveView(int storage_id);
+
+ // Removes the view associated with |storage_id| if any.
+ void RemoveView(int storage_id);
+
+ // Notifies the ViewStorage that a view was removed from its parent somewhere.
+ void ViewRemoved(View* removed);
+
+ size_t view_count() const { return view_to_ids_.size(); }
+
+ private:
+ friend struct DefaultSingletonTraits<ViewStorage>;
+
+ ViewStorage();
+ ~ViewStorage();
+
+ // Removes the view associated with |storage_id|. If |remove_all_ids| is true,
+ // all other mapping pointing to the same view are removed as well.
+ void EraseView(int storage_id, bool remove_all_ids);
+
+ // Next id for the view storage.
+ int view_storage_next_id_;
+
+ // The association id to View used for the view storage.
+ std::map<int, View*> id_to_view_;
+
+ // Association View to id, used to speed up view notification removal.
+ std::map<View*, std::vector<int>*> view_to_ids_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewStorage);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_VIEW_STORAGE_H_
diff --git a/views/focus/widget_focus_manager.cc b/ui/views/focus/widget_focus_manager.cc
index 57cd2cd..57cd2cd 100644
--- a/views/focus/widget_focus_manager.cc
+++ b/ui/views/focus/widget_focus_manager.cc
diff --git a/ui/views/focus/widget_focus_manager.h b/ui/views/focus/widget_focus_manager.h
new file mode 100644
index 0000000..7a0143b
--- /dev/null
+++ b/ui/views/focus/widget_focus_manager.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 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 UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_
+#define UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/observer_list.h"
+#include "ui/gfx/native_widget_types.h"
+#include "views/views_export.h"
+
+template <typename T> struct DefaultSingletonTraits;
+
+namespace views {
+
+// This interface should be implemented by classes that want to be notified when
+// the native focus is about to change. Listeners implementing this interface
+// will be invoked for all native focus changes across the entire Chrome
+// application. FocusChangeListeners are only called for changes within the
+// children of a single top-level native-view.
+class WidgetFocusChangeListener {
+ public:
+ virtual void OnNativeFocusChange(gfx::NativeView focused_before,
+ gfx::NativeView focused_now) = 0;
+
+ protected:
+ virtual ~WidgetFocusChangeListener() {}
+};
+
+class VIEWS_EXPORT WidgetFocusManager {
+ public:
+ // Returns the singleton instance.
+ static WidgetFocusManager* GetInstance();
+
+ // Adds/removes a WidgetFocusChangeListener |listener| to the set of
+ // active listeners.
+ void AddFocusChangeListener(WidgetFocusChangeListener* listener);
+ void RemoveFocusChangeListener(WidgetFocusChangeListener* listener);
+
+ // To be called when native-focus shifts from |focused_before| to
+ // |focused_now|.
+ // TODO(port) : Invocations to this routine are only implemented for
+ // the Win32 platform. Calls need to be placed appropriately for
+ // non-Windows environments.
+ void OnWidgetFocusEvent(gfx::NativeView focused_before,
+ gfx::NativeView focused_now);
+
+ // Enable/Disable notification of registered listeners during calls
+ // to OnWidgetFocusEvent. Used to prevent unwanted focus changes from
+ // propagating notifications.
+ void EnableNotifications() { enabled_ = true; }
+ void DisableNotifications() { enabled_ = false; }
+
+ private:
+ friend struct DefaultSingletonTraits<WidgetFocusManager>;
+
+ WidgetFocusManager();
+ ~WidgetFocusManager();
+
+ ObserverList<WidgetFocusChangeListener> focus_change_listeners_;
+
+ bool enabled_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetFocusManager);
+};
+
+// A basic helper class that is used to disable native focus change
+// notifications within a scope.
+class VIEWS_EXPORT AutoNativeNotificationDisabler {
+ public:
+ AutoNativeNotificationDisabler();
+ ~AutoNativeNotificationDisabler();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_
diff --git a/views/layout/box_layout.cc b/ui/views/layout/box_layout.cc
index 5441e87..5441e87 100644
--- a/views/layout/box_layout.cc
+++ b/ui/views/layout/box_layout.cc
diff --git a/ui/views/layout/box_layout.h b/ui/views/layout/box_layout.h
new file mode 100644
index 0000000..81e5a94
--- /dev/null
+++ b/ui/views/layout/box_layout.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2011 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 UI_VIEWS_LAYOUT_BOX_LAYOUT_H_
+#define UI_VIEWS_LAYOUT_BOX_LAYOUT_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "views/layout/layout_manager.h"
+
+namespace gfx {
+class Size;
+}
+
+namespace views {
+
+class View;
+
+// A Layout manager that arranges child views vertically or horizontally in a
+// side-by-side fashion with spacing around and between the child views. The
+// child views are always sized according to their preferred size. If the
+// host's bounds provide insufficient space, child views will be clamped.
+// Excess space will not be distributed.
+class VIEWS_EXPORT BoxLayout : public LayoutManager {
+ public:
+ enum Orientation {
+ kHorizontal,
+ kVertical,
+ };
+
+ // Use |inside_border_horizontal_spacing| and
+ // |inside_border_vertical_spacing| to add additional space between the child
+ // view area and the host view border. |between_child_spacing| controls the
+ // space in between child views.
+ BoxLayout(Orientation orientation,
+ int inside_border_horizontal_spacing,
+ int inside_border_vertical_spacing,
+ int between_child_spacing);
+ virtual ~BoxLayout();
+
+ // Overridden from views::LayoutManager:
+ virtual void Layout(View* host) OVERRIDE;
+ virtual gfx::Size GetPreferredSize(View* host) OVERRIDE;
+
+ private:
+ const Orientation orientation_;
+
+ // Spacing between child views and host view border.
+ const int inside_border_horizontal_spacing_;
+ const int inside_border_vertical_spacing_;
+
+ // Spacing to put in between child views.
+ const int between_child_spacing_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_LAYOUT_BOX_LAYOUT_H_
diff --git a/views/layout/box_layout_unittest.cc b/ui/views/layout/box_layout_unittest.cc
index 12ea2b5..12ea2b5 100644
--- a/views/layout/box_layout_unittest.cc
+++ b/ui/views/layout/box_layout_unittest.cc
diff --git a/views/layout/fill_layout.cc b/ui/views/layout/fill_layout.cc
index 13fbcce..13fbcce 100644
--- a/views/layout/fill_layout.cc
+++ b/ui/views/layout/fill_layout.cc
diff --git a/ui/views/layout/fill_layout.h b/ui/views/layout/fill_layout.h
new file mode 100644
index 0000000..604d9b5
--- /dev/null
+++ b/ui/views/layout/fill_layout.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 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 UI_VIEWS_LAYOUT_FILL_LAYOUT_H_
+#define UI_VIEWS_LAYOUT_FILL_LAYOUT_H_
+#pragma once
+
+#include "views/layout/layout_manager.h"
+#include "views/view.h"
+
+namespace views {
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// FillLayout
+// A simple LayoutManager that causes the associated view's one child to be
+// sized to match the bounds of its parent.
+//
+///////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT FillLayout : public LayoutManager {
+ public:
+ FillLayout();
+ virtual ~FillLayout();
+
+ // Overridden from LayoutManager:
+ virtual void Layout(View* host);
+ virtual gfx::Size GetPreferredSize(View* host);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FillLayout);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_LAYOUT_FILL_LAYOUT_H_
diff --git a/views/layout/grid_layout.cc b/ui/views/layout/grid_layout.cc
index 55a50ceb..55a50ceb 100644
--- a/views/layout/grid_layout.cc
+++ b/ui/views/layout/grid_layout.cc
diff --git a/ui/views/layout/grid_layout.h b/ui/views/layout/grid_layout.h
new file mode 100644
index 0000000..6c38585
--- /dev/null
+++ b/ui/views/layout/grid_layout.h
@@ -0,0 +1,371 @@
+// Copyright (c) 2011 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 UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
+#define UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "views/layout/layout_manager.h"
+#include "views/view.h"
+
+namespace gfx {
+class Insets;
+}
+
+// GridLayout is a LayoutManager that positions child Views in a grid. You
+// define the structure of the Grid first, then add the Views.
+// The following creates a trivial grid with two columns separated by
+// a column with padding:
+// ColumnSet* columns = layout->AddColumnSet(0); // Give this column an
+// // identifier of 0.
+// columns->AddColumn(FILL, // Views are horizontally resized to fill column.
+// FILL, // Views starting in this column are vertically
+// // resized.
+// 1, // This column has a resize weight of 1.
+// USE_PREF, // Use the preferred size of the view.
+// 0, // Ignored for USE_PREF.
+// 0); // A minimum width of 0.
+// columns->AddPaddingColumn(0, // The padding column is not resizable.
+// 10); // And has a width of 10 pixels.
+// columns->AddColumn(FILL, FILL, 0, USE_PREF, 0, 0);
+// Now add the views:
+// // First start a row.
+// layout->StartRow(0, // This row isn't vertically resizable.
+// 0); // The column set to use for this row.
+// layout->AddView(v1);
+// Notice you need not skip over padding columns, that's done for you.
+// layout->AddView(v2);
+//
+// When adding a Column you give it the default alignment for all views
+// originating in that column. You can override this for specific views
+// when adding them. For example, the following forces a View to have
+// a horizontal and vertical alignment of leading regardless of that defined
+// for the column:
+// layout->AddView(v1, 1, 1, LEADING, LEADING);
+//
+// If the View using GridLayout is given a size bigger than the preferred,
+// columns and rows with a resize percent > 0 are resized. Each column/row
+// is given resize_percent / total_resize_percent * extra_pixels extra
+// pixels. Only Views with an Alignment of FILL are given extra space, others
+// are aligned in the provided space.
+//
+// GridLayout allows you to define multiple column sets. When you start a
+// new row you specify the id of the column set the row is to use.
+//
+// GridLayout allows you to force columns to have the same width. This is
+// done using the LinkColumnSizes method.
+//
+// AddView takes care of adding the View to the View the GridLayout was
+// created with.
+namespace views {
+
+class Column;
+class ColumnSet;
+class Row;
+class View;
+
+struct ViewState;
+
+class VIEWS_EXPORT GridLayout : public LayoutManager {
+ public:
+ // An enumeration of the possible alignments supported by GridLayout.
+ enum Alignment {
+ // Leading equates to left along the horizontal axis, and top along the
+ // vertical axis.
+ LEADING,
+
+ // Centers the view along the axis.
+ CENTER,
+
+ // Trailing equals to right along the horizontal axis, and bottom along
+ // the vertical axis.
+ TRAILING,
+
+ // The view is resized to fill the space.
+ FILL,
+
+ // The view is aligned along the baseline. This is only valid for the
+ // vertical axis.
+ BASELINE
+ };
+
+ // An enumeration of the possible ways the size of a column may be obtained.
+ enum SizeType {
+ // The column size is fixed.
+ FIXED,
+
+ // The preferred size of the view is used to determine the column size.
+ USE_PREF
+ };
+
+ explicit GridLayout(View* host);
+ virtual ~GridLayout();
+
+ // Creates a GridLayout with kPanel*Margin insets.
+ static GridLayout* CreatePanel(View* host);
+
+ // Sets the insets. All views are placed relative to these offsets.
+ void SetInsets(int top, int left, int bottom, int right);
+ void SetInsets(const gfx::Insets& insets);
+
+ // Creates a new column set with the specified id and returns it.
+ // The id is later used when starting a new row.
+ // GridLayout takes ownership of the ColumnSet and will delete it when
+ // the GridLayout is deleted.
+ ColumnSet* AddColumnSet(int id);
+
+ // Adds a padding row. Padding rows typically don't have any views, and
+ // but are used to provide vertical white space between views.
+ // Size specifies the height of the row.
+ void AddPaddingRow(float vertical_resize, int size);
+
+ // A convenience for AddPaddingRow followed by StartRow.
+ void StartRowWithPadding(float vertical_resize, int column_set_id,
+ float padding_resize, int padding);
+
+ // Starts a new row with the specified column set.
+ void StartRow(float vertical_resize, int column_set_id);
+
+ // Advances past columns. Use this when the current column should not
+ // contain any views.
+ void SkipColumns(int col_count);
+
+ // Adds a view using the default alignment from the column. The added
+ // view has a column and row span of 1.
+ // As a convenience this adds the view to the host. The view becomes owned
+ // by the host, and NOT this GridLayout.
+ void AddView(View* view);
+
+ // Adds a view using the default alignment from the column.
+ // As a convenience this adds the view to the host. The view becomes owned
+ // by the host, and NOT this GridLayout.
+ void AddView(View* view, int col_span, int row_span);
+
+ // Adds a view with the specified alignment and spans.
+ // As a convenience this adds the view to the host. The view becomes owned
+ // by the host, and NOT this GridLayout.
+ void AddView(View* view, int col_span, int row_span, Alignment h_align,
+ Alignment v_align);
+
+ // Adds a view with the specified alignment and spans. If
+ // pref_width/pref_height is > 0 then the preferred width/height of the view
+ // is fixed to the specified value.
+ // As a convenience this adds the view to the host. The view becomes owned
+ // by the host, and NOT this GridLayout.
+ void AddView(View* view, int col_span, int row_span,
+ Alignment h_align, Alignment v_align,
+ int pref_width, int pref_height);
+
+ // Notification we've been installed on a particular host. Checks that host
+ // is the same as the View supplied in the constructor.
+ virtual void Installed(View* host);
+
+ // Notification we've been uninstalled on a particular host. Checks that host
+ // is the same as the View supplied in the constructor.
+ virtual void Uninstalled(View* host);
+
+ // Notification that a view has been added.
+ virtual void ViewAdded(View* host, View* view);
+
+ // Notification that a view has been removed.
+ virtual void ViewRemoved(View* host, View* view);
+
+ // Layouts out the components.
+ virtual void Layout(View* host);
+
+ // Returns the preferred size for the GridLayout.
+ virtual gfx::Size GetPreferredSize(View* host);
+
+ virtual int GetPreferredHeightForWidth(View* host, int width);
+
+ private:
+ // As both Layout and GetPreferredSize need to do nearly the same thing,
+ // they both call into this method. This sizes the Columns/Rows as
+ // appropriate. If layout is true, width/height give the width/height the
+ // of the host, otherwise they are ignored.
+ void SizeRowsAndColumns(bool layout, int width, int height, gfx::Size* pref);
+
+ // Calculates the master columns of all the column sets. See Column for
+ // a description of what a master column is.
+ void CalculateMasterColumnsIfNecessary();
+
+ // This is called internally from AddView. It adds the ViewState to the
+ // appropriate structures, and updates internal fields such as next_column_.
+ void AddViewState(ViewState* view_state);
+
+ // Returns the column set for the specified id, or NULL if one doesn't exist.
+ ColumnSet* GetColumnSet(int id);
+
+ // Adds the Row to rows_, as well as updating next_column_,
+ // current_row_col_set ...
+ void AddRow(Row* row);
+
+ // As the name says, updates the remaining_height of the ViewState for
+ // all Rows the supplied ViewState touches.
+ void UpdateRemainingHeightFromRows(ViewState* state);
+
+ // If the view state's remaining height is > 0, it is distributed among
+ // the rows the view state touches. This is used during layout to make
+ // sure the Rows can accommodate a view.
+ void DistributeRemainingHeight(ViewState* state);
+
+ // Advances next_column_ past any padding columns.
+ void SkipPaddingColumns();
+
+ // Returns the column set of the last non-padding row.
+ ColumnSet* GetLastValidColumnSet();
+
+ // The view we were created with. We don't own this.
+ View* const host_;
+
+ // Whether or not we've calculated the master/linked columns.
+ bool calculated_master_columns_;
+
+ // Used to verify a view isn't added with a row span that expands into
+ // another column structure.
+ int remaining_row_span_;
+
+ // Current row.
+ int current_row_;
+
+ // Current column.
+ int next_column_;
+
+ // Column set for the current row. This is null for padding rows.
+ ColumnSet* current_row_col_set_;
+
+ // Insets.
+ int top_inset_;
+ int bottom_inset_;
+ int left_inset_;
+ int right_inset_;
+
+ // Set to true when adding a View.
+ bool adding_view_;
+
+ // ViewStates. This is ordered by row_span in ascending order.
+ std::vector<ViewState*> view_states_;
+
+ // ColumnSets.
+ std::vector<ColumnSet*> column_sets_;
+
+ // Rows.
+ std::vector<Row*> rows_;
+
+ DISALLOW_COPY_AND_ASSIGN(GridLayout);
+};
+
+// ColumnSet is used to define a set of columns. GridLayout may have any
+// number of ColumnSets. You don't create a ColumnSet directly, instead
+// use the AddColumnSet method of GridLayout.
+class VIEWS_EXPORT ColumnSet {
+ public:
+ ~ColumnSet();
+
+ // Adds a column for padding. When adding views, padding columns are
+ // automatically skipped. For example, if you create a column set with
+ // two columns separated by a padding column, the first AddView automatically
+ // skips past the padding column. That is, to add two views, do:
+ // layout->AddView(v1); layout->AddView(v2);, not:
+ // layout->AddView(v1); layout->SkipColumns(1); layout->AddView(v2);
+ void AddPaddingColumn(float resize_percent, int width);
+
+ // Adds a column. The alignment gives the default alignment for views added
+ // with no explicit alignment. fixed_width gives a specific width for the
+ // column, and is only used if size_type == FIXED. min_width gives the
+ // minimum width for the column.
+ //
+ // If none of the columns in a columnset are resizable, the views are only
+ // made as wide as the widest views in each column, even if extra space is
+ // provided. In other words, GridLayout does not automatically resize views
+ // unless the column is marked as resizable.
+ void AddColumn(GridLayout::Alignment h_align,
+ GridLayout::Alignment v_align,
+ float resize_percent,
+ GridLayout::SizeType size_type,
+ int fixed_width,
+ int min_width);
+
+ // Forces the specified columns to have the same size. The size of
+ // linked columns is that of the max of the specified columns. This
+ // must end with -1. For example, the following forces the first and
+ // second column to have the same size:
+ // LinkColumnSizes(0, 1, -1);
+ void LinkColumnSizes(int first, ...);
+
+ // ID of this ColumnSet.
+ int id() const { return id_; }
+
+ int num_columns() { return static_cast<int>(columns_.size()); }
+
+ private:
+ friend class GridLayout;
+
+ explicit ColumnSet(int id);
+
+ void AddColumn(GridLayout::Alignment h_align,
+ GridLayout::Alignment v_align,
+ float resize_percent,
+ GridLayout::SizeType size_type,
+ int fixed_width,
+ int min_width,
+ bool is_padding);
+
+ void AddViewState(ViewState* view_state);
+
+ // Set description of these.
+ void CalculateMasterColumns();
+ void AccumulateMasterColumns();
+
+ // Sets the size of each linked column to be the same.
+ void UnifySameSizedColumnSizes();
+
+ // Updates the remaining width field of the ViewState from that of the
+ // columns the view spans.
+ void UpdateRemainingWidth(ViewState* view_state);
+
+ // Makes sure the columns touched by view state are big enough for the
+ // view.
+ void DistributeRemainingWidth(ViewState* view_state);
+
+ // Returns the total size needed for this ColumnSet.
+ int LayoutWidth();
+
+ // Returns the width of the specified columns.
+ int GetColumnWidth(int start_col, int col_span);
+
+ // Updates the x coordinate of each column from the previous ones.
+ // NOTE: this doesn't include the insets.
+ void ResetColumnXCoordinates();
+
+ // Calculate the preferred width of each view in this column set, as well
+ // as updating the remaining_width.
+ void CalculateSize();
+
+ // Distributes delta amoung the resizable columns.
+ void Resize(int delta);
+
+ // ID for this columnset.
+ const int id_;
+
+ // The columns.
+ std::vector<Column*> columns_;
+
+ // The ViewStates. This is sorted based on column_span in ascending
+ // order.
+ std::vector<ViewState*> view_states_;
+
+ // The master column of those columns that are linked. See Column
+ // for a description of what the master column is.
+ std::vector<Column*> master_columns_;
+
+ DISALLOW_COPY_AND_ASSIGN(ColumnSet);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
diff --git a/views/layout/grid_layout_unittest.cc b/ui/views/layout/grid_layout_unittest.cc
index 542d7c5..542d7c5 100644
--- a/views/layout/grid_layout_unittest.cc
+++ b/ui/views/layout/grid_layout_unittest.cc
diff --git a/ui/views/layout/layout_constants.h b/ui/views/layout/layout_constants.h
new file mode 100644
index 0000000..3d9b69a
--- /dev/null
+++ b/ui/views/layout/layout_constants.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2011 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 UI_VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_
+#define UI_VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_
+#pragma once
+
+// This file contains some constants we use to implement our standard panel
+// layout.
+// see: spec 21/4
+
+namespace views {
+
+// Left or right margin.
+const int kPanelHorizMargin = 13;
+
+// Top or bottom margin.
+const int kPanelVertMargin = 13;
+
+// If some UI has some sub UI. Indent horizontally by the following value.
+const int kPanelHorizIndentation = 24;
+
+// When several controls are aligned vertically, the baseline should be spaced
+// by the following number of pixels.
+const int kPanelVerticalSpacing = 32;
+
+// Vertical spacing between sub UI.
+const int kPanelSubVerticalSpacing = 24;
+
+// Vertical spacing between a label and some control.
+const int kLabelToControlVerticalSpacing = 8;
+
+// Small horizontal spacing between controls that are logically related.
+const int kRelatedControlSmallHorizontalSpacing = 8;
+
+// Horizontal spacing between controls that are logically related.
+const int kRelatedControlHorizontalSpacing = 8;
+
+// Vertical spacing between controls that are logically related.
+const int kRelatedControlVerticalSpacing = 8;
+
+// Small vertical spacing between controls that are logically related.
+const int kRelatedControlSmallVerticalSpacing = 4;
+
+// Horizontal spacing between controls that are logically unrelated.
+const int kUnrelatedControlHorizontalSpacing = 12;
+
+// Larger horizontal spacing between unrelated controls.
+const int kUnrelatedControlLargeHorizontalSpacing = 20;
+
+// Vertical spacing between controls that are logically unrelated.
+const int kUnrelatedControlVerticalSpacing = 20;
+
+// Larger vertical spacing between unrelated controls.
+const int kUnrelatedControlLargeVerticalSpacing = 30;
+
+// Vertical spacing between the edge of the window and the
+// top or bottom of a button.
+const int kButtonVEdgeMargin = 6;
+
+// Vertical spacing between the edge of the window and the
+// left or right of a button.
+const int kButtonHEdgeMargin = 7;
+
+// Horizontal spacing between buttons that are logically related.
+const int kRelatedButtonHSpacing = 6;
+
+} // namespace views
+
+#endif // UI_VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_
diff --git a/views/layout/layout_manager.cc b/ui/views/layout/layout_manager.cc
index c62c6bb..c62c6bb 100644
--- a/views/layout/layout_manager.cc
+++ b/ui/views/layout/layout_manager.cc
diff --git a/ui/views/layout/layout_manager.h b/ui/views/layout/layout_manager.h
new file mode 100644
index 0000000..1241c80
--- /dev/null
+++ b/ui/views/layout/layout_manager.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 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 UI_VIEWS_LAYOUT_LAYOUT_MANAGER_H_
+#define UI_VIEWS_LAYOUT_LAYOUT_MANAGER_H_
+#pragma once
+
+#include "views/views_export.h"
+
+namespace gfx {
+class Size;
+}
+
+namespace views {
+
+class View;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// LayoutManager interface
+//
+// The LayoutManager interface provides methods to handle the sizing of
+// the children of a View according to implementation-specific heuristics.
+//
+/////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT LayoutManager {
+ public:
+ virtual ~LayoutManager();
+
+ // Notification that this LayoutManager has been installed on a particular
+ // host.
+ virtual void Installed(View* host);
+
+ // Notification that this LayoutManager has been uninstalled on a particular
+ // host.
+ virtual void Uninstalled(View* host);
+
+ // Lay out the children of |host| according to implementation-specific
+ // heuristics. The graphics used during painting is provided to allow for
+ // string sizing.
+ virtual void Layout(View* host) = 0;
+
+ // Return the preferred size which is the size required to give each
+ // children their respective preferred size.
+ virtual gfx::Size GetPreferredSize(View* host) = 0;
+
+ // Returns the preferred height for the specified width. The default
+ // implementation returns the value from GetPreferredSize.
+ virtual int GetPreferredHeightForWidth(View* host, int width);
+
+ // Notification that a view has been added.
+ virtual void ViewAdded(View* host, View* view);
+
+ // Notification that a view has been removed.
+ virtual void ViewRemoved(View* host, View* view);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_LAYOUT_LAYOUT_MANAGER_H_
diff --git a/views/bubble/border_contents_view.h b/views/bubble/border_contents_view.h
index 49ddb6a..a6c1bf2 100644
--- a/views/bubble/border_contents_view.h
+++ b/views/bubble/border_contents_view.h
@@ -6,83 +6,7 @@
#define VIEWS_BUBBLE_BORDER_CONTENTS_VIEW_H_
#pragma once
-#include "views/bubble/bubble_border.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "views/view.h"
-
-namespace views {
-
-// This is used to paint the border and background of the Bubble.
-class VIEWS_EXPORT BorderContentsView : public View {
- public:
- BorderContentsView();
- BorderContentsView(int top_margin,
- int left_margin,
- int bottom_margin,
- int right_margin);
-
- // Must be called before this object can be used.
- void Init();
-
- // Sets the background color.
- void SetBackgroundColor(SkColor color);
-
- // Sets the bubble alignment.
- void SetAlignment(views::BubbleBorder::BubbleAlignment alignment);
-
- // Given the size of the contents and the rect to point at, returns the bounds
- // of both the border and the contents inside the bubble.
- // |arrow_location| specifies the preferred location for the arrow
- // anchor. If the bubble does not fit on the monitor and
- // |allow_bubble_offscreen| is false, the arrow location may change so the
- // bubble shows entirely.
- virtual void SizeAndGetBounds(
- const gfx::Rect& position_relative_to, // In screen coordinates
- BubbleBorder::ArrowLocation arrow_location,
- bool allow_bubble_offscreen,
- const gfx::Size& contents_size,
- gfx::Rect* contents_bounds, // Returned in window coordinates
- gfx::Rect* window_bounds); // Returned in screen coordinates
-
- // Sets content margins.
- void set_content_margins(const gfx::Insets& margins) {
- content_margins_ = margins;
- }
-
- // Accessor for |content_margins_|.
- const gfx::Insets& content_margins() const {
- return content_margins_;
- }
-
- protected:
- virtual ~BorderContentsView();
-
- // Returns the bounds for the monitor showing the specified |rect|.
- virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect);
-
- BubbleBorder* bubble_border() const { return bubble_border_; }
-
- private:
- // Changes |arrow_location| to its mirrored version, vertically if |vertical|
- // is true, horizontally otherwise, if |window_bounds| don't fit in
- // |monitor_bounds|.
- void MirrorArrowIfOffScreen(
- bool vertical,
- const gfx::Rect& position_relative_to,
- const gfx::Rect& monitor_bounds,
- const gfx::Size& local_contents_size,
- BubbleBorder::ArrowLocation* arrow_location,
- gfx::Rect* window_bounds);
-
- // The bubble border.
- BubbleBorder* bubble_border_;
-
- // Margins between the content and the inside of the border, in pixels.
- gfx::Insets content_margins_;
-
- DISALLOW_COPY_AND_ASSIGN(BorderContentsView);
-};
-
-} // namespace views
+#include "ui/views/bubble/border_contents_view.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_BUBBLE_BORDER_CONTENTS_VIEW_H_
diff --git a/views/bubble/bubble_border.h b/views/bubble/bubble_border.h
index 7f00072..5612eb70 100644
--- a/views/bubble/bubble_border.h
+++ b/views/bubble/bubble_border.h
@@ -6,178 +6,7 @@
#define VIEWS_BUBBLE_BUBBLE_BORDER_H_
#pragma once
-#include "views/background.h"
-#include "views/border.h"
-
-class SkBitmap;
-
-namespace views {
-
-// Renders a border, with optional arrow, and a custom dropshadow.
-// This can be used to produce floating "bubble" objects with rounded corners.
-class VIEWS_EXPORT BubbleBorder : public views::Border {
- public:
- // Possible locations for the (optional) arrow.
- // 0 bit specifies left or right.
- // 1 bit specifies top or bottom.
- // 2 bit specifies horizontal or vertical.
- enum ArrowLocation {
- TOP_LEFT = 0,
- TOP_RIGHT = 1,
- BOTTOM_LEFT = 2,
- BOTTOM_RIGHT = 3,
- LEFT_TOP = 4,
- RIGHT_TOP = 5,
- LEFT_BOTTOM = 6,
- RIGHT_BOTTOM = 7,
- NONE = 8, // No arrow. Positioned under the supplied rect.
- FLOAT = 9 // No arrow. Centered over the supplied rect.
- };
-
- enum Shadow {
- SHADOW = 0,
- NO_SHADOW = 1
- };
-
- // The position of the bubble in relation to the anchor.
- enum BubbleAlignment {
- // The tip of the arrow points to the middle of the anchor.
- ALIGN_ARROW_TO_MID_ANCHOR,
- // The edge nearest to the arrow is lined up with the edge of the anchor.
- ALIGN_EDGE_TO_ANCHOR_EDGE
- };
-
- BubbleBorder(ArrowLocation arrow_location, Shadow shadow);
-
- // Returns the radius of the corner of the border.
- static int GetCornerRadius() {
- // We can't safely calculate a border radius by comparing the sizes of the
- // side and corner images, because either may have been extended in various
- // directions in order to do more subtle dropshadow fading or other effects.
- // So we hardcode the most accurate value.
- return 4;
- }
-
- // Sets the location for the arrow.
- void set_arrow_location(ArrowLocation arrow_location) {
- arrow_location_ = arrow_location;
- }
- ArrowLocation arrow_location() const { return arrow_location_; }
-
- // Sets the alignment.
- void set_alignment(BubbleAlignment alignment) { alignment_ = alignment; }
- BubbleAlignment alignment() const { return alignment_; }
-
- static ArrowLocation horizontal_mirror(ArrowLocation loc) {
- return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1);
- }
-
- static ArrowLocation vertical_mirror(ArrowLocation loc) {
- return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 2);
- }
-
- static bool has_arrow(ArrowLocation loc) {
- return loc >= NONE ? false : true;
- }
-
- static bool is_arrow_on_left(ArrowLocation loc) {
- return loc >= NONE ? false : !(loc & 1);
- }
-
- static bool is_arrow_on_top(ArrowLocation loc) {
- return loc >= NONE ? false : !(loc & 2);
- }
-
- static bool is_arrow_on_horizontal(ArrowLocation loc) {
- return loc >= NONE ? false : !(loc & 4);
- }
-
- // Sets the background color for the arrow body. This is irrelevant if you do
- // not also set the arrow location to something other than NONE.
- void set_background_color(SkColor background_color) {
- background_color_ = background_color;
- }
- SkColor background_color() const { return background_color_; }
-
- // For borders with an arrow, gives the desired bounds (in screen coordinates)
- // given the rect to point to and the size of the contained contents. This
- // depends on the arrow location, so if you change that, you should call this
- // again to find out the new coordinates.
- gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
- const gfx::Size& contents_size) const;
-
- // Sets a fixed offset for the arrow from the beginning of corresponding edge.
- // The arrow will still point to the same location but the bubble will shift
- // location to make that happen. Returns actuall arrow offset, in case of
- // overflow it differ from desired.
- int SetArrowOffset(int offset, const gfx::Size& contents_size);
-
- // Overridden from views::Border:
- virtual void GetInsets(gfx::Insets* insets) const;
-
- private:
- struct BorderImages;
-
- // Loads images if necessary.
- static BorderImages* GetBorderImages(Shadow shadow);
-
- virtual ~BubbleBorder();
-
- // Overridden from views::Border:
- virtual void Paint(const views::View& view, gfx::Canvas* canvas) const;
-
- void DrawEdgeWithArrow(gfx::Canvas* canvas,
- bool is_horizontal,
- SkBitmap* edge,
- SkBitmap* arrow,
- int start_x,
- int start_y,
- int before_arrow,
- int after_arrow,
- int offset) const;
-
- void DrawArrowInterior(gfx::Canvas* canvas,
- bool is_horizontal,
- int tip_x,
- int tip_y,
- int shift_x,
- int shift_y) const;
-
- // Border graphics.
- struct BorderImages* images_;
-
- // Image bundles.
- static struct BorderImages* normal_images_;
- static struct BorderImages* shadow_images_;
-
- // Minimal offset of the arrow from the closet edge of bounding rect.
- int arrow_offset_;
-
- // If specified, overrides the pre-calculated |arrow_offset_| of the arrow.
- int override_arrow_offset_;
-
- ArrowLocation arrow_location_;
- BubbleAlignment alignment_;
- SkColor background_color_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
-};
-
-// A Background that clips itself to the specified BubbleBorder and uses
-// the background color of the BubbleBorder.
-class VIEWS_EXPORT BubbleBackground : public views::Background {
- public:
- explicit BubbleBackground(BubbleBorder* border) : border_(border) {}
-
- // Background overrides.
- virtual void Paint(gfx::Canvas* canvas, views::View* view) const;
-
- private:
- BubbleBorder* border_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleBackground);
-};
-
-} // namespace views
+#include "ui/views/bubble/bubble_border.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_BUBBLE_BUBBLE_BORDER_H_
diff --git a/views/bubble/bubble_delegate.h b/views/bubble/bubble_delegate.h
index e782b82..c533220 100644
--- a/views/bubble/bubble_delegate.h
+++ b/views/bubble/bubble_delegate.h
@@ -6,148 +6,7 @@
#define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
#pragma once
-#include "base/gtest_prod_util.h"
-#include "ui/base/animation/animation_delegate.h"
-#include "views/bubble/bubble_border.h"
-#include "views/widget/widget.h"
-#include "views/widget/widget_delegate.h"
-
-namespace ui {
-class SlideAnimation;
-} // namespace ui
-
-namespace views {
-
-class BubbleFrameView;
-
-// BubbleDelegateView creates frame and client views for bubble Widgets.
-// BubbleDelegateView itself is the client's contents view.
-//
-///////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
- public ui::AnimationDelegate,
- public Widget::Observer {
- public:
- BubbleDelegateView();
- BubbleDelegateView(View* anchor_view,
- BubbleBorder::ArrowLocation arrow_location,
- const SkColor& color);
- virtual ~BubbleDelegateView();
-
- // Create and initialize the bubble Widget(s) with proper bounds.
- static Widget* CreateBubble(BubbleDelegateView* bubble_delegate);
-
- // WidgetDelegate overrides:
- virtual View* GetInitiallyFocusedView() OVERRIDE;
- virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE;
- virtual View* GetContentsView() OVERRIDE;
- virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
-
- // Widget::Observer overrides:
- virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE;
-
- bool close_on_esc() const { return close_on_esc_; }
- void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; }
-
- bool close_on_deactivate() const { return close_on_deactivate_; }
- void set_close_on_deactivate(bool close_on_deactivate) {
- close_on_deactivate_ = close_on_deactivate;
- }
-
- bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; }
- void set_allow_bubble_offscreen(bool allow_bubble_offscreen) {
- allow_bubble_offscreen_ = allow_bubble_offscreen;
- }
-
- View* anchor_view() const { return anchor_view_; }
-
- bool use_focusless() const { return use_focusless_; }
- void set_use_focusless(bool use_focusless) {
- use_focusless_ = use_focusless;
- }
-
- // Get the arrow's anchor point in screen space.
- virtual gfx::Point GetAnchorPoint();
-
- // Get the arrow's location on the bubble.
- virtual BubbleBorder::ArrowLocation GetArrowLocation() const;
-
- // Get the color used for the background and border.
- virtual SkColor GetColor() const;
-
- // Show the bubble's widget (and |border_widget_| on Windows).
- void Show();
-
- // Fade the bubble in or out via Widget transparency.
- // Fade in calls Widget::Show; fade out calls Widget::Close upon completion.
- void StartFade(bool fade_in);
-
- // Reset fade and opacity of bubble. Restore the opacity of the
- // bubble to the setting before StartFade() was called.
- void ResetFade();
-
- protected:
- // View overrides:
- virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
-
- // ui::AnimationDelegate overrides:
- virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
-
- // Perform view initialization on the contents for bubble sizing.
- virtual void Init();
-
- // Resizes and potentially moves the Bubble to best accommodate the
- // contents preferred size.
- void SizeToContents();
-
- private:
- FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, NonClientHitTest);
- FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate);
-
- BubbleFrameView* GetBubbleFrameView() const;
-
- // Get bubble bounds from the anchor point and client view's preferred size.
- gfx::Rect GetBubbleBounds();
-
-#if defined(OS_WIN) && !defined(USE_AURA)
- // Get bounds for the Windows-only widget that hosts the bubble's contents.
- gfx::Rect GetBubbleClientBounds() const;
-#endif
-
- // Fade animation for bubble.
- scoped_ptr<ui::SlideAnimation> fade_animation_;
-
- // Flags controlling bubble closure on the escape key and deactivation.
- bool close_on_esc_;
- bool close_on_deactivate_;
-
- // Whether the bubble is allowed to be displayed offscreen, or if auto
- // re-positioning should be performed.
- bool allow_bubble_offscreen_;
-
- // The view hosting this bubble; the arrow is anchored to this view.
- View* anchor_view_;
-
- // The arrow's location on the bubble.
- BubbleBorder::ArrowLocation arrow_location_;
-
- // The background color of the bubble.
- SkColor color_;
-
- // Original opacity of the bubble.
- int original_opacity_;
-
- // The widget hosting the border for this bubble (non-Aura Windows only).
- Widget* border_widget_;
-
- // Create a popup window for focusless bubbles on Linux/ChromeOS.
- // These bubbles are not interactive and should not gain focus.
- bool use_focusless_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView);
-};
-
-} // namespace views
+#include "ui/views/bubble/bubble_delegate.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
diff --git a/views/bubble/bubble_frame_view.h b/views/bubble/bubble_frame_view.h
index 1e3cbda..268e1a2 100644
--- a/views/bubble/bubble_frame_view.h
+++ b/views/bubble/bubble_frame_view.h
@@ -6,52 +6,7 @@
#define VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
#pragma once
-#include "base/gtest_prod_util.h"
-#include "ui/views/window/non_client_view.h"
-#include "views/bubble/bubble_border.h"
-
-namespace views {
-
-class BorderContentsView;
-
-// BubbleFrameView to render BubbleBorder.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView {
- public:
- BubbleFrameView(BubbleBorder::ArrowLocation location,
- const gfx::Size& client_size,
- SkColor color,
- bool allow_bubble_offscreen);
- virtual ~BubbleFrameView();
-
- // NonClientFrameView overrides:
- virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
- virtual gfx::Rect GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) const OVERRIDE;
- virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
- virtual void GetWindowMask(const gfx::Size& size,
- gfx::Path* window_mask) OVERRIDE {}
- virtual void EnableClose(bool enable) OVERRIDE {}
- virtual void ResetWindowControls() OVERRIDE {}
- virtual void UpdateWindowIcon() OVERRIDE {}
-
- // View overrides:
- virtual gfx::Size GetPreferredSize() OVERRIDE;
-
- // Accessor for bubble border inside border contents.
- BubbleBorder* bubble_border() const;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, GetBoundsForClientView);
-
- BorderContentsView* border_contents_;
- BubbleBorder::ArrowLocation location_;
- bool allow_bubble_offscreen_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleFrameView);
-};
-
-} // namespace views
+#include "ui/views/bubble/bubble_frame_view.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
diff --git a/views/events/event.h b/views/events/event.h
index d1b9b88..015eb08 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -6,410 +6,7 @@
#define VIEWS_EVENTS_EVENT_H_
#pragma once
-#include "base/basictypes.h"
-#include "base/time.h"
-#include "ui/base/events.h"
-#include "ui/base/keycodes/keyboard_codes.h"
-#include "ui/gfx/point.h"
-#include "views/views_export.h"
-
-namespace ui {
-class OSExchangeData;
-}
-
-#if defined(USE_AURA)
-namespace aura {
-class Event;
-}
-#endif
-
-// TODO(msw): Remove GTK support from views event code when possible.
-#if defined(TOOLKIT_USES_GTK)
-typedef union _GdkEvent GdkEvent;
-#endif
-
-namespace views {
-
-#if defined(USE_AURA)
-typedef aura::Event* NativeEvent;
-#else
-typedef base::NativeEvent NativeEvent;
-#endif
-
-class View;
-
-namespace internal {
-class NativeWidgetView;
-class RootView;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Event class
-//
-// An event encapsulates an input event that can be propagated into view
-// hierarchies. An event has a type, some flags and a time stamp.
-//
-// Each major event type has a corresponding Event subclass.
-//
-// Events are immutable but support copy
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT Event {
- public:
- const NativeEvent& native_event() const { return native_event_; }
-#if defined(TOOLKIT_USES_GTK)
- GdkEvent* gdk_event() const { return gdk_event_; }
-#endif
- ui::EventType type() const { return type_; }
- const base::Time& time_stamp() const { return time_stamp_; }
- int flags() const { return flags_; }
- void set_flags(int flags) { flags_ = flags; }
-
- // The following methods return true if the respective keys were pressed at
- // the time the event was created.
- bool IsShiftDown() const { return (flags_ & ui::EF_SHIFT_DOWN) != 0; }
- bool IsControlDown() const { return (flags_ & ui::EF_CONTROL_DOWN) != 0; }
- bool IsCapsLockDown() const { return (flags_ & ui::EF_CAPS_LOCK_DOWN) != 0; }
- bool IsAltDown() const { return (flags_ & ui::EF_ALT_DOWN) != 0; }
-
- bool IsMouseEvent() const {
- return type_ == ui::ET_MOUSE_PRESSED ||
- type_ == ui::ET_MOUSE_DRAGGED ||
- type_ == ui::ET_MOUSE_RELEASED ||
- type_ == ui::ET_MOUSE_MOVED ||
- type_ == ui::ET_MOUSE_ENTERED ||
- type_ == ui::ET_MOUSE_EXITED ||
- type_ == ui::ET_MOUSEWHEEL;
- }
-
- bool IsTouchEvent() const {
- return type_ == ui::ET_TOUCH_RELEASED ||
- type_ == ui::ET_TOUCH_PRESSED ||
- type_ == ui::ET_TOUCH_MOVED ||
- type_ == ui::ET_TOUCH_STATIONARY ||
- type_ == ui::ET_TOUCH_CANCELLED;
- }
-
- protected:
- Event(ui::EventType type, int flags);
- Event(const NativeEvent& native_event, ui::EventType type, int flags);
-#if defined(TOOLKIT_USES_GTK)
- Event(GdkEvent* gdk_event, ui::EventType type, int flags);
-#endif
-
- Event(const Event& model)
- : native_event_(model.native_event()),
-#if defined(TOOLKIT_USES_GTK)
- gdk_event_(model.gdk_event_),
-#endif
- type_(model.type()),
- time_stamp_(model.time_stamp()),
- flags_(model.flags()) {
- }
-
- void set_type(ui::EventType type) { type_ = type; }
-
- private:
- void operator=(const Event&);
-
- NativeEvent native_event_;
-#if defined(TOOLKIT_USES_GTK)
- GdkEvent* gdk_event_;
-#endif
- ui::EventType type_;
- base::Time time_stamp_;
- int flags_;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// LocatedEvent class
-//
-// A generic event that is used for any events that is located at a specific
-// position in the screen.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT LocatedEvent : public Event {
- public:
- int x() const { return location_.x(); }
- int y() const { return location_.y(); }
- const gfx::Point& location() const { return location_; }
-
- protected:
- explicit LocatedEvent(const NativeEvent& native_event);
-#if defined(TOOLKIT_USES_GTK)
- explicit LocatedEvent(GdkEvent* gdk_event);
-#endif
-
- // TODO(msw): Kill this legacy constructor when we update uses.
- // Simple initialization from cracked metadata.
- LocatedEvent(ui::EventType type, const gfx::Point& location, int flags);
-
- // Create a new LocatedEvent which is identical to the provided model.
- // If source / target views are provided, the model location will be converted
- // from |source| coordinate system to |target| coordinate system.
- LocatedEvent(const LocatedEvent& model, View* source, View* target);
-
- // This constructor is to allow converting the location of an event from the
- // widget's coordinate system to the RootView's coordinate system.
- LocatedEvent(const LocatedEvent& model, View* root);
-
- gfx::Point location_;
-};
-
-class TouchEvent;
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// MouseEvent class
-//
-// A mouse event is used for any input event related to the mouse.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT MouseEvent : public LocatedEvent {
- public:
- explicit MouseEvent(const NativeEvent& native_event);
-#if defined(TOOLKIT_USES_GTK)
- explicit MouseEvent(GdkEvent* gdk_event);
-#endif
-
- // Create a new MouseEvent which is identical to the provided model.
- // If source / target views are provided, the model location will be converted
- // from |source| coordinate system to |target| coordinate system.
- MouseEvent(const MouseEvent& model, View* source, View* target);
-
- // Creates a new MouseEvent from a TouchEvent. The location of the TouchEvent
- // is the same as the MouseEvent. Other attributes (e.g. type, flags) are
- // mapped from the TouchEvent to appropriate MouseEvent attributes.
- // GestureManager uses this to convert TouchEvents that are not handled by any
- // view.
- explicit MouseEvent(const TouchEvent& touch);
-
- // TODO(msw): Kill this legacy constructor when we update uses.
- // Create a new mouse event
- MouseEvent(ui::EventType type, int x, int y, int flags)
- : LocatedEvent(type, gfx::Point(x, y), flags) {
- }
-
- // Conveniences to quickly test what button is down
- bool IsOnlyLeftMouseButton() const {
- return (flags() & ui::EF_LEFT_BUTTON_DOWN) &&
- !(flags() & (ui::EF_MIDDLE_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
- }
-
- bool IsLeftMouseButton() const {
- return (flags() & ui::EF_LEFT_BUTTON_DOWN) != 0;
- }
-
- bool IsOnlyMiddleMouseButton() const {
- return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) &&
- !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
- }
-
- bool IsMiddleMouseButton() const {
- return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) != 0;
- }
-
- bool IsOnlyRightMouseButton() const {
- return (flags() & ui::EF_RIGHT_BUTTON_DOWN) &&
- !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN));
- }
-
- bool IsRightMouseButton() const {
- return (flags() & ui::EF_RIGHT_BUTTON_DOWN) != 0;
- }
-
- protected:
- MouseEvent(const MouseEvent& model, View* root)
- : LocatedEvent(model, root) {
- }
-
- private:
- friend class internal::NativeWidgetView;
- friend class internal::RootView;
-
- DISALLOW_COPY_AND_ASSIGN(MouseEvent);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// TouchEvent class
-//
-// A touch event is generated by touch screen and advanced track
-// pad devices. There is a deliberate direct correspondence between
-// TouchEvent and PlatformTouchPoint.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT TouchEvent : public LocatedEvent {
- public:
- explicit TouchEvent(const NativeEvent& native_event);
-
- // Create a new touch event.
- TouchEvent(ui::EventType type,
- int x,
- int y,
- int flags,
- int touch_id,
- float radius_x,
- float radius_y,
- float angle,
- float force);
-
- // Create a new TouchEvent which is identical to the provided model.
- // If source / target views are provided, the model location will be converted
- // from |source| coordinate system to |target| coordinate system.
- TouchEvent(const TouchEvent& model, View* source, View* target);
-
- int identity() const { return touch_id_; }
-
- float radius_x() const { return radius_x_; }
- float radius_y() const { return radius_y_; }
- float rotation_angle() const { return rotation_angle_; }
- float force() const { return force_; }
-
- private:
- friend class internal::NativeWidgetView;
- friend class internal::RootView;
-
- TouchEvent(const TouchEvent& model, View* root);
-
- // The identity (typically finger) of the touch starting at 0 and incrementing
- // for each separable additional touch that the hardware can detect.
- const int touch_id_;
-
- // Radius of the X (major) axis of the touch ellipse. 1.0 if unknown.
- const float radius_x_;
-
- // Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown.
- const float radius_y_;
-
- // Angle of the major axis away from the X axis. Default 0.0.
- const float rotation_angle_;
-
- // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
- const float force_;
-
- DISALLOW_COPY_AND_ASSIGN(TouchEvent);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// KeyEvent class
-//
-// KeyEvent encapsulates keyboard input events - key press and release.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT KeyEvent : public Event {
- public:
- explicit KeyEvent(const NativeEvent& native_event);
-#if defined(TOOLKIT_USES_GTK)
- explicit KeyEvent(GdkEvent* gdk_event);
-#endif
-
- // Creates a new KeyEvent synthetically (i.e. not in response to an input
- // event from the host environment). This is typically only used in testing as
- // some metadata obtainable from the underlying native event is not present.
- // It's also used by input methods to fabricate keyboard events.
- KeyEvent(ui::EventType type,
- ui::KeyboardCode key_code,
- int event_flags);
-
- ui::KeyboardCode key_code() const { return key_code_; }
-
- // These setters allow an I18N virtual keyboard to fabricate a keyboard event
- // which does not have a corresponding ui::KeyboardCode (example: U+00E1 Latin
- // small letter A with acute, U+0410 Cyrillic capital letter A.)
- // GetCharacter() and GetUnmodifiedCharacter() return the character.
- void set_character(uint16 character) { character_ = character; }
- void set_unmodified_character(uint16 unmodified_character) {
- unmodified_character_ = unmodified_character;
- }
-
- // Gets the character generated by this key event. It only supports Unicode
- // BMP characters.
- uint16 GetCharacter() const;
-
- // Gets the character generated by this key event ignoring concurrently-held
- // modifiers (except shift).
- uint16 GetUnmodifiedCharacter() const;
-
- private:
- ui::KeyboardCode key_code_;
-
- uint16 character_;
- uint16 unmodified_character_;
-
- DISALLOW_COPY_AND_ASSIGN(KeyEvent);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// MouseWheelEvent class
-//
-// A MouseWheelEvent is used to propagate mouse wheel user events.
-// Note: e.GetOffset() > 0 means scroll up / left.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT MouseWheelEvent : public MouseEvent {
- public:
- // See |offset| for details.
- static const int kWheelDelta;
-
- explicit MouseWheelEvent(const NativeEvent& native_event);
-#if defined(TOOLKIT_USES_GTK)
- explicit MouseWheelEvent(GdkEvent* gdk_event);
-#endif
-
- // The amount to scroll. This is in multiples of kWheelDelta.
- int offset() const { return offset_; }
-
- private:
- friend class internal::RootView;
- friend class internal::NativeWidgetView;
-
- MouseWheelEvent(const MouseWheelEvent& model, View* root)
- : MouseEvent(model, root),
- offset_(model.offset_) {
- }
-
- int offset_;
-
- DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// DropTargetEvent class
-//
-// A DropTargetEvent is sent to the view the mouse is over during a drag and
-// drop operation.
-//
-////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT DropTargetEvent : public LocatedEvent {
- public:
- DropTargetEvent(const ui::OSExchangeData& data,
- int x,
- int y,
- int source_operations)
- : LocatedEvent(ui::ET_DROP_TARGET_EVENT, gfx::Point(x, y), 0),
- data_(data),
- source_operations_(source_operations) {
- // TODO(msw): Hook up key state flags for CTRL + drag and drop, etc.
- }
-
- const ui::OSExchangeData& data() const { return data_; }
- int source_operations() const { return source_operations_; }
-
- private:
- // Data associated with the drag/drop session.
- const ui::OSExchangeData& data_;
-
- // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
- int source_operations_;
-
- DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
-};
-
-} // namespace views
+#include "ui/views/events/event.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_EVENTS_EVENT_H_
diff --git a/views/focus/accelerator_handler.h b/views/focus/accelerator_handler.h
index e0036e0..5eef62a 100644
--- a/views/focus/accelerator_handler.h
+++ b/views/focus/accelerator_handler.h
@@ -6,56 +6,7 @@
#define VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
#pragma once
-#include "build/build_config.h"
-
-#if defined(TOOLKIT_USES_GTK)
-#include <gdk/gdk.h>
-#endif
-
-#include <set>
-#include <vector>
-
-#include "base/message_loop.h"
-#include "views/views_export.h"
-
-namespace views {
-
-#if defined(TOUCH_UI) || defined(USE_AURA)
-#if defined(USE_X11) && !defined(USE_WAYLAND)
-// Dispatch an XEvent to the RootView. Return true if the event was dispatched
-// and handled, false otherwise.
-bool VIEWS_EXPORT DispatchXEvent(XEvent* xevent);
-#endif // USE_X11 && !USE_WAYLAND
-#endif // TOUCH_UI || USE_AURA
-
-// This class delegates the key messages to the associated FocusManager class
-// for the window that is receiving these messages for accelerator processing.
-class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher {
- public:
- AcceleratorHandler();
-
- // Dispatcher method. This returns true if an accelerator was processed by the
- // focus manager
-#if defined(OS_WIN)
- virtual bool Dispatch(const MSG& msg);
-#elif defined(USE_WAYLAND)
- virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(
- base::wayland::WaylandEvent* ev);
-#elif defined(TOUCH_UI) || defined(USE_AURA)
- virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xev);
-#else
- virtual bool Dispatch(GdkEvent* event);
-#endif
-
- private:
-#if defined(OS_WIN)
- // The keys currently pressed and consumed by the FocusManager.
- std::set<WPARAM> pressed_keys_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(AcceleratorHandler);
-};
-
-} // namespace views
+#include "ui/views/focus/accelerator_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
diff --git a/views/focus/external_focus_tracker.h b/views/focus/external_focus_tracker.h
index 62f553b..b350c9c 100644
--- a/views/focus/external_focus_tracker.h
+++ b/views/focus/external_focus_tracker.h
@@ -6,73 +6,7 @@
#define VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
#pragma once
-#include "views/focus/focus_manager.h"
-
-namespace views {
-
-class View;
-class ViewStorage;
-
-// ExternalFocusTracker tracks the last focused view which belongs to the
-// provided focus manager and is not either the provided parent view or one of
-// its descendants. This is generally used if the parent view want to return
-// focus to some other view once it is dismissed. The parent view and the focus
-// manager must exist for the duration of the tracking. If the focus manager
-// must be deleted before this object is deleted, make sure to call
-// SetFocusManager(NULL) first.
-//
-// Typical use: When a view is added to the view hierarchy, it instantiates an
-// ExternalFocusTracker and passes in itself and its focus manager. Then,
-// when that view wants to return focus to the last focused view which is not
-// itself and not a descandant of itself, (usually when it is being closed)
-// it calls FocusLastFocusedExternalView.
-class VIEWS_EXPORT ExternalFocusTracker : public FocusChangeListener {
- public:
- ExternalFocusTracker(View* parent_view, FocusManager* focus_manager);
-
- virtual ~ExternalFocusTracker();
- // FocusChangeListener implementation.
- virtual void OnWillChangeFocus(View* focused_before, View* focused_now);
- virtual void OnDidChangeFocus(View* focused_before, View* focused_now);
-
- // Focuses last focused view which is not a child of parent view and is not
- // parent view itself. Returns true if focus for a view was requested, false
- // otherwise.
- void FocusLastFocusedExternalView();
-
- // Sets the focus manager whose focus we are tracking. |focus_manager| can
- // be NULL, but no focus changes will be tracked. This is useful if the focus
- // manager went away, but you might later want to start tracking with a new
- // manager later, or call FocusLastFocusedExternalView to focus the previous
- // view.
- void SetFocusManager(FocusManager* focus_manager);
-
- private:
- // Store the provided view. This view will be focused when
- // FocusLastFocusedExternalView is called.
- void StoreLastFocusedView(View* view);
-
- // Store the currently focused view for our view manager and register as a
- // listener for future focus changes.
- void StartTracking();
-
- // Focus manager which we are a listener for.
- FocusManager* focus_manager_;
-
- // ID of the last focused view, which we store in view_storage_.
- int last_focused_view_storage_id_;
-
- // Used to store the last focused view which is not a child of
- // ExternalFocusTracker.
- ViewStorage* view_storage_;
-
- // The parent view of views which we should not track focus changes to. We
- // also do not track changes to parent_view_ itself.
- View* parent_view_;
-
- DISALLOW_COPY_AND_ASSIGN(ExternalFocusTracker);
-};
-
-} // namespace views
+#include "ui/views/focus/external_focus_tracker.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_EXTERNAL_FOCUS_TRACKER_H_
diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h
index 5d4caa7..5432cb5 100644
--- a/views/focus/focus_manager.h
+++ b/views/focus/focus_manager.h
@@ -6,278 +6,7 @@
#define VIEWS_FOCUS_FOCUS_MANAGER_H_
#pragma once
-#include <list>
-#include <map>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "ui/base/models/accelerator.h"
-#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
-#include "views/events/event.h"
-
-// The FocusManager class is used to handle focus traversal, store/restore
-// focused views and handle keyboard accelerators.
-//
-// There are 2 types of focus:
-// - the native focus, which is the focus that an gfx::NativeView has.
-// - the view focus, which is the focus that a views::View has.
-//
-// Each native view must register with their Focus Manager so the focus manager
-// gets notified when they are focused (and keeps track of the native focus) and
-// as well so that the tab key events can be intercepted.
-// They can provide when they register a View that is kept in synch in term of
-// focus. This is used in NativeControl for example, where a View wraps an
-// actual native window.
-// This is already done for you if you subclass the NativeControl class or if
-// you use the NativeViewHost class.
-//
-// When creating a top window (derived from views::Widget) that is not a child
-// window, it creates and owns a FocusManager to manage the focus for itself and
-// all its child windows.
-//
-// The FocusTraversable interface exposes the methods a class should implement
-// in order to be able to be focus traversed when tab key is pressed.
-// RootViews implement FocusTraversable.
-// The FocusManager contains a top FocusTraversable instance, which is the top
-// RootView.
-//
-// If you just use views, then the focus traversal is handled for you by the
-// RootView. The default traversal order is the order in which the views have
-// been added to their container. You can modify this order by using the View
-// method SetNextFocusableView().
-//
-// If you are embedding a native view containing a nested RootView (for example
-// by adding a NativeControl that contains a NativeWidgetWin as its native
-// component), then you need to:
-// - override the View::GetFocusTraversable() method in your outer component.
-// It should return the RootView of the inner component. This is used when
-// the focus traversal traverse down the focus hierarchy to enter the nested
-// RootView. In the example mentioned above, the NativeControl overrides
-// GetFocusTraversable() and returns hwnd_view_container_->GetRootView().
-// - call Widget::SetFocusTraversableParent() on the nested RootView and point
-// it to the outer RootView. This is used when the focus goes out of the
-// nested RootView. In the example:
-// hwnd_view_container_->GetWidget()->SetFocusTraversableParent(
-// native_control->GetRootView());
-// - call RootView::SetFocusTraversableParentView() on the nested RootView with
-// the parent view that directly contains the native window. This is needed
-// when traversing up from the nested RootView to know which view to start
-// with when going to the next/previous view.
-// In our example:
-// hwnd_view_container_->GetWidget()->SetFocusTraversableParent(
-// native_control);
-//
-// Note that FocusTraversable do not have to be RootViews: AccessibleToolbarView
-// is FocusTraversable.
-
-namespace ui {
-class AcceleratorTarget;
-class AcceleratorManager;
-}
-
-namespace views {
-
-class FocusSearch;
-class RootView;
-class View;
-class Widget;
-
-// The FocusTraversable interface is used by components that want to process
-// focus traversal events (due to Tab/Shift-Tab key events).
-class VIEWS_EXPORT FocusTraversable {
- public:
- // Return a FocusSearch object that implements the algorithm to find
- // the next or previous focusable view.
- virtual FocusSearch* GetFocusSearch() = 0;
-
- // Should return the parent FocusTraversable.
- // The top RootView which is the top FocusTraversable returns NULL.
- virtual FocusTraversable* GetFocusTraversableParent() = 0;
-
- // This should return the View this FocusTraversable belongs to.
- // It is used when walking up the view hierarchy tree to find which view
- // should be used as the starting view for finding the next/previous view.
- virtual View* GetFocusTraversableParentView() = 0;
-
- protected:
- virtual ~FocusTraversable() {}
-};
-
-// This interface should be implemented by classes that want to be notified when
-// the focus is about to change. See the Add/RemoveFocusChangeListener methods.
-class VIEWS_EXPORT FocusChangeListener {
- public:
- // No change to focus state has occurred yet when this function is called.
- virtual void OnWillChangeFocus(View* focused_before, View* focused_now) = 0;
-
- // Called after focus state has changed.
- virtual void OnDidChangeFocus(View* focused_before, View* focused_now) = 0;
-
- protected:
- virtual ~FocusChangeListener() {}
-};
-
-class VIEWS_EXPORT FocusManager {
- public:
- // The reason why the focus changed.
- enum FocusChangeReason {
- // The focus changed because the user traversed focusable views using
- // keys like Tab or Shift+Tab.
- kReasonFocusTraversal,
-
- // The focus changed due to restoring the focus.
- kReasonFocusRestore,
-
- // The focus changed due to a click or a shortcut to jump directly to
- // a particular view.
- kReasonDirectFocusChange
- };
-
- explicit FocusManager(Widget* widget);
- virtual ~FocusManager();
-
- // Processes the passed key event for accelerators and tab traversal.
- // Returns false if the event has been consumed and should not be processed
- // further.
- bool OnKeyEvent(const KeyEvent& event);
-
- // Returns true is the specified is part of the hierarchy of the window
- // associated with this FocusManager.
- bool ContainsView(View* view);
-
- // Advances the focus (backward if reverse is true).
- void AdvanceFocus(bool reverse);
-
- // The FocusManager keeps track of the focused view within a RootView.
- View* GetFocusedView() { return focused_view_; }
- const View* GetFocusedView() const { return focused_view_; }
-
- // Low-level methods to force the focus to change (and optionally provide
- // a reason). If the focus change should only happen if the view is
- // currenty focusable, enabled, and visible, call view->RequestFocus().
- void SetFocusedViewWithReason(View* view, FocusChangeReason reason);
- void SetFocusedView(View* view) {
- SetFocusedViewWithReason(view, kReasonDirectFocusChange);
- }
-
- // Get the reason why the focus most recently changed.
- FocusChangeReason focus_change_reason() const {
- return focus_change_reason_;
- }
-
- // Clears the focused view. The window associated with the top root view gets
- // the native focus (so we still get keyboard events).
- void ClearFocus();
-
- // Validates the focused view, clearing it if the window it belongs too is not
- // attached to the window hierarchy anymore.
- void ValidateFocusedView();
-
- // Stores and restores the focused view. Used when the window becomes
- // active/inactive.
- void StoreFocusedView();
- void RestoreFocusedView();
-
- // Clears the stored focused view.
- void ClearStoredFocusedView();
-
- // Returns true if in the process of changing the focused view.
- bool is_changing_focus() const { return is_changing_focus_; }
-
- // Register a keyboard accelerator for the specified target. If multiple
- // targets are registered for an accelerator, a target registered later has
- // higher priority.
- // Note that we are currently limited to accelerators that are either:
- // - a key combination including Ctrl or Alt
- // - the escape key
- // - the enter key
- // - any F key (F1, F2, F3 ...)
- // - any browser specific keys (as available on special keyboards)
- void RegisterAccelerator(const ui::Accelerator& accelerator,
- ui::AcceleratorTarget* target);
-
- // Unregister the specified keyboard accelerator for the specified target.
- void UnregisterAccelerator(const ui::Accelerator& accelerator,
- ui::AcceleratorTarget* target);
-
- // Unregister all keyboard accelerator for the specified target.
- void UnregisterAccelerators(ui::AcceleratorTarget* target);
-
- // Activate the target associated with the specified accelerator.
- // First, AcceleratorPressed handler of the most recently registered target
- // is called, and if that handler processes the event (i.e. returns true),
- // this method immediately returns. If not, we do the same thing on the next
- // target, and so on.
- // Returns true if an accelerator was activated.
- bool ProcessAccelerator(const ui::Accelerator& accelerator);
-
- // Called by a RootView when a view within its hierarchy is removed
- // from its parent. This will only be called by a RootView in a
- // hierarchy of Widgets that this FocusManager is attached to the
- // parent Widget of.
- void ViewRemoved(View* removed);
-
- // Adds/removes a listener. The FocusChangeListener is notified every time
- // the focused view is about to change.
- void AddFocusChangeListener(FocusChangeListener* listener);
- void RemoveFocusChangeListener(FocusChangeListener* listener);
-
- // Returns the AcceleratorTarget that should be activated for the specified
- // keyboard accelerator, or NULL if no view is registered for that keyboard
- // accelerator.
- ui::AcceleratorTarget* GetCurrentTargetForAccelerator(
- const ui::Accelerator& accelertor) const;
-
- // Sets the focus to the specified native view.
- virtual void FocusNativeView(gfx::NativeView native_view);
-
- // Clears the native view having the focus.
- virtual void ClearNativeFocus();
-
- // Convenience method that returns true if the passed |key_event| should
- // trigger tab traversal (if it is a TAB key press with or without SHIFT
- // pressed).
- static bool IsTabTraversalKeyEvent(const KeyEvent& key_event);
-
- private:
- // Returns the next focusable view.
- View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop);
-
- // Returns the focusable view found in the FocusTraversable specified starting
- // at the specified view. This traverses down along the FocusTraversable
- // hierarchy.
- // Returns NULL if no focusable view were found.
- View* FindFocusableView(FocusTraversable* focus_traversable,
- View* starting_view,
- bool reverse);
-
- // The top-level Widget this FocusManager is associated with.
- Widget* widget_;
-
- // The view that currently is focused.
- View* focused_view_;
-
- // The AcceleratorManager this FocusManager is associated with.
- scoped_ptr<ui::AcceleratorManager> accelerator_manager_;
-
- // The storage id used in the ViewStorage to store/restore the view that last
- // had focus.
- int stored_focused_view_storage_id_;
-
- // The reason why the focus most recently changed.
- FocusChangeReason focus_change_reason_;
-
- // The list of registered FocusChange listeners.
- ObserverList<FocusChangeListener, true> focus_change_listeners_;
-
- // See description above getter.
- bool is_changing_focus_;
-
- DISALLOW_COPY_AND_ASSIGN(FocusManager);
-};
-
-} // namespace views
+#include "ui/views/focus/focus_manager.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_FOCUS_MANAGER_H_
diff --git a/views/focus/focus_manager_factory.h b/views/focus/focus_manager_factory.h
index 136b254..825cc34 100644
--- a/views/focus/focus_manager_factory.h
+++ b/views/focus/focus_manager_factory.h
@@ -6,36 +6,7 @@
#define VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_
#pragma once
-#include "base/basictypes.h"
-#include "views/views_export.h"
-
-namespace views {
-
-class FocusManager;
-class Widget;
-
-// A factory to create FocusManager. This is used in unit tests
-// to inject a custom factory.
-class VIEWS_EXPORT FocusManagerFactory {
- public:
- // Create a FocusManager for the given |widget| using installe Factory.
- static FocusManager* Create(Widget* widget);
-
- // Installs FocusManagerFactory. If |factory| is NULL, it resets
- // to the default factory which creates plain FocusManager.
- static void Install(FocusManagerFactory* factory);
-
- protected:
- FocusManagerFactory();
- virtual ~FocusManagerFactory();
-
- // Create a FocusManager for the given |widget|.
- virtual FocusManager* CreateFocusManager(Widget* widget) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FocusManagerFactory);
-};
-
-} // namespace views
+#include "ui/views/focus/focus_manager_factory.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_
diff --git a/views/focus/focus_search.h b/views/focus/focus_search.h
index ae20a31..0ef2fc3 100644
--- a/views/focus/focus_search.h
+++ b/views/focus/focus_search.h
@@ -2,121 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef VIEWS_WIDGET_FOCUS_SEARCH_H_
-#define VIEWS_WIDGET_FOCUS_SEARCH_H_
+#ifndef VIEWS_FOCUS_FOCUS_SEARCH_H_
+#define VIEWS_FOCUS_FOCUS_SEARCH_H_
#pragma once
-#include "views/view.h"
+#include "ui/views/focus/focus_search.h"
+// TODO(tfarina): remove this file once all includes have been updated.
-namespace views {
-
-class FocusTraversable;
-
-// FocusSearch is an object that implements the algorithm to find the
-// next view to focus.
-class VIEWS_EXPORT FocusSearch {
- public:
- // The direction in which the focus traversal is going.
- // TODO (jcampan): add support for lateral (left, right) focus traversal. The
- // goal is to switch to focusable views on the same level when using the arrow
- // keys (ala Windows: in a dialog box, arrow keys typically move between the
- // dialog OK, Cancel buttons).
- enum Direction {
- UP = 0,
- DOWN
- };
-
- // Constructor.
- // - |root| is the root of the view hierarchy to traverse. Focus will be
- // trapped inside.
- // - |cycle| should be true if you want FindNextFocusableView to cycle back
- // to the first view within this root when the traversal reaches
- // the end. If this is true, then if you pass a valid starting
- // view to FindNextFocusableView you will always get a valid view
- // out, even if it's the same view.
- // - |accessibility_mode| should be true if full keyboard accessibility is
- // needed and you want to check IsAccessibilityFocusableInRootView(),
- // rather than IsFocusableInRootView().
- FocusSearch(View* root, bool cycle, bool accessibility_mode);
- virtual ~FocusSearch() {}
-
- // Finds the next view that should be focused and returns it. If a
- // FocusTraversable is found while searching for the focusable view,
- // returns NULL and sets |focus_traversable| to the FocusTraversable
- // and |focus_traversable_view| to the view associated with the
- // FocusTraversable.
- //
- // Return NULL if the end of the focus loop is reached, unless this object
- // was initialized with |cycle|=true, in which case it goes back to the
- // beginning when it reaches the end of the traversal.
- // - |starting_view| is the view that should be used as the starting point
- // when looking for the previous/next view. It may be NULL (in which case
- // the first/last view should be used depending if normal/reverse).
- // - |reverse| whether we should find the next (reverse is false) or the
- // previous (reverse is true) view.
- // - |direction| specifies whether we are traversing down (meaning we should
- // look into child views) or traversing up (don't look at child views).
- // - |check_starting_view| is true if starting_view may obtain the next focus.
- // - |focus_traversable| is set to the focus traversable that should be
- // traversed if one is found (in which case the call returns NULL).
- // - |focus_traversable_view| is set to the view associated with the
- // FocusTraversable set in the previous parameter (it is used as the
- // starting view when looking for the next focusable view).
- virtual View* FindNextFocusableView(View* starting_view,
- bool reverse,
- Direction direction,
- bool check_starting_view,
- FocusTraversable** focus_traversable,
- View** focus_traversable_view);
-
- private:
- // Convenience method that returns true if a view is focusable and does not
- // belong to the specified group.
- bool IsViewFocusableCandidate(View* v, int skip_group_id);
-
- // Convenience method; returns true if a view is not NULL and is focusable
- // (checking IsAccessibilityFocusableInRootView() if accessibility_mode_ is
- // true).
- bool IsFocusable(View* v);
-
- // Returns the view selected for the group of the selected view. If the view
- // does not belong to a group or if no view is selected in the group, the
- // specified view is returned.
- View* FindSelectedViewForGroup(View* view);
-
- // Get the parent, but stay within the root. Returns NULL if asked for
- // the parent of root_.
- View* GetParent(View* view);
-
- // Returns the next focusable view or view containing a FocusTraversable
- // (NULL if none was found), starting at the starting_view.
- // |check_starting_view|, |can_go_up| and |can_go_down| controls the
- // traversal of the views hierarchy. |skip_group_id| specifies a group_id,
- // -1 means no group. All views from a group are traversed in one pass.
- View* FindNextFocusableViewImpl(View* starting_view,
- bool check_starting_view,
- bool can_go_up,
- bool can_go_down,
- int skip_group_id,
- FocusTraversable** focus_traversable,
- View** focus_traversable_view);
-
- // Same as FindNextFocusableViewImpl but returns the previous focusable view.
- View* FindPreviousFocusableViewImpl(View* starting_view,
- bool check_starting_view,
- bool can_go_up,
- bool can_go_down,
- int skip_group_id,
- FocusTraversable** focus_traversable,
- View** focus_traversable_view);
-
- View* root_;
- bool cycle_;
- bool accessibility_mode_;
-
- DISALLOW_COPY_AND_ASSIGN(FocusSearch);
-};
-
-} // namespace views
-
-#endif // VIEWS_WIDGET_FOCUS_SEARCH_H_
+#endif // VIEWS_FOCUS_FOCUS_SEARCH_H_
diff --git a/views/focus/view_storage.h b/views/focus/view_storage.h
index 8beb9e7..48037ed 100644
--- a/views/focus/view_storage.h
+++ b/views/focus/view_storage.h
@@ -6,65 +6,7 @@
#define VIEWS_FOCUS_VIEW_STORAGE_H_
#pragma once
-#include "base/memory/singleton.h"
-#include "views/view.h"
-
-// This class is a simple storage place for storing/retrieving views. It is
-// used for example in the FocusManager to store/restore focused views when the
-// main window becomes active/inactive.
-// It automatically removes a view from the storage if the view is removed from
-// the tree hierarchy.
-//
-// To use it, you first need to create a view storage id that can then be used
-// to store/retrieve views.
-
-namespace views {
-
-class VIEWS_EXPORT ViewStorage {
- public:
- // Returns the global ViewStorage instance.
- // It is guaranted to be non NULL.
- static ViewStorage* GetInstance();
-
- // Returns a unique storage id that can be used to store/retrieve views.
- int CreateStorageID();
-
- // Associates |view| with the specified |storage_id|.
- void StoreView(int storage_id, View* view);
-
- // Returns the view associated with |storage_id| if any, NULL otherwise.
- View* RetrieveView(int storage_id);
-
- // Removes the view associated with |storage_id| if any.
- void RemoveView(int storage_id);
-
- // Notifies the ViewStorage that a view was removed from its parent somewhere.
- void ViewRemoved(View* removed);
-
- size_t view_count() const { return view_to_ids_.size(); }
-
- private:
- friend struct DefaultSingletonTraits<ViewStorage>;
-
- ViewStorage();
- ~ViewStorage();
-
- // Removes the view associated with |storage_id|. If |remove_all_ids| is true,
- // all other mapping pointing to the same view are removed as well.
- void EraseView(int storage_id, bool remove_all_ids);
-
- // Next id for the view storage.
- int view_storage_next_id_;
-
- // The association id to View used for the view storage.
- std::map<int, View*> id_to_view_;
-
- // Association View to id, used to speed up view notification removal.
- std::map<View*, std::vector<int>*> view_to_ids_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewStorage);
-};
-
-} // namespace views
+#include "ui/views/focus/view_storage.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_VIEW_STORAGE_H_
diff --git a/views/focus/widget_focus_manager.h b/views/focus/widget_focus_manager.h
index 503a158..b9f4e0a 100644
--- a/views/focus/widget_focus_manager.h
+++ b/views/focus/widget_focus_manager.h
@@ -6,77 +6,7 @@
#define VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_
#pragma once
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
-
-template <typename T> struct DefaultSingletonTraits;
-
-namespace views {
-
-// This interface should be implemented by classes that want to be notified when
-// the native focus is about to change. Listeners implementing this interface
-// will be invoked for all native focus changes across the entire Chrome
-// application. FocusChangeListeners are only called for changes within the
-// children of a single top-level native-view.
-class WidgetFocusChangeListener {
- public:
- virtual void OnNativeFocusChange(gfx::NativeView focused_before,
- gfx::NativeView focused_now) = 0;
-
- protected:
- virtual ~WidgetFocusChangeListener() {}
-};
-
-class VIEWS_EXPORT WidgetFocusManager {
- public:
- // Returns the singleton instance.
- static WidgetFocusManager* GetInstance();
-
- // Adds/removes a WidgetFocusChangeListener |listener| to the set of
- // active listeners.
- void AddFocusChangeListener(WidgetFocusChangeListener* listener);
- void RemoveFocusChangeListener(WidgetFocusChangeListener* listener);
-
- // To be called when native-focus shifts from |focused_before| to
- // |focused_now|.
- // TODO(port) : Invocations to this routine are only implemented for
- // the Win32 platform. Calls need to be placed appropriately for
- // non-Windows environments.
- void OnWidgetFocusEvent(gfx::NativeView focused_before,
- gfx::NativeView focused_now);
-
- // Enable/Disable notification of registered listeners during calls
- // to OnWidgetFocusEvent. Used to prevent unwanted focus changes from
- // propagating notifications.
- void EnableNotifications() { enabled_ = true; }
- void DisableNotifications() { enabled_ = false; }
-
- private:
- friend struct DefaultSingletonTraits<WidgetFocusManager>;
-
- WidgetFocusManager();
- ~WidgetFocusManager();
-
- ObserverList<WidgetFocusChangeListener> focus_change_listeners_;
-
- bool enabled_;
-
- DISALLOW_COPY_AND_ASSIGN(WidgetFocusManager);
-};
-
-// A basic helper class that is used to disable native focus change
-// notifications within a scope.
-class VIEWS_EXPORT AutoNativeNotificationDisabler {
- public:
- AutoNativeNotificationDisabler();
- ~AutoNativeNotificationDisabler();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler);
-};
-
-} // namespace views
+#include "ui/views/focus/widget_focus_manager.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_FOCUS_WIDGET_FOCUS_MANAGER_H_
diff --git a/views/layout/box_layout.h b/views/layout/box_layout.h
index 2422bb6..88d7c24 100644
--- a/views/layout/box_layout.h
+++ b/views/layout/box_layout.h
@@ -6,57 +6,7 @@
#define VIEWS_LAYOUT_BOX_LAYOUT_H_
#pragma once
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "views/layout/layout_manager.h"
+#include "ui/views/layout/box_layout.h"
+// TODO(tfarina): remove this file once all includes have been updated.
-namespace gfx {
-class Size;
-}
-
-namespace views {
-
-class View;
-
-// A Layout manager that arranges child views vertically or horizontally in a
-// side-by-side fashion with spacing around and between the child views. The
-// child views are always sized according to their preferred size. If the
-// host's bounds provide insufficient space, child views will be clamped.
-// Excess space will not be distributed.
-class VIEWS_EXPORT BoxLayout : public LayoutManager {
- public:
- enum Orientation {
- kHorizontal,
- kVertical,
- };
-
- // Use |inside_border_horizontal_spacing| and
- // |inside_border_vertical_spacing| to add additional space between the child
- // view area and the host view border. |between_child_spacing| controls the
- // space in between child views.
- BoxLayout(Orientation orientation,
- int inside_border_horizontal_spacing,
- int inside_border_vertical_spacing,
- int between_child_spacing);
- virtual ~BoxLayout();
-
- // Overridden from views::LayoutManager:
- virtual void Layout(View* host) OVERRIDE;
- virtual gfx::Size GetPreferredSize(View* host) OVERRIDE;
-
- private:
- const Orientation orientation_;
-
- // Spacing between child views and host view border.
- const int inside_border_horizontal_spacing_;
- const int inside_border_vertical_spacing_;
-
- // Spacing to put in between child views.
- const int between_child_spacing_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout);
-};
-
-} // namespace views
-
-#endif // VIEWS_LAYOUT_BOX_LAYOUT_H_
+#endif // VIEWS_LAYOUT_BOX_LAYOUT_H_
diff --git a/views/layout/fill_layout.h b/views/layout/fill_layout.h
index 20e989f..b3351b6 100644
--- a/views/layout/fill_layout.h
+++ b/views/layout/fill_layout.h
@@ -6,31 +6,7 @@
#define VIEWS_LAYOUT_FILL_LAYOUT_H_
#pragma once
-#include "views/layout/layout_manager.h"
-#include "views/view.h"
-
-namespace views {
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// FillLayout
-// A simple LayoutManager that causes the associated view's one child to be
-// sized to match the bounds of its parent.
-//
-///////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT FillLayout : public LayoutManager {
- public:
- FillLayout();
- virtual ~FillLayout();
-
- // Overridden from LayoutManager:
- virtual void Layout(View* host);
- virtual gfx::Size GetPreferredSize(View* host);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FillLayout);
-};
-
-} // namespace views
+#include "ui/views/layout/fill_layout.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_LAYOUT_FILL_LAYOUT_H_
diff --git a/views/layout/grid_layout.h b/views/layout/grid_layout.h
index ddfaf8e..790030e 100644
--- a/views/layout/grid_layout.h
+++ b/views/layout/grid_layout.h
@@ -6,366 +6,7 @@
#define VIEWS_LAYOUT_GRID_LAYOUT_H_
#pragma once
-#include <string>
-#include <vector>
-
-#include "views/layout/layout_manager.h"
-#include "views/view.h"
-
-namespace gfx {
-class Insets;
-}
-
-// GridLayout is a LayoutManager that positions child Views in a grid. You
-// define the structure of the Grid first, then add the Views.
-// The following creates a trivial grid with two columns separated by
-// a column with padding:
-// ColumnSet* columns = layout->AddColumnSet(0); // Give this column an
-// // identifier of 0.
-// columns->AddColumn(FILL, // Views are horizontally resized to fill column.
-// FILL, // Views starting in this column are vertically
-// // resized.
-// 1, // This column has a resize weight of 1.
-// USE_PREF, // Use the preferred size of the view.
-// 0, // Ignored for USE_PREF.
-// 0); // A minimum width of 0.
-// columns->AddPaddingColumn(0, // The padding column is not resizable.
-// 10); // And has a width of 10 pixels.
-// columns->AddColumn(FILL, FILL, 0, USE_PREF, 0, 0);
-// Now add the views:
-// // First start a row.
-// layout->StartRow(0, // This row isn't vertically resizable.
-// 0); // The column set to use for this row.
-// layout->AddView(v1);
-// Notice you need not skip over padding columns, that's done for you.
-// layout->AddView(v2);
-//
-// When adding a Column you give it the default alignment for all views
-// originating in that column. You can override this for specific views
-// when adding them. For example, the following forces a View to have
-// a horizontal and vertical alignment of leading regardless of that defined
-// for the column:
-// layout->AddView(v1, 1, 1, LEADING, LEADING);
-//
-// If the View using GridLayout is given a size bigger than the preferred,
-// columns and rows with a resize percent > 0 are resized. Each column/row
-// is given resize_percent / total_resize_percent * extra_pixels extra
-// pixels. Only Views with an Alignment of FILL are given extra space, others
-// are aligned in the provided space.
-//
-// GridLayout allows you to define multiple column sets. When you start a
-// new row you specify the id of the column set the row is to use.
-//
-// GridLayout allows you to force columns to have the same width. This is
-// done using the LinkColumnSizes method.
-//
-// AddView takes care of adding the View to the View the GridLayout was
-// created with.
-namespace views {
-
-class Column;
-class ColumnSet;
-class Row;
-class View;
-
-struct ViewState;
-
-class VIEWS_EXPORT GridLayout : public LayoutManager {
- public:
- // An enumeration of the possible alignments supported by GridLayout.
- enum Alignment {
- // Leading equates to left along the horizontal axis, and top along the
- // vertical axis.
- LEADING,
-
- // Centers the view along the axis.
- CENTER,
-
- // Trailing equals to right along the horizontal axis, and bottom along
- // the vertical axis.
- TRAILING,
-
- // The view is resized to fill the space.
- FILL,
-
- // The view is aligned along the baseline. This is only valid for the
- // vertical axis.
- BASELINE
- };
-
- // An enumeration of the possible ways the size of a column may be obtained.
- enum SizeType {
- // The column size is fixed.
- FIXED,
-
- // The preferred size of the view is used to determine the column size.
- USE_PREF
- };
-
- explicit GridLayout(View* host);
- virtual ~GridLayout();
-
- // Creates a GridLayout with kPanel*Margin insets.
- static GridLayout* CreatePanel(View* host);
-
- // Sets the insets. All views are placed relative to these offsets.
- void SetInsets(int top, int left, int bottom, int right);
- void SetInsets(const gfx::Insets& insets);
-
- // Creates a new column set with the specified id and returns it.
- // The id is later used when starting a new row.
- // GridLayout takes ownership of the ColumnSet and will delete it when
- // the GridLayout is deleted.
- ColumnSet* AddColumnSet(int id);
-
- // Adds a padding row. Padding rows typically don't have any views, and
- // but are used to provide vertical white space between views.
- // Size specifies the height of the row.
- void AddPaddingRow(float vertical_resize, int size);
-
- // A convenience for AddPaddingRow followed by StartRow.
- void StartRowWithPadding(float vertical_resize, int column_set_id,
- float padding_resize, int padding);
-
- // Starts a new row with the specified column set.
- void StartRow(float vertical_resize, int column_set_id);
-
- // Advances past columns. Use this when the current column should not
- // contain any views.
- void SkipColumns(int col_count);
-
- // Adds a view using the default alignment from the column. The added
- // view has a column and row span of 1.
- // As a convenience this adds the view to the host. The view becomes owned
- // by the host, and NOT this GridLayout.
- void AddView(View* view);
-
- // Adds a view using the default alignment from the column.
- // As a convenience this adds the view to the host. The view becomes owned
- // by the host, and NOT this GridLayout.
- void AddView(View* view, int col_span, int row_span);
-
- // Adds a view with the specified alignment and spans.
- // As a convenience this adds the view to the host. The view becomes owned
- // by the host, and NOT this GridLayout.
- void AddView(View* view, int col_span, int row_span, Alignment h_align,
- Alignment v_align);
-
- // Adds a view with the specified alignment and spans. If
- // pref_width/pref_height is > 0 then the preferred width/height of the view
- // is fixed to the specified value.
- // As a convenience this adds the view to the host. The view becomes owned
- // by the host, and NOT this GridLayout.
- void AddView(View* view, int col_span, int row_span,
- Alignment h_align, Alignment v_align,
- int pref_width, int pref_height);
-
- // Notification we've been installed on a particular host. Checks that host
- // is the same as the View supplied in the constructor.
- virtual void Installed(View* host);
-
- // Notification we've been uninstalled on a particular host. Checks that host
- // is the same as the View supplied in the constructor.
- virtual void Uninstalled(View* host);
-
- // Notification that a view has been added.
- virtual void ViewAdded(View* host, View* view);
-
- // Notification that a view has been removed.
- virtual void ViewRemoved(View* host, View* view);
-
- // Layouts out the components.
- virtual void Layout(View* host);
-
- // Returns the preferred size for the GridLayout.
- virtual gfx::Size GetPreferredSize(View* host);
-
- virtual int GetPreferredHeightForWidth(View* host, int width);
-
- private:
- // As both Layout and GetPreferredSize need to do nearly the same thing,
- // they both call into this method. This sizes the Columns/Rows as
- // appropriate. If layout is true, width/height give the width/height the
- // of the host, otherwise they are ignored.
- void SizeRowsAndColumns(bool layout, int width, int height, gfx::Size* pref);
-
- // Calculates the master columns of all the column sets. See Column for
- // a description of what a master column is.
- void CalculateMasterColumnsIfNecessary();
-
- // This is called internally from AddView. It adds the ViewState to the
- // appropriate structures, and updates internal fields such as next_column_.
- void AddViewState(ViewState* view_state);
-
- // Returns the column set for the specified id, or NULL if one doesn't exist.
- ColumnSet* GetColumnSet(int id);
-
- // Adds the Row to rows_, as well as updating next_column_,
- // current_row_col_set ...
- void AddRow(Row* row);
-
- // As the name says, updates the remaining_height of the ViewState for
- // all Rows the supplied ViewState touches.
- void UpdateRemainingHeightFromRows(ViewState* state);
-
- // If the view state's remaining height is > 0, it is distributed among
- // the rows the view state touches. This is used during layout to make
- // sure the Rows can accommodate a view.
- void DistributeRemainingHeight(ViewState* state);
-
- // Advances next_column_ past any padding columns.
- void SkipPaddingColumns();
-
- // Returns the column set of the last non-padding row.
- ColumnSet* GetLastValidColumnSet();
-
- // The view we were created with. We don't own this.
- View* const host_;
-
- // Whether or not we've calculated the master/linked columns.
- bool calculated_master_columns_;
-
- // Used to verify a view isn't added with a row span that expands into
- // another column structure.
- int remaining_row_span_;
-
- // Current row.
- int current_row_;
-
- // Current column.
- int next_column_;
-
- // Column set for the current row. This is null for padding rows.
- ColumnSet* current_row_col_set_;
-
- // Insets.
- int top_inset_;
- int bottom_inset_;
- int left_inset_;
- int right_inset_;
-
- // Set to true when adding a View.
- bool adding_view_;
-
- // ViewStates. This is ordered by row_span in ascending order.
- std::vector<ViewState*> view_states_;
-
- // ColumnSets.
- std::vector<ColumnSet*> column_sets_;
-
- // Rows.
- std::vector<Row*> rows_;
-
- DISALLOW_COPY_AND_ASSIGN(GridLayout);
-};
-
-// ColumnSet is used to define a set of columns. GridLayout may have any
-// number of ColumnSets. You don't create a ColumnSet directly, instead
-// use the AddColumnSet method of GridLayout.
-class VIEWS_EXPORT ColumnSet {
- public:
- ~ColumnSet();
-
- // Adds a column for padding. When adding views, padding columns are
- // automatically skipped. For example, if you create a column set with
- // two columns separated by a padding column, the first AddView automatically
- // skips past the padding column. That is, to add two views, do:
- // layout->AddView(v1); layout->AddView(v2);, not:
- // layout->AddView(v1); layout->SkipColumns(1); layout->AddView(v2);
- void AddPaddingColumn(float resize_percent, int width);
-
- // Adds a column. The alignment gives the default alignment for views added
- // with no explicit alignment. fixed_width gives a specific width for the
- // column, and is only used if size_type == FIXED. min_width gives the
- // minimum width for the column.
- //
- // If none of the columns in a columnset are resizable, the views are only
- // made as wide as the widest views in each column, even if extra space is
- // provided. In other words, GridLayout does not automatically resize views
- // unless the column is marked as resizable.
- void AddColumn(GridLayout::Alignment h_align,
- GridLayout::Alignment v_align,
- float resize_percent,
- GridLayout::SizeType size_type,
- int fixed_width,
- int min_width);
-
- // Forces the specified columns to have the same size. The size of
- // linked columns is that of the max of the specified columns. This
- // must end with -1. For example, the following forces the first and
- // second column to have the same size:
- // LinkColumnSizes(0, 1, -1);
- void LinkColumnSizes(int first, ...);
-
- // ID of this ColumnSet.
- int id() const { return id_; }
-
- int num_columns() { return static_cast<int>(columns_.size()); }
-
- private:
- friend class GridLayout;
-
- explicit ColumnSet(int id);
-
- void AddColumn(GridLayout::Alignment h_align,
- GridLayout::Alignment v_align,
- float resize_percent,
- GridLayout::SizeType size_type,
- int fixed_width,
- int min_width,
- bool is_padding);
-
- void AddViewState(ViewState* view_state);
-
- // Set description of these.
- void CalculateMasterColumns();
- void AccumulateMasterColumns();
-
- // Sets the size of each linked column to be the same.
- void UnifySameSizedColumnSizes();
-
- // Updates the remaining width field of the ViewState from that of the
- // columns the view spans.
- void UpdateRemainingWidth(ViewState* view_state);
-
- // Makes sure the columns touched by view state are big enough for the
- // view.
- void DistributeRemainingWidth(ViewState* view_state);
-
- // Returns the total size needed for this ColumnSet.
- int LayoutWidth();
-
- // Returns the width of the specified columns.
- int GetColumnWidth(int start_col, int col_span);
-
- // Updates the x coordinate of each column from the previous ones.
- // NOTE: this doesn't include the insets.
- void ResetColumnXCoordinates();
-
- // Calculate the preferred width of each view in this column set, as well
- // as updating the remaining_width.
- void CalculateSize();
-
- // Distributes delta amoung the resizable columns.
- void Resize(int delta);
-
- // ID for this columnset.
- const int id_;
-
- // The columns.
- std::vector<Column*> columns_;
-
- // The ViewStates. This is sorted based on column_span in ascending
- // order.
- std::vector<ViewState*> view_states_;
-
- // The master column of those columns that are linked. See Column
- // for a description of what the master column is.
- std::vector<Column*> master_columns_;
-
- DISALLOW_COPY_AND_ASSIGN(ColumnSet);
-};
-
-} // namespace views
+#include "ui/views/layout/grid_layout.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_LAYOUT_GRID_LAYOUT_H_
diff --git a/views/layout/layout_constants.h b/views/layout/layout_constants.h
index 85633d4..8e85bc0 100644
--- a/views/layout/layout_constants.h
+++ b/views/layout/layout_constants.h
@@ -6,66 +6,7 @@
#define VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_
#pragma once
-// This file contains some constants we use to implement our standard panel
-// layout.
-// see: spec 21/4
-
-namespace views {
-
-// Left or right margin.
-const int kPanelHorizMargin = 13;
-
-// Top or bottom margin.
-const int kPanelVertMargin = 13;
-
-// If some UI has some sub UI. Indent horizontally by the following value.
-const int kPanelHorizIndentation = 24;
-
-// When several controls are aligned vertically, the baseline should be spaced
-// by the following number of pixels.
-const int kPanelVerticalSpacing = 32;
-
-// Vertical spacing between sub UI.
-const int kPanelSubVerticalSpacing = 24;
-
-// Vertical spacing between a label and some control.
-const int kLabelToControlVerticalSpacing = 8;
-
-// Small horizontal spacing between controls that are logically related.
-const int kRelatedControlSmallHorizontalSpacing = 8;
-
-// Horizontal spacing between controls that are logically related.
-const int kRelatedControlHorizontalSpacing = 8;
-
-// Vertical spacing between controls that are logically related.
-const int kRelatedControlVerticalSpacing = 8;
-
-// Small vertical spacing between controls that are logically related.
-const int kRelatedControlSmallVerticalSpacing = 4;
-
-// Horizontal spacing between controls that are logically unrelated.
-const int kUnrelatedControlHorizontalSpacing = 12;
-
-// Larger horizontal spacing between unrelated controls.
-const int kUnrelatedControlLargeHorizontalSpacing = 20;
-
-// Vertical spacing between controls that are logically unrelated.
-const int kUnrelatedControlVerticalSpacing = 20;
-
-// Larger vertical spacing between unrelated controls.
-const int kUnrelatedControlLargeVerticalSpacing = 30;
-
-// Vertical spacing between the edge of the window and the
-// top or bottom of a button.
-const int kButtonVEdgeMargin = 6;
-
-// Vertical spacing between the edge of the window and the
-// left or right of a button.
-const int kButtonHEdgeMargin = 7;
-
-// Horizontal spacing between buttons that are logically related.
-const int kRelatedButtonHSpacing = 6;
-
-} // namespace views
+#include "ui/views/layout/layout_constants.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_
diff --git a/views/layout/layout_manager.h b/views/layout/layout_manager.h
index b34499c..e1944f1 100644
--- a/views/layout/layout_manager.h
+++ b/views/layout/layout_manager.h
@@ -2,60 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef VIEWS_LAYOUT_MANAGER_H_
-#define VIEWS_LAYOUT_MANAGER_H_
+#ifndef VIEWS_LAYOUT_LAYOUT_MANAGER_H_
+#define VIEWS_LAYOUT_LAYOUT_MANAGER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/layout/layout_manager.h"
+// TODO(tfarina): remove this file once all includes have been updated.
-namespace gfx {
-class Size;
-}
-
-namespace views {
-
-class View;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// LayoutManager interface
-//
-// The LayoutManager interface provides methods to handle the sizing of
-// the children of a View according to implementation-specific heuristics.
-//
-/////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT LayoutManager {
- public:
- virtual ~LayoutManager();
-
- // Notification that this LayoutManager has been installed on a particular
- // host.
- virtual void Installed(View* host);
-
- // Notification that this LayoutManager has been uninstalled on a particular
- // host.
- virtual void Uninstalled(View* host);
-
- // Lay out the children of |host| according to implementation-specific
- // heuristics. The graphics used during painting is provided to allow for
- // string sizing.
- virtual void Layout(View* host) = 0;
-
- // Return the preferred size which is the size required to give each
- // children their respective preferred size.
- virtual gfx::Size GetPreferredSize(View* host) = 0;
-
- // Returns the preferred height for the specified width. The default
- // implementation returns the value from GetPreferredSize.
- virtual int GetPreferredHeightForWidth(View* host, int width);
-
- // Notification that a view has been added.
- virtual void ViewAdded(View* host, View* view);
-
- // Notification that a view has been removed.
- virtual void ViewRemoved(View* host, View* view);
-};
-
-} // namespace views
-
-#endif // VIEWS_LAYOUT_MANAGER_H_
+#endif // VIEWS_LAYOUT_LAYOUT_MANAGER_H_
diff --git a/views/views.gyp b/views/views.gyp
index d3e98b3..6a183c1 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -61,14 +61,6 @@
'background.h',
'border.cc',
'border.h',
- 'bubble/bubble_border.cc',
- 'bubble/bubble_border.h',
- 'bubble/border_contents_view.cc',
- 'bubble/border_contents_view.h',
- 'bubble/bubble_delegate.cc',
- 'bubble/bubble_delegate.h',
- 'bubble/bubble_frame_view.cc',
- 'bubble/bubble_frame_view.h',
'context_menu_controller.h',
'controls/button/button.cc',
'controls/button/button.h',
@@ -259,40 +251,6 @@
'drag_utils_aura.cc',
'drag_utils_gtk.cc',
'drag_utils_win.cc',
- 'events/event.cc',
- 'events/event.h',
- 'events/event_aura.cc',
- 'events/event_gtk.cc',
- 'events/event_wayland.cc',
- 'events/event_win.cc',
- 'events/event_x.cc',
- 'focus/accelerator_handler.h',
- 'focus/accelerator_handler_aura.cc',
- 'focus/accelerator_handler_gtk.cc',
- 'focus/accelerator_handler_touch.cc',
- 'focus/accelerator_handler_wayland.cc',
- 'focus/accelerator_handler_win.cc',
- 'focus/external_focus_tracker.cc',
- 'focus/external_focus_tracker.h',
- 'focus/focus_manager.cc',
- 'focus/focus_manager.h',
- 'focus/focus_manager_factory.cc',
- 'focus/focus_manager_factory.h',
- 'focus/focus_search.cc',
- 'focus/focus_search.h',
- 'focus/view_storage.cc',
- 'focus/view_storage.h',
- 'focus/widget_focus_manager.cc',
- 'focus/widget_focus_manager.h',
- 'layout/box_layout.cc',
- 'layout/box_layout.h',
- 'layout/fill_layout.cc',
- 'layout/fill_layout.h',
- 'layout/grid_layout.cc',
- 'layout/grid_layout.h',
- 'layout/layout_constants.h',
- 'layout/layout_manager.cc',
- 'layout/layout_manager.h',
'metrics.cc',
'metrics.h',
'metrics_aura.cc',
@@ -370,10 +328,43 @@
'widget/widget_delegate.h',
'widget/window_manager.cc',
'widget/window_manager.h',
- '../ui/views/animation/bounds_animator.cc',
- '../ui/views/animation/bounds_animator.h',
'../ui/views/accessibility/native_view_accessibility_win.cc',
'../ui/views/accessibility/native_view_accessibility_win.h',
+ '../ui/views/animation/bounds_animator.cc',
+ '../ui/views/animation/bounds_animator.h',
+ '../ui/views/bubble/border_contents_view.cc',
+ '../ui/views/bubble/border_contents_view.h',
+ '../ui/views/bubble/bubble_border.cc',
+ '../ui/views/bubble/bubble_border.h',
+ '../ui/views/bubble/bubble_delegate.cc',
+ '../ui/views/bubble/bubble_delegate.h',
+ '../ui/views/bubble/bubble_frame_view.cc',
+ '../ui/views/bubble/bubble_frame_view.h',
+ '../ui/views/events/event.cc',
+ '../ui/views/events/event.h',
+ '../ui/views/events/event_aura.cc',
+ '../ui/views/events/event_gtk.cc',
+ '../ui/views/events/event_wayland.cc',
+ '../ui/views/events/event_win.cc',
+ '../ui/views/events/event_x.cc',
+ '../ui/views/focus/accelerator_handler.h',
+ '../ui/views/focus/accelerator_handler_aura.cc',
+ '../ui/views/focus/accelerator_handler_gtk.cc',
+ '../ui/views/focus/accelerator_handler_touch.cc',
+ '../ui/views/focus/accelerator_handler_wayland.cc',
+ '../ui/views/focus/accelerator_handler_win.cc',
+ '../ui/views/focus/external_focus_tracker.cc',
+ '../ui/views/focus/external_focus_tracker.h',
+ '../ui/views/focus/focus_manager.cc',
+ '../ui/views/focus/focus_manager.h',
+ '../ui/views/focus/focus_manager_factory.cc',
+ '../ui/views/focus/focus_manager_factory.h',
+ '../ui/views/focus/focus_search.cc',
+ '../ui/views/focus/focus_search.h',
+ '../ui/views/focus/view_storage.cc',
+ '../ui/views/focus/view_storage.h',
+ '../ui/views/focus/widget_focus_manager.cc',
+ '../ui/views/focus/widget_focus_manager.h',
'../ui/views/ime/input_method_base.cc',
'../ui/views/ime/input_method_base.h',
'../ui/views/ime/input_method_delegate.h',
@@ -390,6 +381,15 @@
'../ui/views/ime/mock_input_method.h',
'../ui/views/ime/text_input_type_tracker.cc',
'../ui/views/ime/text_input_type_tracker.h',
+ '../ui/views/layout/box_layout.cc',
+ '../ui/views/layout/box_layout.h',
+ '../ui/views/layout/fill_layout.cc',
+ '../ui/views/layout/fill_layout.h',
+ '../ui/views/layout/grid_layout.cc',
+ '../ui/views/layout/grid_layout.h',
+ '../ui/views/layout/layout_constants.h',
+ '../ui/views/layout/layout_manager.cc',
+ '../ui/views/layout/layout_manager.h',
'../ui/views/touchui/gesture_manager.cc',
'../ui/views/touchui/gesture_manager.h',
'../ui/views/touchui/touch_selection_controller.cc',
@@ -423,7 +423,7 @@
'sources/': [
['exclude', '_(gtk|x)\\.cc$'],
['exclude', '/(gtk|x)_[^/]*\\.cc$'],
- ['exclude', 'focus/accelerator_handler_touch.cc'],
+ ['exclude', '../ui/views/focus/accelerator_handler_touch.cc'],
['include', 'controls/menu/native_menu_views.cc'],
['include', 'controls/menu/native_menu_views.h'],
['include', 'drag_utils_gtk.cc'],
@@ -437,7 +437,7 @@
['exclude', 'controls/menu/menu_2.*'],
],
'sources!': [
- 'drag_utils_win.cc',
+ '../ui/views/focus/accelerator_handler_touch.cc',
'controls/menu/menu_config_linux.cc',
'controls/menu/menu_item_view_linux.cc',
'controls/menu/menu_separator_linux.cc',
@@ -457,7 +457,7 @@
'controls/table/table_view_observer.h',
'controls/tree/tree_view.cc',
'controls/tree/tree_view.h',
- 'focus/accelerator_handler_touch.cc',
+ 'drag_utils_win.cc',
'widget/aero_tooltip_manager.cc',
'widget/aero_tooltip_manager.h',
'widget/child_window_message_processor.cc',
@@ -472,13 +472,13 @@
'../build/linux/system.gyp:xext',
],
'sources!': [
+ '../ui/views/events/event_win.cc',
'accessibility/native_view_accessibility_win.cc',
'controls/scrollbar/bitmap_scroll_bar.cc',
'controls/native_control.cc',
'controls/table/group_table_view.cc',
'controls/table/table_view.cc',
'controls/tree/tree_view.cc',
- 'events/event_win.cc',
'widget/aero_tooltip_manager.cc',
'widget/child_window_message_processor.cc',
'widget/child_window_message_processor.h',
@@ -488,7 +488,7 @@
['touchui==1', {
'defines': ['TOUCH_UI=1'],
'sources/': [
- ['exclude', 'focus/accelerator_handler_gtk.cc'],
+ ['exclude', '../ui/views/focus/accelerator_handler_gtk.cc'],
['exclude', 'controls/menu/native_menu_gtk.cc'],
['exclude', 'widget/tooltip_manager_gtk.cc'],
],
@@ -531,7 +531,7 @@
}],
['use_x11==0', {
'sources!': [
- 'events/event_x.cc',
+ '../ui/views/events/event_x.cc',
],
}],
],
@@ -566,14 +566,19 @@
],
'sources': [
'../ui/views/animation/bounds_animator_unittest.cc',
+ '../ui/views/bubble/bubble_delegate_unittest.cc',
+ '../ui/views/bubble/bubble_frame_view_unittest.cc',
+ '../ui/views/events/event_unittest.cc',
+ '../ui/views/focus/accelerator_handler_gtk_unittest.cc',
+ '../ui/views/focus/focus_manager_unittest.cc',
+ '../ui/views/layout/box_layout_unittest.cc',
+ '../ui/views/layout/grid_layout_unittest.cc',
'../ui/views/touchui/touch_selection_controller_impl_unittest.cc',
'../ui/views/test/test_views_delegate.cc',
'../ui/views/test/test_views_delegate.h',
'../ui/views/test/views_test_base.cc',
'../ui/views/test/views_test_base.h',
'accessible_pane_view_unittest.cc',
- 'bubble/bubble_delegate_unittest.cc',
- 'bubble/bubble_frame_view_unittest.cc',
'controls/label_unittest.cc',
'controls/progress_bar_unittest.cc',
'controls/single_split_view_unittest.cc',
@@ -584,11 +589,6 @@
'controls/textfield/native_textfield_views_unittest.cc',
'controls/textfield/textfield_views_model_unittest.cc',
'controls/scrollbar/scrollbar_unittest.cc',
- 'events/event_unittest.cc',
- 'focus/accelerator_handler_gtk_unittest.cc',
- 'focus/focus_manager_unittest.cc',
- 'layout/grid_layout_unittest.cc',
- 'layout/box_layout_unittest.cc',
'run_all_unittests.cc',
'view_unittest.cc',
'widget/native_widget_test_utils.h',
@@ -616,7 +616,7 @@
}],
[ 'touchui==1', {
'sources!': [
- 'focus/accelerator_handler_gtk_unittest.cc',
+ '../ui/views/focus/accelerator_handler_gtk_unittest.cc',
'controls/table/table_view_unittest.cc',
'controls/tabbed_pane/tabbed_pane_unittest.cc'
],
@@ -644,11 +644,11 @@
'../ui/aura/aura.gyp:test_support_aura',
],
'sources/': [
- ['exclude', 'focus/focus_manager_unittest.cc'], # TODO(beng):
- ['exclude', 'widget/native_widget_win_unittest.cc'],
+ ['exclude', '../ui/views/focus/focus_manager_unittest.cc'], # TODO(beng):
['exclude', 'controls/combobox/native_combobox_views_unittest.cc'],
['exclude', 'controls/table/table_view_unittest.cc'],
['exclude', 'controls/tabbed_pane/tabbed_pane_unittest.cc'],
+ ['exclude', 'widget/native_widget_win_unittest.cc'],
],
}, {
'sources/': [