#ifndef UI_VIEWS_CONTROLS_HIGHLIGHT_PATH_GENERATOR_H_
#define UI_VIEWS_CONTROLS_HIGHLIGHT_PATH_GENERATOR_H_
#include <memory>
#include <optional>
#include "third_party/skia/include/core/SkPath.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/views/views_export.h"
namespace gfx {
class RRectF;
}
namespace views {
class View;
class VIEWS_EXPORT HighlightPathGenerator {
public:
HighlightPathGenerator();
explicit HighlightPathGenerator(const gfx::Insets& insets);
virtual ~HighlightPathGenerator();
HighlightPathGenerator(const HighlightPathGenerator&) = delete;
HighlightPathGenerator& operator=(const HighlightPathGenerator&) = delete;
static void Install(View* host,
std::unique_ptr<HighlightPathGenerator> generator);
static std::optional<gfx::RRectF> GetRoundRectForView(const View* view);
virtual SkPath GetHighlightPath(const View* view);
virtual std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect);
std::optional<gfx::RRectF> GetRoundRect(const View* view);
void set_use_contents_bounds(bool use_contents_bounds) {
use_contents_bounds_ = use_contents_bounds;
}
void set_use_mirrored_rect(bool use_mirrored_rect) {
use_mirrored_rect_ = use_mirrored_rect;
}
private:
const gfx::Insets insets_;
bool use_contents_bounds_ = false;
bool use_mirrored_rect_ = false;
};
class VIEWS_EXPORT EmptyHighlightPathGenerator : public HighlightPathGenerator {
public:
EmptyHighlightPathGenerator() = default;
EmptyHighlightPathGenerator(const EmptyHighlightPathGenerator&) = delete;
EmptyHighlightPathGenerator& operator=(const EmptyHighlightPathGenerator&) =
delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallEmptyHighlightPathGenerator(View* view);
class VIEWS_EXPORT RectHighlightPathGenerator : public HighlightPathGenerator {
public:
RectHighlightPathGenerator() = default;
RectHighlightPathGenerator(const RectHighlightPathGenerator&) = delete;
RectHighlightPathGenerator& operator=(const RectHighlightPathGenerator&) =
delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallRectHighlightPathGenerator(View* view);
class VIEWS_EXPORT CircleHighlightPathGenerator
: public HighlightPathGenerator {
public:
explicit CircleHighlightPathGenerator(const gfx::Insets& insets);
CircleHighlightPathGenerator(const CircleHighlightPathGenerator&) = delete;
CircleHighlightPathGenerator& operator=(const CircleHighlightPathGenerator&) =
delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallCircleHighlightPathGenerator(View* view);
void VIEWS_EXPORT
InstallCircleHighlightPathGenerator(View* view, const gfx::Insets& insets);
class VIEWS_EXPORT PillHighlightPathGenerator : public HighlightPathGenerator {
public:
PillHighlightPathGenerator() = default;
PillHighlightPathGenerator(const PillHighlightPathGenerator&) = delete;
PillHighlightPathGenerator& operator=(const PillHighlightPathGenerator&) =
delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallPillHighlightPathGenerator(View* view);
class VIEWS_EXPORT FixedSizeCircleHighlightPathGenerator
: public HighlightPathGenerator {
public:
explicit FixedSizeCircleHighlightPathGenerator(int radius);
FixedSizeCircleHighlightPathGenerator(
const FixedSizeCircleHighlightPathGenerator&) = delete;
FixedSizeCircleHighlightPathGenerator& operator=(
const FixedSizeCircleHighlightPathGenerator&) = delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
private:
const int radius_;
};
void VIEWS_EXPORT InstallFixedSizeCircleHighlightPathGenerator(View* view,
int radius);
class VIEWS_EXPORT RoundRectHighlightPathGenerator
: public HighlightPathGenerator {
public:
RoundRectHighlightPathGenerator(const gfx::Insets& insets, int corner_radius);
RoundRectHighlightPathGenerator(const gfx::Insets& insets,
const gfx::RoundedCornersF& rounded_corners);
RoundRectHighlightPathGenerator(const RoundRectHighlightPathGenerator&) =
delete;
RoundRectHighlightPathGenerator& operator=(
const RoundRectHighlightPathGenerator&) = delete;
std::optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
private:
const gfx::RoundedCornersF rounded_corners_;
};
void VIEWS_EXPORT
InstallRoundRectHighlightPathGenerator(View* view,
const gfx::Insets& insets,
int corner_radius);
void VIEWS_EXPORT InstallRoundRectHighlightPathGenerator(
View* view,
const gfx::Insets& insets,
const gfx::RoundedCornersF& corner_radii);
}
#endif