|
64 | 64 | } |
65 | 65 | } |
66 | 66 |
|
67 | | - // Reduce minimum acceptable side panel content width without changing the default size. |
68 | | - --- a/chrome/browser/ui/views/side_panel/side_panel.cc |
69 | | - +++ b/chrome/browser/ui/views/side_panel/side_panel.cc |
70 | | - @@ -419,8 +419,7 @@ void SidePanel::UpdateWidthOnEntryChange |
71 | | - // 1. Use the user's manually resized width |
72 | | - // 2. Use the side panels default width |
73 | | - // NOTE: If not specified, the side panel will default to |
74 | | - - // SidePanelEntry::kSidePanelDefaultContentWidth which evaluates to the same |
75 | | - - // value as GetMinimumSize(). |
76 | | - + // SidePanelEntry::kSidePanelDefaultContentWidth |
77 | | - if (std::optional<int> width_from_pref = dict.FindInt(panel_id)) { |
78 | | - SetPanelWidth(width_from_pref.value()); |
79 | | - } else { |
80 | | - @@ -444,6 +443,13 @@ bool SidePanel::IsRightAligned() const { |
81 | | - gfx::Size SidePanel::GetMinimumSize() const { |
82 | | - const int min_height = 0; |
83 | | - return gfx::Size( |
84 | | - + SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), |
85 | | - + min_height); |
86 | | - +} |
87 | | - + |
88 | | - +gfx::Size SidePanel::GetDefaultSize() const { |
89 | | - + const int min_height = 0; |
90 | | - + return gfx::Size( |
91 | | - SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), |
92 | | - min_height); |
93 | | - } |
94 | | - @@ -614,6 +620,13 @@ void SidePanel::OnResize(int resize_amou |
95 | | - proposed_width = minimum_width; |
96 | | - } |
97 | | - |
98 | | - + // Snap to default_width if the proposed_width is close enough. |
99 | | - + const int default_width = GetDefaultSize().width(); |
100 | | - + const int snap_diff = 20; |
101 | | - + if (abs(proposed_width - default_width) < snap_diff) { |
102 | | - + proposed_width = default_width; |
103 | | - + } |
104 | | - + |
105 | | - if (width() != proposed_width) { |
106 | | - if (SidePanelUI* side_panel_ui = |
107 | | - browser_view_->browser()->GetFeatures().side_panel_ui()) { |
108 | | - --- a/chrome/browser/ui/views/side_panel/side_panel_entry.h |
109 | | - +++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h |
110 | | - @@ -38,8 +38,10 @@ class SidePanelEntry final : public ui:: |
111 | | - kToolbar, |
112 | | - }; |
113 | | - |
114 | | - - // The default and minimum acceptable side panel content width. |
115 | | - + // The default side panel content width. |
116 | | - static constexpr int kSidePanelDefaultContentWidth = 360; |
117 | | - + // The minimum acceptable side panel content width |
118 | | - + static constexpr int kSidePanelMinimumContentWidth = 260; |
119 | | - using CreateContentCallback = |
120 | | - base::RepeatingCallback<std::unique_ptr<views::View>( |
121 | | - SidePanelEntryScope&)>; |
122 | | - --- a/chrome/browser/ui/views/side_panel/side_panel.h |
123 | | - +++ b/chrome/browser/ui/views/side_panel/side_panel.h |
124 | | - @@ -51,6 +51,7 @@ class SidePanel : public views::Accessib |
125 | | - HorizontalAlignment GetHorizontalAlignment() const; |
126 | | - bool IsRightAligned() const; |
127 | | - gfx::Size GetMinimumSize() const override; |
128 | | - + gfx::Size GetDefaultSize() const; |
129 | | - bool IsClosing(); |
130 | | - void DisableAnimationsForTesting() { animations_disabled_ = true; } |
131 | | - void SetKeyboardResized(bool keyboard_resized) { |
| 67 | +// Reduce minimum acceptable side panel content width without changing the default size. |
| 68 | +--- a/chrome/browser/ui/views/side_panel/side_panel.cc |
| 69 | ++++ b/chrome/browser/ui/views/side_panel/side_panel.cc |
| 70 | +@@ -419,8 +419,7 @@ void SidePanel::UpdateWidthOnEntryChange |
| 71 | +// 1. Use the user's manually resized width |
| 72 | +// 2. Use the side panels default width |
| 73 | +// NOTE: If not specified, the side panel will default to |
| 74 | +- // SidePanelEntry::kSidePanelDefaultContentWidth which evaluates to the same |
| 75 | +- // value as GetMinimumSize(). |
| 76 | ++ // SidePanelEntry::kSidePanelDefaultContentWidth |
| 77 | +if (std::optional<int> width_from_pref = dict.FindInt(panel_id)) { |
| 78 | + SetPanelWidth(width_from_pref.value()); |
| 79 | +} else { |
| 80 | +@@ -444,6 +443,13 @@ bool SidePanel::IsRightAligned() const { |
| 81 | +gfx::Size SidePanel::GetMinimumSize() const { |
| 82 | +const int min_height = 0; |
| 83 | +return gfx::Size( |
| 84 | ++ SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), |
| 85 | ++ min_height); |
| 86 | ++} |
| 87 | ++ |
| 88 | ++gfx::Size SidePanel::GetDefaultSize() const { |
| 89 | ++ const int min_height = 0; |
| 90 | ++ return gfx::Size( |
| 91 | + SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), |
| 92 | + min_height); |
| 93 | +} |
| 94 | +@@ -614,6 +620,13 @@ void SidePanel::OnResize(int resize_amou |
| 95 | + proposed_width = minimum_width; |
| 96 | +} |
| 97 | + |
| 98 | ++ // Snap to default_width if the proposed_width is close enough. |
| 99 | ++ const int default_width = GetDefaultSize().width(); |
| 100 | ++ const int snap_diff = 20; |
| 101 | ++ if (abs(proposed_width - default_width) < snap_diff) { |
| 102 | ++ proposed_width = default_width; |
| 103 | ++ } |
| 104 | ++ |
| 105 | +if (width() != proposed_width) { |
| 106 | + if (SidePanelUI* side_panel_ui = |
| 107 | + browser_view_->browser()->GetFeatures().side_panel_ui()) { |
| 108 | +--- a/chrome/browser/ui/views/side_panel/side_panel_entry.h |
| 109 | ++++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h |
| 110 | +@@ -38,8 +38,10 @@ class SidePanelEntry final : public ui:: |
| 111 | + kToolbar, |
| 112 | +}; |
| 113 | + |
| 114 | +- // The default and minimum acceptable side panel content width. |
| 115 | ++ // The default side panel content width. |
| 116 | +static constexpr int kSidePanelDefaultContentWidth = 360; |
| 117 | ++ // The minimum acceptable side panel content width |
| 118 | ++ static constexpr int kSidePanelMinimumContentWidth = 260; |
| 119 | +using CreateContentCallback = |
| 120 | + base::RepeatingCallback<std::unique_ptr<views::View>( |
| 121 | + SidePanelEntryScope&)>; |
| 122 | +--- a/chrome/browser/ui/views/side_panel/side_panel.h |
| 123 | ++++ b/chrome/browser/ui/views/side_panel/side_panel.h |
| 124 | +@@ -51,6 +51,7 @@ class SidePanel : public views::Accessib |
| 125 | +HorizontalAlignment GetHorizontalAlignment() const; |
| 126 | +bool IsRightAligned() const; |
| 127 | +gfx::Size GetMinimumSize() const override; |
| 128 | ++ gfx::Size GetDefaultSize() const; |
| 129 | +bool IsClosing(); |
| 130 | +void DisableAnimationsForTesting() { animations_disabled_ = true; } |
| 131 | +void SetKeyboardResized(bool keyboard_resized) { |
0 commit comments