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

Side by Side Diff: views/view.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DisableOnHover test? Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/view.h" 5 #include "views/view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 // FATE TBD -------------------------------------------------------------------- 89 // FATE TBD --------------------------------------------------------------------
90 90
91 Widget* View::GetChildWidget() { 91 Widget* View::GetChildWidget() {
92 return NULL; 92 return NULL;
93 } 93 }
94 94
95 // Creation and lifetime ------------------------------------------------------- 95 // Creation and lifetime -------------------------------------------------------
96 96
97 View::View() 97 View::View()
98 : enabled_(true), 98 : focusable_(false),
99 focusable_(false),
100 parent_owned_(true), 99 parent_owned_(true),
101 id_(0), 100 id_(0),
102 group_(-1), 101 group_(-1),
103 parent_(NULL), 102 parent_(NULL),
104 is_visible_(true), 103 is_visible_(true),
104 enabled_(true),
105 registered_for_visible_bounds_notification_(false), 105 registered_for_visible_bounds_notification_(false),
106 clip_x_(0.0), 106 clip_x_(0.0),
107 clip_y_(0.0), 107 clip_y_(0.0),
108 needs_layout_(true), 108 needs_layout_(true),
109 flip_canvas_on_paint_for_rtl_ui_(false), 109 flip_canvas_on_paint_for_rtl_ui_(false),
110 #if !defined(COMPOSITOR_2) 110 #if !defined(COMPOSITOR_2)
111 texture_id_(0), // TODO(sadrul): 0 can be a valid texture id. 111 texture_id_(0), // TODO(sadrul): 0 can be a valid texture id.
112 #endif 112 #endif
113 texture_needs_updating_(true), 113 texture_needs_updating_(true),
114 accelerator_registration_delayed_(false), 114 accelerator_registration_delayed_(false),
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 gfx::Size View::GetMinimumSize() { 346 gfx::Size View::GetMinimumSize() {
347 return GetPreferredSize(); 347 return GetPreferredSize();
348 } 348 }
349 349
350 int View::GetHeightForWidth(int w) { 350 int View::GetHeightForWidth(int w) {
351 if (layout_manager_.get()) 351 if (layout_manager_.get())
352 return layout_manager_->GetPreferredHeightForWidth(this, w); 352 return layout_manager_->GetPreferredHeightForWidth(this, w);
353 return GetPreferredSize().height(); 353 return GetPreferredSize().height();
354 } 354 }
355 355
356 void View::SetVisible(bool flag) { 356 void View::SetVisible(bool visible) {
357 if (flag != is_visible_) { 357 if (visible != is_visible_) {
358 // If the tab is currently visible, schedule paint to 358 // If the tab is currently visible, schedule paint to refresh parent.
359 // refresh parent 359 if (is_visible_)
360 if (IsVisible())
361 SchedulePaint(); 360 SchedulePaint();
362 else 361 else
363 ResetTexture(); 362 ResetTexture();
364 363
365 is_visible_ = flag; 364 is_visible_ = visible;
366 365
367 // This notifies all sub-views recursively. 366 // This notifies all sub-views recursively.
368 PropagateVisibilityNotifications(this, flag); 367 PropagateVisibilityNotifications(this, is_visible_);
369 368
370 // If we are newly visible, schedule paint. 369 // If we are newly visible, schedule paint.
371 if (IsVisible()) 370 if (is_visible_)
372 SchedulePaint(); 371 SchedulePaint();
373 } 372 }
374 } 373 }
375 374
376 bool View::IsVisible() const { 375 bool View::IsVisible() const {
377 return is_visible_; 376 return is_visible_;
378 } 377 }
379 378
380 bool View::IsVisibleInRootView() const { 379 bool View::IsVisibleInRootView() const {
381 return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false; 380 return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false;
382 } 381 }
383 382
384 void View::SetEnabled(bool state) { 383 void View::SetEnabled(bool enabled) {
385 if (enabled_ != state) { 384 if (enabled != enabled_) {
386 enabled_ = state; 385 enabled_ = enabled;
387 SchedulePaint(); 386 OnEnabledChanged();
388 } 387 }
389 } 388 }
390 389
391 bool View::IsEnabled() const { 390 bool View::IsEnabled() const {
392 return enabled_; 391 return enabled_;
393 } 392 }
394 393
394 void View::OnEnabledChanged() {
395 SchedulePaint();
396 }
397
395 // Transformations ------------------------------------------------------------- 398 // Transformations -------------------------------------------------------------
396 399
397 const ui::Transform& View::GetTransform() const { 400 const ui::Transform& View::GetTransform() const {
398 static const ui::Transform* no_op = new ui::Transform; 401 static const ui::Transform* no_op = new ui::Transform;
399 if (transform_.get()) 402 if (transform_.get())
400 return *transform_.get(); 403 return *transform_.get();
401 return *no_op; 404 return *no_op;
402 } 405 }
403 406
404 void View::SetTransform(const ui::Transform& transform) { 407 void View::SetTransform(const ui::Transform& transform) {
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 result.append(GetChildViewAt(i)->PrintViewGraph(false)); 1869 result.append(GetChildViewAt(i)->PrintViewGraph(false));
1867 1870
1868 if (first) 1871 if (first)
1869 result.append("}\n"); 1872 result.append("}\n");
1870 1873
1871 return result; 1874 return result;
1872 } 1875 }
1873 #endif 1876 #endif
1874 1877
1875 } // namespace views 1878 } // namespace views
OLDNEW
« no previous file with comments | « views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698