Skip to content

Commit

Permalink
this is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
cinnamon-msft committed Jan 14, 2025
1 parent 8e74e18 commit d9b2c9d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
9 changes: 7 additions & 2 deletions src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,18 +714,22 @@ struct CompositionSpotlight : SuperSonar<CompositionSpotlight>
m_backdrop.RelativeSizeAdjustment({ 1.0f, 1.0f }); // fill the parent
m_backdrop.Brush(m_compositor.CreateColorBrush(m_backgroundColor));
layer.Children().InsertAtTop(m_backdrop);

m_circleGeometry = m_compositor.CreateEllipseGeometry(); // radius set via expression animation
m_circleShape = m_compositor.CreateSpriteShape(m_circleGeometry);
m_circleShape.FillBrush(m_compositor.CreateColorBrush(m_spotlightColor));
m_circleShape.Offset({ m_sonarRadiusFloat * m_sonarZoomFactor, m_sonarRadiusFloat * m_sonarZoomFactor });
m_spotlight = m_compositor.CreateShapeVisual();
m_spotlight.Size({ m_sonarRadiusFloat * 2 * m_sonarZoomFactor, m_sonarRadiusFloat * 2 * m_sonarZoomFactor });
m_spotlight.AnchorPoint({ 0.5f, 0.5f });
m_spotlight.Opacity(m_spotlightColor.A);
m_spotlight.Shapes().Append(m_circleShape);

layer.Children().InsertAtTop(m_spotlight);

// auto clip = m_compositor.CreateGeometricClip(m_circleShape.Geometry());
// layer.Clip(clip);
// m_backdrop.Clip(clip);

// Implicitly animate the alpha.
m_animation = m_compositor.CreateScalarKeyFrameAnimation();
m_animation.Target(L"Opacity");
Expand Down Expand Up @@ -816,6 +820,7 @@ struct CompositionSpotlight : SuperSonar<CompositionSpotlight>
m_circleShape.FillBrush().as<winrt::CompositionColorBrush>().Color(m_spotlightColor);
m_circleShape.Offset({ m_sonarRadiusFloat * m_sonarZoomFactor, m_sonarRadiusFloat * m_sonarZoomFactor });
m_spotlight.Size({ m_sonarRadiusFloat * 2 * m_sonarZoomFactor, m_sonarRadiusFloat * 2 * m_sonarZoomFactor });
m_spotlight.Opacity(m_spotlightColor.A);
m_animation.Duration(std::chrono::milliseconds{ m_fadeDuration });
m_circleGeometry.StopAnimation(L"Radius");

Expand Down
23 changes: 1 addition & 22 deletions src/modules/MouseUtils/FindMyMouse/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace
const wchar_t JSON_KEY_DO_NOT_ACTIVATE_ON_GAME_MODE[] = L"do_not_activate_on_game_mode";
const wchar_t JSON_KEY_BACKGROUND_COLOR[] = L"background_color";
const wchar_t JSON_KEY_SPOTLIGHT_COLOR[] = L"spotlight_color";
const wchar_t JSON_KEY_SPOTLIGHT_OPACITY[] = L"spotlight_opacity";
const wchar_t JSON_KEY_OVERLAY_OPACITY[] = L"overlay_opacity";
const wchar_t JSON_KEY_SPOTLIGHT_RADIUS[] = L"spotlight_radius";
const wchar_t JSON_KEY_ANIMATION_DURATION_MS[] = L"animation_duration_ms";
Expand Down Expand Up @@ -277,31 +276,11 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
}
try
{
// Parse opacity
uint8_t opacity = 166;
try
{
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_OPACITY);
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
if (value >= 0)
{
opacity = value * 255 / 100;
}
else
{
throw std::runtime_error("Invalid Opacity value");
}
}
catch (...)
{
Logger::warn("Failed to initialize Opacity from settings. Will use default value");
}

// Parse spotlight color
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_COLOR);
auto spotlightColor = (std::wstring)jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE);

uint8_t a = opacity, r, g, b;
uint8_t a, r, g, b;
if (!checkValidARGB(spotlightColor, &a, &r, &g, &b))
{
Logger::error("Spotlight color RGB value is invalid. Will use default value");
Expand Down
3 changes: 0 additions & 3 deletions src/settings-ui/Settings.UI.Library/FindMyMouseProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public class FindMyMouseProperties
[JsonPropertyName("spotlight_color")]
public StringProperty SpotlightColor { get; set; }

[JsonPropertyName("spotlight_opacity")]
public IntProperty SpotlightOpacity { get; set; }

[JsonPropertyName("overlay_opacity")]
public IntProperty OverlayOpacity { get; set; }

Expand Down
3 changes: 0 additions & 3 deletions src/settings-ui/Settings.UI.Library/FindMyMouseSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Globalization;
using System.Text.Json.Serialization;

using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
Expand Down Expand Up @@ -33,13 +32,11 @@ public bool UpgradeSettingsConfiguration()
{
if (Version == "1.0")
{
string opacity = string.Format(CultureInfo.InvariantCulture, "{0:X2}", Properties.SpotlightOpacity.Value * 255 / 100);
if (Properties.ActivationMethod.Value == 1)
{
Properties.ActivationMethod = new IntProperty(2);
}

Properties.SpotlightColor = new StringProperty(string.Concat("#", opacity, Properties.SpotlightColor.Value.ToString().Substring(1, 6)));
Version = "1.1";
return true;
}
Expand Down

0 comments on commit d9b2c9d

Please sign in to comment.