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

Unified Diff: ui/views/demo/main.cc

Issue 6541030: View API/implementation cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/events/event.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/demo/main.cc
===================================================================
--- ui/views/demo/main.cc (revision 75141)
+++ ui/views/demo/main.cc (working copy)
@@ -88,8 +88,9 @@
// Overridden from ui::View:
virtual void Layout() {
- c1_->SetBounds(20, 20, width() - 40, height() - 40);
- c2_->SetBounds(50, 50, 50, 50);
+ c1_->SetBounds(gfx::Rect(20, 20, std::max(width() - 40, 0),
+ std::max(height() - 40, 0)));
+ c2_->SetBounds(gfx::Rect(50, 50, 50, 50));
Invalidate();
}
virtual bool OnMousePressed(const ui::MouseEvent& event) {
@@ -100,8 +101,8 @@
}
virtual bool OnMouseDragged(const ui::MouseEvent& event) {
gfx::Rect old_bounds = bounds();
- SetPosition(gfx::Point(event.x() - mouse_offset_.x(),
- event.y() - mouse_offset_.y()));
+ SetOrigin(gfx::Point(event.x() - mouse_offset_.x(),
+ event.y() - mouse_offset_.y()));
gfx::Rect new_bounds = bounds();
parent()->InvalidateRect(old_bounds.Union(new_bounds));
return true;
@@ -135,7 +136,7 @@
set_parent_owned(false);
AddChildView(c1_);
AddChildView(c2_);
- c3_->SetPosition(gfx::Point(200, 200));
+ c3_->SetOrigin(gfx::Point(200, 200));
AddChildView(c3_);
}
@@ -148,8 +149,9 @@
private:
// Overridden from ui::View:
virtual void Layout() {
- c1_->SetBounds(20, 20, width() - 40, height() - 40);
- c2_->SetBounds(50, 50, 50, 50);
+ c1_->SetBounds(gfx::Rect(20, 20, std::max(width() - 40, 0),
+ std::max(height() - 40, 0)));
+ c2_->SetBounds(gfx::Rect(50, 50, 50, 50));
c3_->SetSize(gfx::Size(75, 75));
Invalidate();
}
« no previous file with comments | « no previous file | ui/views/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698