Skip to content
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

Resizable Window + Customize #2699

Merged
merged 30 commits into from
May 28, 2024

Conversation

onesounds
Copy link
Contributor

@onesounds onesounds commented May 17, 2024

What's the PR

Resizable Window

RESIZE7

Customize

RESIZE6

Todo

  • Reset
    - [ ] Get Preset from Theme
    • I decided to leave it out because it was overkill. Expected to be too burdensome to manage in the future..
  • Adjusting the Theme Editor Area Size
  • Import to Split Setting Window
  • Remove existing settings (number of results, window width, font settings)

ETC

  • Fix Navigation Sidebar Color in this PR
  • This PR is fine on its own, but there are things to work on in a separate PR.
    • Adjust Item Spacing
    • Adjust Themes

Test Cases

  • The window should be resizable with the mouse and should work when turned off and on.
  • Adjustable items in the Customize menu should be preserved after relaunch.
  • If the Keep Height menu is enabled, the vertical height (number of items) should be maintained regardless of screen resizing.
  • The reset button should work.

@jjw24 jjw24 marked this pull request as draft May 17, 2024 05:56
@onesounds onesounds self-assigned this May 22, 2024
@onesounds onesounds added the enhancement New feature or request label May 22, 2024
@@ -189,9 +187,25 @@ public ResourceDictionary GetResourceDictionary(string theme)

Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(
new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
new[] { resultItemStyle, resultItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separating / And adding Subtitle Styles.

@@ -56,6 +56,13 @@ public string Theme
}
}
public bool UseDropShadowEffect { get; set; } = false;

/* Appearance Settings. It should be separated from the setting later.*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settings for Customize

{

}
private void OnResizeEnd()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusts the total number of items based on the height at the time the window is resized.


if (System.Convert.ToInt32((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize) < 1)
{
_settings.MaxResultsToShow = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the window height is too low, it will rescale the height based on 2 criteria.

Comment on lines 35 to 54
private void Reset_Click(object sender, System.Windows.RoutedEventArgs e)
{
/*The FamilyTypeface should initialize all of its various properties.*/
FamilyTypeface targetTypeface = new FamilyTypeface { Stretch = FontStretches.Normal, Weight = FontWeights.Normal, Style = FontStyles.Normal };

QueryBoxFontSize.Value = 20;
QueryBoxFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", QueryBoxFontComboBox);
QueryBoxFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, QueryBoxFontStyleComboBox);

ResultItemFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", ResultItemFontComboBox);
ResultItemFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, ResultItemFontStyleComboBox);
ResultItemFontSize.Value = 16;

ResultSubItemFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", ResultSubItemFontComboBox);
ResultSubItemFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, ResultSubItemFontStyleComboBox);
ResultSubItemFontSize.Value = 13;

WindowHeightValue.Value = 42;
ItemHeightValue.Value = 58;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, we worked by changing the settings value, but there was an issue with the control not reflecting the change. After a few tries, we settled on just changing the value of the control.

+) This initial value has been matched to the initial value in settings.cs and should be matched in the future. No problem if it's different. Should we replace it with a contant value and align them both to constant?

Comment on lines 55 to 107
public int SearchFontIndex(string str, ComboBox combo)
{
int index = -1;
string targetFont = str;

for (int i = 0; i < combo.Items.Count; i++)
{
if (combo.Items[i].ToString() == targetFont)
{
index = i;
break;
}
}

if (index != -1)
{
return index;
}
else
{
// If there no Default Value.
return 0;
}
}
public int SearchFontStyleIndex(FamilyTypeface targetTypeface, ComboBox combo)
{
int index = -1;

for (int i = 0; i < combo.Items.Count; i++)
{
if (combo.Items[i] is FamilyTypeface)
{
FamilyTypeface typefaceItem = (FamilyTypeface)combo.Items[i];
if (typefaceItem.Stretch == targetTypeface.Stretch &&
typefaceItem.Weight == targetTypeface.Weight &&
typefaceItem.Style == targetTypeface.Style)
{
index = i;
break;
}
}
}

if (index != -1)
{
return index;
}
else
{
return 0;
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function to find a specific value when initializing a combobox to its default value.

@onesounds onesounds marked this pull request as ready for review May 26, 2024 21:52
@onesounds onesounds requested review from VictoriousRaptor, taooceros, Yusyuriv and jjw24 and removed request for VictoriousRaptor and taooceros May 26, 2024 21:52
Comment on lines 59 to 60
<system:String x:Key="KeepMaxResults">Keeping Window Max Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">Window height will keep to fit the maximum number of results</system:String>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check expression

Copy link
Member

@Yusyuriv Yusyuriv May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing is not very clear, but I can't think of anything better. My version doesn't look much better:

Suggested change
<system:String x:Key="KeepMaxResults">Keeping Window Max Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">Window height will keep to fit the maximum number of results</system:String>
<system:String x:Key="KeepMaxResults">Fixed Window Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">The window height will be fixed to show up to the maximum number of results</system:String>

Comment on lines 59 to 60
<system:String x:Key="KeepMaxResults">Keeping Window Max Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">Window height will keep to fit the maximum number of results</system:String>
Copy link
Member

@Yusyuriv Yusyuriv May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing is not very clear, but I can't think of anything better. My version doesn't look much better:

Suggested change
<system:String x:Key="KeepMaxResults">Keeping Window Max Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">Window height will keep to fit the maximum number of results</system:String>
<system:String x:Key="KeepMaxResults">Fixed Window Height</system:String>
<system:String x:Key="KeepMaxResultsToolTip">The window height will be fixed to show up to the maximum number of results</system:String>

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml Outdated Show resolved Hide resolved
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs Outdated Show resolved Hide resolved
Flow.Launcher/ViewModel/MainViewModel.cs Show resolved Hide resolved
Flow.Launcher/ViewModel/MainViewModel.cs Outdated Show resolved Hide resolved
Flow.Launcher/MainWindow.xaml.cs Show resolved Hide resolved
Flow.Launcher/MainWindow.xaml Outdated Show resolved Hide resolved
Flow.Launcher/MainWindow.xaml.cs Outdated Show resolved Hide resolved
Flow.Launcher/MainWindow.xaml.cs Outdated Show resolved Hide resolved
ResultSubItemFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, ResultSubItemFontStyleComboBox);
ResultSubItemFontSize.Value = 13;

WindowHeightValue.Value = 42;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why there's a .Value ? shouldn't it be an int? just took a quick glance and don't have time to further review it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This item changes the value of a specific control (slider) rather than a setting.
This was implemented because there was an issue with changing the value of a set value not being reflected in the control.

Maximum="60"
Minimum="20"
TickFrequency="2"
Value="{Binding WindowHeightSize, Mode=TwoWay}" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's here. but why not just set WindowHeightSize and separate the UI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what are you mean. pardon~?

@onesounds onesounds merged commit c9061a4 into Flow-Launcher:dev May 28, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants