#include "ui/views/examples/designer_example.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/ranges/ranges.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/metadata/metadata_types.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/events/event.h"
#include "ui/events/event_targeter.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/button/radio_button.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/table/table_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/examples/examples_color_id.h"
#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/metadata/view_factory.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view.h"
#include "ui/views/view_targeter.h"
namespace views::examples {
class DesignerSurface : public View { … };
DesignerSurface::DesignerSurface(int grid_size) : … { … }
void DesignerSurface::SetGridSize(int grid_size) { … }
void DesignerSurface::OnPaint(gfx::Canvas* canvas) { … }
void DesignerSurface::OnThemeChanged() { … }
void DesignerSurface::RebuildGridImage() { … }
BEGIN_METADATA(…)
BEGIN_VIEW_BUILDER(, DesignerSurface, View)
VIEW_BUILDER_PROPERTY(int, GridSize)
END_VIEW_BUILDER
}
DEFINE_VIEW_BUILDER(…)
namespace views::examples {
namespace {
ui::TableColumn MakeColumn(int id, std::u16string title, bool sortable) { … }
int SnapToInterval(int value, int interval) { … }
template <typename C>
class ClassRegistration : public BaseClassRegistration { … };
template <>
class ClassRegistration<Combobox> : public BaseClassRegistration,
public ui::ComboboxModel { … };
template <>
class ClassRegistration<MdTextButton> : public BaseClassRegistration { … };
template <>
class ClassRegistration<Textfield> : public BaseClassRegistration { … };
template <>
class ClassRegistration<Checkbox> : public BaseClassRegistration { … };
template <>
class ClassRegistration<RadioButton> : public BaseClassRegistration { … };
template <>
class ClassRegistration<ToggleButton> : public BaseClassRegistration { … };
template <>
class ClassRegistration<ImageButton> : public BaseClassRegistration { … };
std::vector<std::unique_ptr<BaseClassRegistration>> GetClassRegistrations() { … }
bool IsViewParent(View* parent, View* view) { … }
View* GetDesignerChild(View* child_view, View* designer) { … }
}
BaseClassRegistration::~BaseClassRegistration() = default;
DesignerExample::GrabHandle::GrabHandle(GrabHandles* grab_handles,
GrabHandlePosition position)
: … { … }
DesignerExample::GrabHandle::~GrabHandle() = default;
void DesignerExample::GrabHandle::SetAttachedView(View* view) { … }
void DesignerExample::GrabHandle::UpdatePosition(bool reorder) { … }
ui::Cursor DesignerExample::GrabHandle::GetCursor(const ui::MouseEvent& event) { … }
gfx::Size DesignerExample::GrabHandle::CalculatePreferredSize(
const SizeBounds& ) const { … }
void DesignerExample::GrabHandle::OnPaint(gfx::Canvas* canvas) { … }
bool DesignerExample::GrabHandle::OnMousePressed(const ui::MouseEvent& event) { … }
bool DesignerExample::GrabHandle::OnMouseDragged(const ui::MouseEvent& event) { … }
void DesignerExample::GrabHandle::PositionOnView() { … }
void DesignerExample::GrabHandle::UpdateViewSize() { … }
bool DesignerExample::GrabHandle::IsTop(GrabHandlePosition position) { … }
bool DesignerExample::GrabHandle::IsBottom(GrabHandlePosition position) { … }
bool DesignerExample::GrabHandle::IsLeft(GrabHandlePosition position) { … }
bool DesignerExample::GrabHandle::IsRight(GrabHandlePosition position) { … }
BEGIN_METADATA(…)
END_METADATA
DesignerExample::GrabHandles::GrabHandles() = default;
DesignerExample::GrabHandles::~GrabHandles() = default;
void DesignerExample::GrabHandles::Initialize(View* layout_panel) { … }
void DesignerExample::GrabHandles::SetAttachedView(View* view) { … }
bool DesignerExample::GrabHandles::IsGrabHandle(View* view) { … }
DesignerExample::DesignerExample() : … { … }
DesignerExample::~DesignerExample() { … }
void DesignerExample::CreateExampleView(View* container) { … }
void DesignerExample::OnEvent(ui::Event* event) { … }
void DesignerExample::HandleDesignerMouseEvent(ui::Event* event) { … }
void DesignerExample::SelectView(View* view) { … }
gfx::Vector2d DesignerExample::SnapToGrid(const gfx::Vector2d& distance) { … }
void DesignerExample::CreateView(const ui::Event& event) { … }
size_t DesignerExample::RowCount() { … }
std::u16string DesignerExample::GetText(size_t row, int column_id) { … }
void DesignerExample::SetObserver(ui::TableModelObserver* observer) { … }
size_t DesignerExample::GetItemCount() const { … }
std::u16string DesignerExample::GetItemAt(size_t index) const { … }
std::optional<size_t> DesignerExample::GetDefaultIndex() const { … }
}