#include "ui/views/examples/layout_example_base.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/examples/example_combobox_model.h"
#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view_class_properties.h"
namespace views::examples {
namespace {
constexpr int kLayoutExampleVerticalSpacing = …;
constexpr int kLayoutExampleLeftPadding = …;
constexpr gfx::Size kLayoutExampleDefaultChildSize(180, 90);
class LayoutPanel : public View { … };
BEGIN_METADATA(…)
std::unique_ptr<Textfield> CreateCommonTextfield(
TextfieldController* container) { … }
std::unique_ptr<Textfield> CreateCommonTextfieldWithAXName(
TextfieldController* container,
std::u16string name) { … }
}
void LayoutExampleBase::InsetTextfields::ResetControllers() { … }
LayoutExampleBase::ChildPanel::ChildPanel(LayoutExampleBase* example)
: … { … }
LayoutExampleBase::ChildPanel::~ChildPanel() = default;
bool LayoutExampleBase::ChildPanel::OnMousePressed(
const ui::MouseEvent& event) { … }
ProposedLayout LayoutExampleBase::ChildPanel::CalculateProposedLayout(
const SizeBounds& size_bounds) const { … }
void LayoutExampleBase::ChildPanel::SetSelected(bool value) { … }
int LayoutExampleBase::ChildPanel::GetFlex() const { … }
void LayoutExampleBase::ChildPanel::OnThemeChanged() { … }
void LayoutExampleBase::ChildPanel::ContentsChanged(
Textfield* sender,
const std::u16string& new_contents) { … }
Textfield* LayoutExampleBase::ChildPanel::CreateTextfield(
const std::u16string& name) { … }
BEGIN_METADATA(…)
END_METADATA
LayoutExampleBase::LayoutExampleBase(const char* title) : … { … }
LayoutExampleBase::~LayoutExampleBase() { … }
void LayoutExampleBase::RefreshLayoutPanel(bool update_layout) { … }
gfx::Insets LayoutExampleBase::TextfieldsToInsets(
const InsetTextfields& textfields,
const gfx::Insets& default_insets) { … }
Combobox* LayoutExampleBase::CreateAndAddCombobox(
const std::u16string& label_text,
base::span<const char* const> items,
base::RepeatingClosure combobox_callback) { … }
Textfield* LayoutExampleBase::CreateAndAddTextfield(
const std::u16string& label_text) { … }
void LayoutExampleBase::CreateMarginsTextFields(const std::u16string& label,
InsetTextfields* textfields) { … }
Checkbox* LayoutExampleBase::CreateAndAddCheckbox(
const std::u16string& label_text,
base::RepeatingClosure checkbox_callback) { … }
void LayoutExampleBase::CreateExampleView(View* container) { … }
gfx::Size LayoutExampleBase::GetNewChildPanelPreferredSize() { … }
void LayoutExampleBase::AddButtonPressed() { … }
}