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

Improved MarqueeText control #548

Closed
wants to merge 15 commits into from

Conversation

Avid29
Copy link
Contributor

@Avid29 Avid29 commented Jun 3, 2024

Changes:

Added Cycle Marquee Behavior option

When in cycle mode, an animation is played to transition between values when the Text property is changed.

MarqueeCycle-Example.mp4

More predictable behavior

  • Marquee animation no longer plays by default.
  • Marquee animation is no longer started when the control's size changes.

@Arlodotexe Arlodotexe self-requested a review June 3, 2024 15:28
@Arlodotexe Arlodotexe added the enhancement Improvement to an existing feature label Jun 3, 2024
Copy link
Member

@Arlodotexe Arlodotexe left a comment

Choose a reason for hiding this comment

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

First pass review. As discussed in call, we'll do a bit of cleanup before merging this in. There are layout and extensibility complexities here that we'll want to resolve later, but the new cycling functionality works quite well as-is and should be made available for others.


<Content Include="Assets\MarqueeText.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

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

we can remove this since it's done automatically by our tooling

@@ -17,9 +17,17 @@

<ItemGroup>
<None Remove="Assets\MarqueeText.png" />
<None Remove="CustomStyleMarqueeTextSample.xaml" />
<UpToDateCheckInput Remove="CustomStyleMarqueeTextSample.xaml" />
Copy link
Member

Choose a reason for hiding this comment

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

we can remove this since it's done automatically by our tooling

//[ToolkitSampleMultiChoiceOption("MarqueeRepeat", "Repeat", "Forever", "1x", "2x")]
public sealed partial class CustomStyleMarqueeTextSample : Page
{
private const string LoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
Copy link
Member

Choose a reason for hiding this comment

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

This might be an area to improve our tooling -- ToolkitSampleTextOption should take a default value for the text.

this.InitializeComponent();
}

private MarqueeDirection ConvertStringToMarqueeDirection(string str) => str switch
Copy link
Member

Choose a reason for hiding this comment

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

Since the value of each string here matches the enum value name, we shouldn't need a converter. If this doesn't work, it's something we need to investigate fixing.

@@ -71,7 +78,8 @@ protected override void OnApplyTemplate()
_marqueeContainer = (Panel)GetTemplateChild(MarqueeContainerPartName);
_segment1 = (FrameworkElement)GetTemplateChild(Segment1PartName);
_segment2 = (FrameworkElement)GetTemplateChild(Segment2PartName);
_marqueeTransform = (TranslateTransform)GetTemplateChild(MarqueeTransformPartName);
_marqueeTransform = (CompositeTransform)GetTemplateChild(MarqueeTransformPartName);
_cyclingStoryboard = (Storyboard)GetTemplateChild(CyclingAnaimationPartName);
Copy link
Member

Choose a reason for hiding this comment

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

Small typo

}

// Create new storyboard and animation
_marqueeStoryboard = CreateMarqueeStoryboardAnimation(start, end, duration, targetProperty);
_marqueeStoryboard = Behavior switch
Copy link
Member

Choose a reason for hiding this comment

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

We should consider the ways we can generalize this control so differences like this are handled in the style template instead of internally in the control. Might be a bit of work, but now that things are working under a variety of configurations it would be a good thing to do.

@Arlodotexe
Copy link
Member

Arlodotexe commented Jun 7, 2024

@michael-hawker Not here or now, but we should consider the advantages we'd get building this on ItemsRepeater instead of manually repositioning two text segments via Storyboard/code-behind. It would require a full rewrite, but in the long term it may be worth it.

I don't have experience with building a custom layout with ItemsRepeater, so any insight you could add here would be valuable.

@Arlodotexe Arlodotexe marked this pull request as draft June 8, 2024 20:11
@Avid29 Avid29 closed this Jul 21, 2024
@Avid29 Avid29 deleted the marquee_text/cycle branch July 21, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants