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

Enable the subtitle settings panel for the new layout #655

Merged

Conversation

stonko1994
Copy link
Collaborator

@stonko1994 stonko1994 commented Dec 9, 2024

Description

The current version of the new UI layout does not support subtitle customization settings.

Changes

In order to add support for the subtitle customization settings I had to refactor quite a bit inside the SettingsPanel. The changes are outlined in detail below.

  • Components no longer are separated into modern and non-modern. The name of the components now reflect their purpose.
    • ModernSettingsPanelItem was refactored and split into a DynamicSettingsPanelItem and a SettingsPanelSelectOption instead of handling both in the same component.
    • The ModernSettingsPanelPage and ModernSettingsPanel were removed and their functionality was moved into the parent components.
  • The SubtitleSettingsPanelPage now supports the old and the new layout.

Checklist (for PR submitter and reviewers)

  • CHANGELOG entry A generic redesign changelog with all changes will be added at the end

Comment on lines +74 to +75
buttonElement.on('click', (e) => {
e.stopPropagation();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is needed to prevent the event from bubbling up to the parent element.

Example: In the new design, the whole SettingsPanelItem is clickable. The subtitle customization item also contains a button to a different page. Without this change, both would trigger when clicking the button.

protected mergeConfig<Config>(config: Config, defaults: Config, base: Config): Config {
protected mergeConfig<Config>(config: Config, defaults: Partial<Config>, base: Config): Config {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not every component can fill all of its default config values. It does not need to fill out all as others are required anyway on initialization. To improve the type handling I decided to make this Partial here. The alternative (which was used before) was a cast to the Config type.

Comment on lines 750 to 751
// TODO: the problem is that the SeekbarLabel is also inside the seekbarContainer and therefore reacts to the
// TODO: mouse inputs.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will be handled in a follow up PR.

this.getDomElement().on('mouseenter', () => {
// On mouse enter clear the timeout
this.hideTimeout.clear();
this.getDomElement().on('mouseenter mousemove', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had to add the mousemove event here as well because the focusout event triggers between SettingsPanelPage transitions causing the settings panel to hide after selecting anything.

Comment on lines +118 to +125
if (config.pageTransitionAnimation) {
const handleResize = () => {
// Reset the dimension of the settingsPanel to let the browser calculate the new dimension after resizing
this.getDomElement().css({ width: '', height: '' });
};

player.on(player.exports.PlayerEvent.PlayerResized, handleResize);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a workaround within the animation handling where the width and height of the SettingsPanel are set to the current dimension. This breaks the SettingsPanel when resizing the browser window. Removing the width and height properties on resize fixes this.

Comment on lines +264 to +267
addPage(page: SettingsPanelPage) {
this.addComponent(page);
this.updateComponents();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Convenience method to add a SettingsPanelPage element.

Comment on lines -303 to +320
targetPage.onActiveEvent();
sourcePage.onInactiveEvent();
targetPage.onActiveEvent();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous order was 'wrong' and caused an issue with the new dynamic SettingsPanelPage approach, where the previous page would get the inactive event after the new page got the active event.

};

constructor(label: LocalizableText | Component<ComponentConfig>, setting: Component<ComponentConfig>, config: ContainerConfig = {}, addSettingAsComponent: boolean = true) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored the constructor to follow our config-based approach, which we follow for almost all other Components.

};

constructor(label: LocalizableText | Component<ComponentConfig>, setting: Component<ComponentConfig>, config: ContainerConfig = {}, addSettingAsComponent: boolean = true) {
constructor(config: SettingsPanelItemConfig)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This second constructor overload is a workaround for the weak-type-detection issue when there is no property of the parent type used.

Not adding this requires to cast the config to a SettingsPanelItemConfig on every usage which is cumbersome.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was refactored to the DynamicSettingsPanelItem

@stonko1994 stonko1994 changed the title Enable the subtitle settings panel Enable the subtitle settings panel for the new layout Dec 10, 2024
@@ -6,92 +6,6 @@
&.#{$prefix}-active {
display: block;
}

// A "line" in the panel: a container holding a label + control
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The styling for a settings-panel-item was extracted into a separate file.

settingsPanel: SettingsPanel;
overlay: SubtitleOverlay;
useDynamicSettingsPanelItem?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still don't know how we want to ship the new UI layout. We are currently leaning towards a new major version. Once this decision is confirmed I'll rework this and just change to the new dynamic approach and throw out the config option again. For now I didn't want to create a subclass for this as the code is very similar.

@stonko1994 stonko1994 marked this pull request as ready for review December 10, 2024 19:21
Base automatically changed from feature/super-modern-ui-for-web to feature/modern-ui-base December 11, 2024 16:34
src/ts/components/settingspanelitem.ts Outdated Show resolved Hide resolved
@stonko1994 stonko1994 merged commit 77d2044 into feature/modern-ui-base Dec 20, 2024
3 checks passed
@stonko1994 stonko1994 deleted the feature/super-modern-subtitle-settings-panel branch December 20, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants