Commit 5dd7f89f authored by msw@chromium.org's avatar msw@chromium.org

Add dialog-specific styling, restore old-style task manager.

Add per-dialog UseNewStyleForThisDialog() style control.
(by default this returns the static UseNewStyle() control)
Update DialogDelegate to respect this per-dialog control.

Have TaskManagerView always use the old style; cleanup.
See before/after pics at http://crbug.com/245000#c1

Do DialogClientView background init in ViewHierarchyChanged.
(check the dialog delegate instance for styling control)

BUG=245000,166075
TEST=The task manager always uses the old dialog style.
R=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/15731007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203044 0039d316-1c4b-4281-b951-d872f2087c98
parent ee53f09e
......@@ -227,6 +227,7 @@ class TaskManagerView : public views::ButtonListener,
virtual std::string GetWindowName() const OVERRIDE;
virtual int GetDialogButtons() const OVERRIDE;
virtual void WindowClosing() OVERRIDE;
virtual bool UseNewStyleForThisDialog() const OVERRIDE;
// views::TableViewObserver:
virtual void OnSelectionChanged() OVERRIDE;
......@@ -493,13 +494,10 @@ void TaskManagerView::ViewHierarchyChanged(
}
void TaskManagerView::Layout() {
bool new_style = views::DialogDelegate::UseNewStyle();
gfx::Size size = kill_button_->GetPreferredSize();
gfx::Rect parent_bounds = parent()->GetContentsBounds();
const int horizontal_margin =
new_style ? views::kButtonHEdgeMarginNew : views::kPanelHorizMargin;
const int vertical_margin =
new_style ? views::kButtonVEdgeMarginNew : views::kButtonVEdgeMargin;
const int horizontal_margin = views::kPanelHorizMargin;
const int vertical_margin = views::kButtonVEdgeMargin;
int x = width() - size.width() - horizontal_margin;
int y_buttons = parent_bounds.bottom() - size.height() - vertical_margin;
kill_button_->SetBounds(x, y_buttons, size.width(), size.height());
......@@ -651,6 +649,10 @@ void TaskManagerView::WindowClosing() {
task_manager_->OnWindowClosed();
}
bool TaskManagerView::UseNewStyleForThisDialog() const {
return false;
}
// views::TableViewObserver implementation.
void TaskManagerView::OnSelectionChanged() {
const ui::ListSelectionModel::SelectedIndices& selection(
......
......@@ -40,13 +40,6 @@ DialogClientView::DialogClientView(Widget* owner, View* contents_view)
extra_view_(NULL),
footnote_view_(NULL),
notified_delegate_(false) {
// When using the new style, the background color is set on the bubble frame,
// so a transparent background is fine.
if (!DialogDelegate::UseNewStyle()) {
const SkColor color = owner->GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_DialogBackground);
set_background(views::Background::CreateSolidBackground(color));
}
}
DialogClientView::~DialogClientView() {
......@@ -263,6 +256,15 @@ void DialogClientView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
ClientView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this) {
// The old dialog style needs an explicit background color, while the new
// dialog style simply inherits the bubble's frame view color.
const DialogDelegate* dialog = GetDialogDelegate();
const bool use_new_style = dialog ?
dialog->UseNewStyleForThisDialog() : DialogDelegate::UseNewStyle();
if (!use_new_style)
set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
focus_manager_ = GetFocusManager();
if (focus_manager_)
GetFocusManager()->AddFocusChangeListener(this);
......
......@@ -39,7 +39,9 @@ Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog,
views::Widget* widget = new views::Widget;
views::Widget::InitParams params;
params.delegate = dialog;
if (DialogDelegate::UseNewStyle()) {
const bool use_new_style = dialog ?
dialog->UseNewStyleForThisDialog() : DialogDelegate::UseNewStyle();
if (use_new_style) {
// Note: Transparent widgets cannot host native Windows textfield controls.
params.transparent = true;
params.remove_standard_frame = true;
......@@ -48,7 +50,7 @@ Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog,
params.parent = parent;
params.top_level = true;
widget->Init(params);
if (DialogDelegate::UseNewStyle()) {
if (use_new_style) {
#if defined(USE_AURA)
// TODO(msw): Add a matching shadow type and remove the bubble frame border?
corewm::SetShadowType(widget->GetNativeWindow(), corewm::SHADOW_TYPE_NONE);
......@@ -155,8 +157,9 @@ ClientView* DialogDelegate::CreateClientView(Widget* widget) {
}
NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) {
return UseNewStyle() ? CreateNewStyleFrameView(widget) :
WidgetDelegate::CreateNonClientFrameView(widget);
if (UseNewStyleForThisDialog())
return CreateNewStyleFrameView(widget);
return WidgetDelegate::CreateNonClientFrameView(widget);
}
// static
......@@ -193,6 +196,10 @@ NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(
return frame;
}
bool DialogDelegate::UseNewStyleForThisDialog() const {
return UseNewStyle();
}
const DialogClientView* DialogDelegate::GetDialogClientView() const {
return GetWidget()->client_view()->AsDialogClientView();
}
......
......@@ -31,7 +31,8 @@ class VIEWS_EXPORT DialogDelegate : public ui::DialogModel,
public:
virtual ~DialogDelegate();
// Returns whether to use the new dialog style.
// Returns whether to use the new dialog style in general.
// See UseNewStyleForThisDialog() for dialog-specific styling.
static bool UseNewStyle();
// Create a |dialog| window Widget with the specified |context| or |parent|.
......@@ -96,6 +97,9 @@ class VIEWS_EXPORT DialogDelegate : public ui::DialogModel,
static NonClientFrameView* CreateNewStyleFrameView(Widget* widget,
bool force_opaque_border);
// Returns whether this particular dialog should use the new dialog style.
virtual bool UseNewStyleForThisDialog() const;
// Called when the window has been closed.
virtual void OnClose() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment