[go: nahoru, domu]

tree: 7351f8782bbbcaaa0db8e369c62bd284fa87e889 [path history] [tgz]
  1. markdown_resources/
  2. arc_curve_path_util.cc
  3. arc_curve_path_util.h
  4. arc_curve_path_util_pixeltest.cc
  5. BUILD.gn
  6. cropping_util.cc
  7. cropping_util.h
  8. cropping_util_unittest.cc
  9. cursor_setter.cc
  10. cursor_setter.h
  11. haptics_tracking_test_input_controller.cc
  12. haptics_tracking_test_input_controller.h
  13. haptics_util_unittest.cc
  14. layer_copy_animator.cc
  15. layer_copy_animator.h
  16. layer_copy_animator_unittest.cc
  17. layer_util.cc
  18. layer_util.h
  19. layer_util_unittest.cc
  20. lottie_util.cc
  21. lottie_util.h
  22. lottie_util_unittest.cc
  23. occlusion_tracker_pauser.cc
  24. occlusion_tracker_pauser.h
  25. occlusion_tracker_pauser_unittest.cc
  26. persistent_proto.cc
  27. persistent_proto.h
  28. persistent_proto_test.proto
  29. persistent_proto_unittest.cc
  30. README.md
  31. rounded_window_targeter.cc
  32. rounded_window_targeter.h
  33. rounded_window_targeter_unittest.cc
  34. transformer_util.cc
  35. transformer_util.h
ash/utility/README.md

Ash Utility

Arc Curve Corner

Here is an example arc curve corner:

Alt

An arc curve corner is a corner shape consisting of arcs and lines. It can be specified with the following parameters:

  • width: The width of the arc curve corner. In this example, the width is 10+12+16+20*2=78.
  • height: The height of the arc curve corner. In this example, the height is 8+20+10=38.
  • convex radius: The radius of the convex rounded corner. In this example, this value is 10.
  • concave radius: The radius of the concave rounded corner. In this example, this value is 12.

NOTE: A valid arc curve corner must satisfy

  • width >= 2*convex_radius+concave_radius
  • height >= 2*convex_radius+concave_radius

Draw an arc curve corner in code

GetArcCurveRectPath() accepts three parameters:

  • size: The size of the bounding rectangle with an arc curve corner.
  • arc_curve_corner: An arc curve corner specified by the aforementioned parameters.
  • corner_radius: If given, specifies the corner radius of the corners that are not shaped with an arc curve.

Typically, we clip a view with the path returned by GetArcCurveRectPath() in the overridden OnBoundsChanged() function. For example:

class ViewWithArcCurveCorner : public views::View {
  // ...

  // views::View:
  void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
    SetClipPath(GetArcCurveRectPath(
                            GetContentsBounds().size(),
                            ArcCurveCorner(/*parameters...*/),
                            kCornerRadius));
  }
};