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

Unified Diff: ui/views/anchor_attribute.h

Issue 2230913003: Experimental alignment layout manager using a property on the views Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed AlignAttribute and associated types to FillAttribute Created 4 years, 2 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 | « ui/views/BUILD.gn ('k') | ui/views/anchor_attribute.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/anchor_attribute.h
diff --git a/ui/views/anchor_attribute.h b/ui/views/anchor_attribute.h
new file mode 100644
index 0000000000000000000000000000000000000000..1e690b1f4880d105f1f6cf12f95f706ff9a8d103
--- /dev/null
+++ b/ui/views/anchor_attribute.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_ANCHOR_ATTRIBUTE_H_
+#define UI_VIEWS_ANCHOR_ATTRIBUTE_H_
+
+#include "base/macros.h"
+#include "base/set_template.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/views/attributes.h"
+#include "ui/views/fill_attribute.h"
+#include "ui/views/view.h"
+
+namespace views {
+
+enum class Anchor {
+ // Anchor view's left side to the parent's left side of its content bounds.
+ Left,
+ // Anchor view's top side to the parent's top side of its content bounds.
+ Top,
+ // Anchor view's right side to the parent's right side of its content
+ // bounds.
+ Right,
+ // Anchor view's bottom side to the parent's bottom side of its content
+ // bounds.
+ Bottom,
+};
+
+using Anchors = base::SetOf<Anchor, Anchor::Bottom>;
+
+struct VIEWS_EXPORT AnchorContent {
+ AnchorContent();
+ AnchorContent(Anchors anchors);
+ AnchorContent(const AnchorContent& content);
+ static Anchors AnchorFill(Fill fill);
+ gfx::Point& anchorBasis() { return anchor_basis_; }
+ Anchors& anchors() { return anchors_; }
+ gfx::Size& LastParentSize() { return last_parent_size_; }
+ void SetAnchors(Anchors anchors);
+ void SetAttribute(Attribute *attribute) { attribute_ = attribute; }
+ void UpdateAnchorBasis(View *view);
+ private:
+ Attribute *attribute_;
+ Anchors anchors_;
+ gfx::Point anchor_basis_;
+ gfx::Size last_parent_size_;
+};
+
+class VIEWS_EXPORT AnchorAttribute : public CustomAttribute<AnchorContent> {
+ public:
+ AnchorAttribute();
+ AnchorAttribute(Anchors anchors);
+ AnchorAttribute(AnchorContent& content);
+ AttributeId Identity() const override;
+ void Notification(Attribute::NotifyType type, Attribute* attribute) override;
+ void ViewNotification(View *view) override;
+};
+
+REGISTER_ATTRIBUTE_ID(CustomAttribute<AnchorContent>);
+REGISTER_ATTRIBUTE_ID(AnchorAttribute);
+
+} // namespace views
+
+#endif // UI_VIEWS_ANCHOR_ATTRIBUTE_H_
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/anchor_attribute.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698