-
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 1 commit
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,32 @@ 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. |
||
} | ||
|
||
void SetTopPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Top, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
void SetRightPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Right, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
void SetBottomPadding(double value) | ||
{ | ||
const hstring& padding = _GetNewPadding(PaddingDirection::Bottom, value); | ||
|
||
Padding(padding); | ||
} | ||
|
||
winrt::hstring EvaluatedIcon() const | ||
|
@@ -140,6 +163,47 @@ 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) | ||
{ | ||
std::wstringstream result; | ||
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(); | ||
} | ||
|
||
result << values[0] << L", " << values[1] << L", " << values[2] << L", " << values[3]; | ||
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. We use Something like this: const auto result = fmt::format(
FMT_COMPILE(L"{:.6f},{:.6f},{:.6f},{:.6f}"),
values[0],
values[1],
values[2],
values[3]
);
return winrt::hstring{ result }; Theoretically you should also have access to const auto result = fmt::format(FMT_COMPILE(L"{:.6f}"), fmt::join(values, L",")); |
||
|
||
return hstring{ result.str() }; | ||
} | ||
}; | ||
|
||
struct DeleteProfileEventArgs : | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,35 @@ namespace winrt::Microsoft::Terminal::UI::implementation | |
|
||
return maxVal; | ||
} | ||
|
||
double Converters::PaddingValueFromIndex(const winrt::hstring& paddingString, uint32_t paddingIndex) | ||
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. Maybe this should also take an |
||
{ | ||
std::wstring_view remaining{ paddingString }; | ||
double paddingVal = 0; | ||
uint32_t index = 0; | ||
|
||
try | ||
{ | ||
while (!remaining.empty()) | ||
{ | ||
const std::wstring token{ til::prefix_split(remaining, L',') }; | ||
const auto curVal = std::stod(token); | ||
|
||
if (paddingIndex == index) | ||
{ | ||
paddingVal = curVal; | ||
break; | ||
} | ||
|
||
++index; | ||
} | ||
} | ||
catch (...) | ||
{ | ||
paddingVal = 0; | ||
LOG_CAUGHT_EXCEPTION(); | ||
} | ||
|
||
return paddingVal; | ||
} | ||
} |
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.