-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add separate padding settings for left, top, right and bottom #17909
base: main
Are you sure you want to change the base?
Changes from 3 commits
0eb788c
fa2eae3
af5a194
93c234c
483f92b
dc55cee
4341be1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,9 +51,52 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |
Opacity(static_cast<float>(value) / 100.0f); | ||
}; | ||
|
||
void SetPadding(double value) | ||
void SetLeftPadding(double value) | ||
{ | ||
Padding(to_hstring(value)); | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Left, value); | ||
|
||
Padding(padding); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I understand now. This will properly propagate the change notification through to Padding. You may still need to do the other notifications yourself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will allow you to turn this into a setter and a getter with normal two-way binding. |
||
} | ||
|
||
double GetLeftPadding(const winrt::hstring& padding) | ||
{ | ||
return _GetPaddingValue(padding, PaddingDirection::Left); | ||
} | ||
|
||
void SetTopPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Top, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
double GetTopPadding(const winrt::hstring& padding) | ||
{ | ||
return _GetPaddingValue(padding, PaddingDirection::Top); | ||
} | ||
|
||
void SetRightPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Right, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
double GetRightPadding(const winrt::hstring& padding) | ||
{ | ||
return _GetPaddingValue(padding, PaddingDirection::Right); | ||
} | ||
|
||
void SetBottomPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Bottom, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
double GetBottomPadding(const winrt::hstring& padding) | ||
{ | ||
return _GetPaddingValue(padding, PaddingDirection::Bottom); | ||
} | ||
|
||
winrt::hstring EvaluatedIcon() const | ||
|
@@ -140,6 +183,75 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |
|
||
Model::CascadiaSettings _appSettings; | ||
Editor::AppearanceViewModel _unfocusedAppearanceViewModel; | ||
|
||
enum class PaddingDirection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used this |
||
{ | ||
Left = 0, | ||
Top = 1, | ||
Right = 2, | ||
Bottom = 3 | ||
}; | ||
|
||
winrt::hstring _GetNewPadding(PaddingDirection paddingDirection, double newPaddingValue) const | ||
{ | ||
std::array<double, 4> values{}; | ||
std::wstring_view remaining{ Padding() }; | ||
uint32_t paddingIndex = static_cast<uint32_t>(paddingDirection); | ||
|
||
try | ||
{ | ||
for (uint32_t index = 0; !remaining.empty() && index < values.size(); ++index) | ||
{ | ||
const std::wstring token{ til::prefix_split(remaining, L',') }; | ||
auto curVal = std::stod(token); | ||
|
||
if (paddingIndex == index) | ||
{ | ||
curVal = newPaddingValue; | ||
} | ||
|
||
values[index] = curVal; | ||
} | ||
} | ||
catch (...) | ||
{ | ||
values.fill(0); | ||
LOG_CAUGHT_EXCEPTION(); | ||
} | ||
|
||
const auto result = fmt::format(FMT_COMPILE(L"{:.6f}"), fmt::join(values, L",")); | ||
|
||
return winrt::hstring{ result }; | ||
} | ||
|
||
double _GetPaddingValue(const winrt::hstring& padding, PaddingDirection paddingDirection) const | ||
{ | ||
std::wstring_view remaining{ padding }; | ||
uint32_t paddingIndex = static_cast<uint32_t>(paddingDirection); | ||
double paddingValue = 0.; | ||
|
||
try | ||
{ | ||
for (uint32_t index = 0; !remaining.empty(); ++index) | ||
{ | ||
const std::wstring token{ til::prefix_split(remaining, L',') }; | ||
auto curVal = std::stod(token); | ||
|
||
if (paddingIndex == index) | ||
{ | ||
paddingValue = curVal; | ||
break; | ||
} | ||
} | ||
} | ||
catch (...) | ||
{ | ||
paddingValue = 0.; | ||
LOG_CAUGHT_EXCEPTION(); | ||
} | ||
|
||
return paddingValue; | ||
} | ||
}; | ||
|
||
struct DeleteProfileEventArgs : | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -41,8 +41,16 @@ namespace Microsoft.Terminal.Settings.Editor | |||
void SetupAppearances(Windows.Foundation.Collections.IObservableVector<ColorSchemeViewModel> schemesList); | ||||
|
||||
void SetAcrylicOpacityPercentageValue(Double value); | ||||
void SetPadding(Double value); | ||||
|
||||
void SetLeftPadding(Double value); | ||||
Double GetLeftPadding(String padding); | ||||
void SetTopPadding(Double value); | ||||
Double GetTopPadding(String padding); | ||||
void SetRightPadding(Double value); | ||||
Double GetRightPadding(String padding); | ||||
void SetBottomPadding(Double value); | ||||
Double GetBottomPadding(String padding); | ||||
|
||||
Boolean IsBellStyleFlagSet(UInt32 flag); | ||||
void SetBellStyleAudible(Windows.Foundation.IReference<Boolean> on); | ||||
void SetBellStyleWindow(Windows.Foundation.IReference<Boolean> on); | ||||
|
@@ -74,7 +82,7 @@ namespace Microsoft.Terminal.Settings.Editor | |||
Boolean ShowMarksAvailable { get; }; | ||||
Boolean AutoMarkPromptsAvailable { get; }; | ||||
Boolean RepositionCursorWithMouseAvailable { get; }; | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
String EvaluatedIcon { get; }; | ||||
|
||||
void CreateUnfocusedAppearance(); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
SetXXXPadding(double value)
functions can be overloaded but idk how to make it work with XAML.