diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 09:51:51 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 09:51:51 +0000 |
commit | ada3a02b33b92392617b45dbb4a9d757fa10ec72 (patch) | |
tree | 382c8cfb26f3be529be67e0e4428a76ad064272d /views/controls | |
parent | e9c4061d914b36974e27a66f855eb4946e2a0d11 (diff) | |
download | chromium_src-ada3a02b33b92392617b45dbb4a9d757fa10ec72.zip chromium_src-ada3a02b33b92392617b45dbb4a9d757fa10ec72.tar.gz chromium_src-ada3a02b33b92392617b45dbb4a9d757fa10ec72.tar.bz2 |
Convert the native separator to a regular view. Also, lighten it a bit in color.
BUG=59288
TEST=Open the page info bubble. The horizontal separator between sections should work as before.
Review URL: http://codereview.chromium.org/7144018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/separator.cc | 91 | ||||
-rw-r--r-- | views/controls/separator.h | 14 |
2 files changed, 14 insertions, 91 deletions
diff --git a/views/controls/separator.cc b/views/controls/separator.cc index 5bec307..8dd0312 100644 --- a/views/controls/separator.cc +++ b/views/controls/separator.cc @@ -4,65 +4,21 @@ #include "views/controls/separator.h" -#include "base/logging.h" #include "ui/base/accessibility/accessible_view_state.h" -#include "views/widget/widget.h" - -#if defined(OS_LINUX) -#include "views/controls/native_control_gtk.h" -#elif defined(OS_WIN) -#include "ui/base/win/hwnd_util.h" -#include "views/controls/native_control_win.h" -#endif +#include "ui/gfx/canvas.h" namespace views { -#if defined(OS_WIN) -class NativeSeparatorWin : public NativeControlWin { - public: - explicit NativeSeparatorWin(Separator* separator) : separator_(separator) {} - virtual ~NativeSeparatorWin() {} - - // Overridden from NativeControlWin: - virtual void CreateNativeControl() { - HWND control_hwnd = CreateWindowEx(GetAdditionalExStyle(), L"STATIC", L"", - WS_CHILD | SS_ETCHEDHORZ | SS_SUNKEN, - 0, 0, width(), height(), - separator_->GetWidget()->GetNativeView(), - NULL, NULL, NULL); - ui::CheckWindowCreated(control_hwnd); - NativeControlCreated(control_hwnd); - } - - private: - Separator* separator_; - - DISALLOW_COPY_AND_ASSIGN(NativeSeparatorWin); -}; -#elif defined(OS_LINUX) -class NativeSeparatorGtk : public NativeControlGtk { - public: - explicit NativeSeparatorGtk(Separator* separator) : separator_(separator) {} - virtual ~NativeSeparatorGtk() {} - - // Overridden from NativeSeparatorGtk: - virtual void CreateNativeControl() { - // TODO(port): create a separator widget and pass to NativeControlCreated. - } - - private: - Separator* separator_; - - DISALLOW_COPY_AND_ASSIGN(NativeSeparatorGtk); -}; -#endif - // static const char Separator::kViewClassName[] = "views/Separator"; -const int kSeparatorSize = 2; +// The separator height in pixels. +const int kSeparatorHeight = 1; -Separator::Separator() : native_wrapper_(NULL) { +// Default color of the separator. +const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233); + +Separator::Separator() { set_focusable(false); } @@ -73,42 +29,19 @@ Separator::~Separator() { // Separator, View overrides: gfx::Size Separator::GetPreferredSize() { - return gfx::Size(width(), kSeparatorSize); + return gfx::Size(width(), kSeparatorHeight); } -void Separator::Layout() { - if (native_wrapper_) { - int y = static_cast<int>((height() - kSeparatorSize) / 2); - native_wrapper_->SetBounds(0, y, width(), kSeparatorSize); - native_wrapper_->Layout(); - } +void Separator::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; } -void Separator::ViewHierarchyChanged(bool is_add, View* parent, - View* child) { - if (is_add && !native_wrapper_ && GetWidget()) { - CreateNativeWrapper(); - AddChildView(native_wrapper_); - } +void Separator::Paint(gfx::Canvas* canvas) { + canvas->FillRectInt(kDefaultColor, x(), y(), width(), height()); } std::string Separator::GetClassName() const { return kViewClassName; } -void Separator::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; -} - -//////////////////////////////////////////////////////////////////////////////// -// Separator, private: - -void Separator::CreateNativeWrapper() { -#if defined(OS_WIN) - native_wrapper_ = new NativeSeparatorWin(this); -#elif defined(OS_LINUX) - native_wrapper_ = new NativeSeparatorGtk(this); -#endif -} - } // namespace views diff --git a/views/controls/separator.h b/views/controls/separator.h index 6c4d9c4..405efc3 100644 --- a/views/controls/separator.h +++ b/views/controls/separator.h @@ -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. @@ -24,22 +24,12 @@ class Separator : public View { virtual ~Separator(); // Overridden from View: - virtual void Layout() OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - - protected: - // Overridden from View: - virtual void ViewHierarchyChanged(bool is_add, View* parent, - View* child) OVERRIDE; + virtual void Paint(gfx::Canvas* canvas) OVERRIDE; virtual std::string GetClassName() const OVERRIDE; private: - void CreateNativeWrapper(); - - // The native view. - View* native_wrapper_; - DISALLOW_COPY_AND_ASSIGN(Separator); }; |