| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "ui/base/models/combobox_model.h" | 11 #include "ui/base/models/combobox_model.h" |
| 12 #include "ui/views/background.h" | 12 #include "ui/views/background.h" |
| 13 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/button/checkbox.h" | 14 #include "ui/views/controls/button/checkbox.h" |
| 15 #include "ui/views/controls/button/label_button.h" | 15 #include "ui/views/controls/button/label_button.h" |
| 16 #include "ui/views/controls/button/md_text_button.h" |
| 16 #include "ui/views/controls/button/radio_button.h" | 17 #include "ui/views/controls/button/radio_button.h" |
| 17 #include "ui/views/controls/combobox/combobox.h" | 18 #include "ui/views/controls/combobox/combobox.h" |
| 18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/controls/link.h" | 20 #include "ui/views/controls/link.h" |
| 20 #include "ui/views/controls/native/native_view_host.h" | 21 #include "ui/views/controls/native/native_view_host.h" |
| 21 #include "ui/views/controls/scroll_view.h" | 22 #include "ui/views/controls/scroll_view.h" |
| 22 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 23 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 23 #include "ui/views/controls/textfield/textfield.h" | 24 #include "ui/views/controls/textfield/textfield.h" |
| 24 #include "ui/views/focus/focus_manager.h" | 25 #include "ui/views/focus/focus_manager.h" |
| 25 #include "ui/views/test/focus_manager_test.h" | 26 #include "ui/views/test/focus_manager_test.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 label->SetBounds(label_x, y, label_width, label_height); | 369 label->SetBounds(label_x, y, label_width, label_height); |
| 369 | 370 |
| 370 text_field = new Textfield(); | 371 text_field = new Textfield(); |
| 371 text_field->set_id(kKiwiTextfieldID); | 372 text_field->set_id(kKiwiTextfieldID); |
| 372 left_container_->AddChildView(text_field); | 373 left_container_->AddChildView(text_field); |
| 373 text_field->SetBounds(label_x + label_width + 5, y, | 374 text_field->SetBounds(label_x + label_width + 5, y, |
| 374 text_field_width, label_height); | 375 text_field_width, label_height); |
| 375 | 376 |
| 376 y += label_height + gap_between_labels; | 377 y += label_height + gap_between_labels; |
| 377 | 378 |
| 378 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16("Click me")); | 379 LabelButton* button = |
| 379 button->SetStyle(Button::STYLE_BUTTON); | 380 MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("Click me")); |
| 380 button->SetBounds(label_x, y + 10, 80, 30); | 381 button->SetBounds(label_x, y + 10, 80, 30); |
| 381 button->set_id(kFruitButtonID); | 382 button->set_id(kFruitButtonID); |
| 382 left_container_->AddChildView(button); | 383 left_container_->AddChildView(button); |
| 383 y += 40; | 384 y += 40; |
| 384 | 385 |
| 385 cb = new Checkbox(ASCIIToUTF16("This is another check box")); | 386 cb = new Checkbox(ASCIIToUTF16("This is another check box")); |
| 386 cb->SetBounds(label_x + label_width + 5, y, 180, 20); | 387 cb->SetBounds(label_x + label_width + 5, y, 180, 20); |
| 387 cb->set_id(kFruitCheckBoxID); | 388 cb->set_id(kFruitCheckBoxID); |
| 388 left_container_->AddChildView(cb); | 389 left_container_->AddChildView(cb); |
| 389 y += 20; | 390 y += 20; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 Link* link = new Link(ASCIIToUTF16(kTitles[i])); | 465 Link* link = new Link(ASCIIToUTF16(kTitles[i])); |
| 465 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 466 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 466 link->set_id(kIDs[i]); | 467 link->set_id(kIDs[i]); |
| 467 scroll_content->AddChildView(link); | 468 scroll_content->AddChildView(link); |
| 468 link->SetBounds(5, y, 300, 15); | 469 link->SetBounds(5, y, 300, 15); |
| 469 y += 15; | 470 y += 15; |
| 470 } | 471 } |
| 471 | 472 |
| 472 y = 250; | 473 y = 250; |
| 473 int width = 60; | 474 int width = 60; |
| 474 button = new LabelButton(NULL, ASCIIToUTF16("OK")); | 475 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("OK")); |
| 475 button->SetStyle(Button::STYLE_BUTTON); | |
| 476 button->set_id(kOKButtonID); | 476 button->set_id(kOKButtonID); |
| 477 button->SetIsDefault(true); | 477 button->SetIsDefault(true); |
| 478 | 478 |
| 479 GetContentsView()->AddChildView(button); | 479 GetContentsView()->AddChildView(button); |
| 480 button->SetBounds(150, y, width, 30); | 480 button->SetBounds(150, y, width, 30); |
| 481 | 481 |
| 482 button = new LabelButton(NULL, ASCIIToUTF16("Cancel")); | 482 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("Cancel")); |
| 483 button->SetStyle(Button::STYLE_BUTTON); | |
| 484 button->set_id(kCancelButtonID); | 483 button->set_id(kCancelButtonID); |
| 485 GetContentsView()->AddChildView(button); | 484 GetContentsView()->AddChildView(button); |
| 486 button->SetBounds(220, y, width, 30); | 485 button->SetBounds(220, y, width, 30); |
| 487 | 486 |
| 488 button = new LabelButton(NULL, ASCIIToUTF16("Help")); | 487 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("Help")); |
| 489 button->SetStyle(Button::STYLE_BUTTON); | |
| 490 button->set_id(kHelpButtonID); | 488 button->set_id(kHelpButtonID); |
| 491 GetContentsView()->AddChildView(button); | 489 GetContentsView()->AddChildView(button); |
| 492 button->SetBounds(290, y, width, 30); | 490 button->SetBounds(290, y, width, 30); |
| 493 | 491 |
| 494 y += 40; | 492 y += 40; |
| 495 | 493 |
| 496 View* contents = NULL; | 494 View* contents = NULL; |
| 497 Link* link = NULL; | 495 Link* link = NULL; |
| 498 | 496 |
| 499 // Left bottom box with style checkboxes. | 497 // Left bottom box with style checkboxes. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 style_tab_->AddTab(ASCIIToUTF16("Other"), new View()); | 530 style_tab_->AddTab(ASCIIToUTF16("Other"), new View()); |
| 533 | 531 |
| 534 // Right bottom box with search. | 532 // Right bottom box with search. |
| 535 contents = new View(); | 533 contents = new View(); |
| 536 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); | 534 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); |
| 537 text_field = new Textfield(); | 535 text_field = new Textfield(); |
| 538 contents->AddChildView(text_field); | 536 contents->AddChildView(text_field); |
| 539 text_field->SetBounds(10, 10, 100, 20); | 537 text_field->SetBounds(10, 10, 100, 20); |
| 540 text_field->set_id(kSearchTextfieldID); | 538 text_field->set_id(kSearchTextfieldID); |
| 541 | 539 |
| 542 button = new LabelButton(NULL, ASCIIToUTF16("Search")); | 540 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("Search")); |
| 543 button->SetStyle(Button::STYLE_BUTTON); | |
| 544 contents->AddChildView(button); | 541 contents->AddChildView(button); |
| 545 button->SetBounds(112, 5, 60, 30); | 542 button->SetBounds(112, 5, 60, 30); |
| 546 button->set_id(kSearchButtonID); | 543 button->set_id(kSearchButtonID); |
| 547 | 544 |
| 548 link = new Link(ASCIIToUTF16("Help")); | 545 link = new Link(ASCIIToUTF16("Help")); |
| 549 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 546 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 550 link->set_id(kHelpLinkID); | 547 link->set_id(kHelpLinkID); |
| 551 contents->AddChildView(link); | 548 contents->AddChildView(link); |
| 552 link->SetBounds(175, 10, 30, 20); | 549 link->SetBounds(175, 10, 30, 20); |
| 553 | 550 |
| 554 search_border_view_ = new BorderView(contents); | 551 search_border_view_ = new BorderView(contents); |
| 555 search_border_view_->set_id(kSearchContainerID); | 552 search_border_view_->set_id(kSearchContainerID); |
| 556 | 553 |
| 557 GetContentsView()->AddChildView(search_border_view_); | 554 GetContentsView()->AddChildView(search_border_view_); |
| 558 search_border_view_->SetBounds(300, y, 240, 50); | 555 search_border_view_->SetBounds(300, y, 240, 50); |
| 559 | 556 |
| 560 y += 60; | 557 y += 60; |
| 561 | 558 |
| 562 contents = new View(); | 559 contents = new View(); |
| 563 contents->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 560 contents->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
| 564 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); | 561 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); |
| 565 contents->set_id(kThumbnailContainerID); | 562 contents->set_id(kThumbnailContainerID); |
| 566 button = new LabelButton(NULL, ASCIIToUTF16("Star")); | 563 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("Star")); |
| 567 button->SetStyle(Button::STYLE_BUTTON); | |
| 568 contents->AddChildView(button); | 564 contents->AddChildView(button); |
| 569 button->SetBounds(5, 5, 50, 30); | 565 button->SetBounds(5, 5, 50, 30); |
| 570 button->set_id(kThumbnailStarID); | 566 button->set_id(kThumbnailStarID); |
| 571 button = new LabelButton(NULL, ASCIIToUTF16("SuperStar")); | 567 button = MdTextButton::CreateMdButton(NULL, ASCIIToUTF16("SuperStar")); |
| 572 button->SetStyle(Button::STYLE_BUTTON); | |
| 573 contents->AddChildView(button); | 568 contents->AddChildView(button); |
| 574 button->SetBounds(60, 5, 100, 30); | 569 button->SetBounds(60, 5, 100, 30); |
| 575 button->set_id(kThumbnailSuperStarID); | 570 button->set_id(kThumbnailSuperStarID); |
| 576 | 571 |
| 577 GetContentsView()->AddChildView(contents); | 572 GetContentsView()->AddChildView(contents); |
| 578 contents->SetBounds(250, y, 200, 50); | 573 contents->SetBounds(250, y, 200, 50); |
| 579 // We can only call RadioButton::SetChecked() on the radio-button is part of | 574 // We can only call RadioButton::SetChecked() on the radio-button is part of |
| 580 // the view hierarchy. | 575 // the view hierarchy. |
| 581 radio_button_to_check->SetChecked(true); | 576 radio_button_to_check->SetChecked(true); |
| 582 } | 577 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 GetFocusManager()->AdvanceFocus(false); | 840 GetFocusManager()->AdvanceFocus(false); |
| 846 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 841 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
| 847 | 842 |
| 848 // Advance backwards from the root node. | 843 // Advance backwards from the root node. |
| 849 GetFocusManager()->ClearFocus(); | 844 GetFocusManager()->ClearFocus(); |
| 850 GetFocusManager()->AdvanceFocus(true); | 845 GetFocusManager()->AdvanceFocus(true); |
| 851 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 846 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
| 852 } | 847 } |
| 853 | 848 |
| 854 } // namespace views | 849 } // namespace views |
| OLD | NEW |