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

Unified Diff: ui/views/examples/multiline_example.h

Issue 1953133002: [WIP: not for review] Reduce re-layout Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: ui/views/examples/multiline_example.h
diff --git a/ui/views/examples/multiline_example.h b/ui/views/examples/multiline_example.h
index a4c3ba56ea0d3de17867b20677d2cc3eb56e0307..10d13409b1baa0537d902c817c875294f7096473 100644
--- a/ui/views/examples/multiline_example.h
+++ b/ui/views/examples/multiline_example.h
@@ -10,6 +10,10 @@
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/examples/example_base.h"
+namespace gfx {
+class RenderText;
+}
+
namespace views {
class Checkbox;
@@ -22,7 +26,7 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase,
public TextfieldController,
public ButtonListener {
public:
- MultilineExample();
+ explicit MultilineExample(const char* name);
~MultilineExample() override;
// ExampleBase:
@@ -31,13 +35,16 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase,
// ButtonListener:
void ButtonPressed(Button* sender, const ui::Event& event) override;
- private:
+ protected:
class RenderTextView;
+ virtual RenderTextView* CreateTextView();
+
// TextfieldController:
void ContentsChanged(Textfield* sender,
const base::string16& new_contents) override;
+ private:
RenderTextView* render_text_view_;
Label* label_;
Textfield* textfield_;
@@ -48,6 +55,27 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase,
DISALLOW_COPY_AND_ASSIGN(MultilineExample);
};
+// A simple View that hosts a RenderText object.
+class MultilineExample::RenderTextView : public View {
+ public:
+ RenderTextView();
+ ~RenderTextView() override;
+
+ void SetText(const base::string16& new_contents);
+ gfx::RenderText* render_text() { return render_text_.get(); }
+
+ // View:
+ void OnPaint(gfx::Canvas* canvas) override;
+ gfx::Size GetPreferredSize() const override;
+ int GetHeightForWidth(int w) const override;
+ void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
+
+ private:
+ std::unique_ptr<gfx::RenderText> render_text_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderTextView);
+};
+
} // namespace examples
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698