Skip to content

Commit

Permalink
Merge pull request #78 from NickvisionApps/circle
Browse files Browse the repository at this point in the history
Circle variants of drawing modes
  • Loading branch information
nlogozzo authored Aug 5, 2023
2 parents ef5b578 + 7a190fe commit e3ce0c0
Show file tree
Hide file tree
Showing 20 changed files with 1,861 additions and 1,204 deletions.
50 changes: 43 additions & 7 deletions NickvisionCavalier.GNOME/Blueprints/preferences_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ Adw.PreferencesWindow _root {
Adw.PreferencesGroup {
title: _("Drawing mode");

[header-suffix]
Gtk.Box {
halign: center;

Gtk.ToggleButton _boxButton {
label: _("Box");
}

Gtk.ToggleButton {
label: _("Circle");
active: bind _boxButton.active bidirectional inverted;
}

styles ["linked"]
}

Adw.ActionRow {
title: _("Wave");
activatable-widget: _waveCheckButton;
Expand Down Expand Up @@ -67,6 +83,7 @@ Adw.PreferencesWindow _root {
Adw.ActionRow {
title: _("Splitter");
activatable-widget: _splitterCheckButton;
sensitive: bind _boxButton.active;

[prefix]
Gtk.CheckButton _splitterCheckButton {
Expand All @@ -75,6 +92,24 @@ Adw.PreferencesWindow _root {
}
}

Adw.PreferencesGroup {
Adw.ActionRow {
title: _("Radius");
visible: bind _boxButton.active inverted;

[suffix]
Gtk.Scale _radiusScale {
width-request: 150;
draw-value: false;
adjustment: Gtk.Adjustment {
lower: 0.2;
upper: 0.8;
step-increment: 0.05;
};
}
}
}

Adw.PreferencesGroup {
Adw.ComboRow _mirrorRow {
title: _("Mirror");
Expand All @@ -92,6 +127,14 @@ Adw.PreferencesWindow _root {
}

Adw.PreferencesGroup {
Adw.ComboRow _directionRow {
title: _("Drawing direction");
model: Gtk.StringList {
strings [_("Top to bottom"), _("Bottom to top"), _("Left to right"), _("Right to left") ]
};
sensitive: bind _boxButton.active;
}

Adw.ActionRow {
title: _("Drawing area margin");
subtitle: _("Size of gaps around drawing area (in pixels).");
Expand All @@ -110,13 +153,6 @@ Adw.PreferencesWindow _root {
}
}

Adw.ComboRow _directionRow {
title: _("Drawing direction");
model: Gtk.StringList {
strings [_("Top to bottom"), _("Bottom to top"), _("Left to right"), _("Right to left") ]
};
}

Adw.ActionRow _offsetRow {
title: _("Offset between items");
subtitle: _("The size of spaces between elements (in percent).");
Expand Down
5 changes: 5 additions & 0 deletions NickvisionCavalier.GNOME/Blueprints/shortcuts_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Gtk.ShortcutsWindow _shortcuts {
accelerator: "D <Shift>D";
}

Gtk.ShortcutsShortcut {
title: _("Change radius in Circle modes");
accelerator: "U <Shift>U";
}

Gtk.ShortcutsShortcut {
title: _("Change Mirror Mode");
accelerator: "M <Shift>M";
Expand Down
3 changes: 3 additions & 0 deletions NickvisionCavalier.GNOME/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public Program(string[] args)
_mainWindowController = new MainWindowController(args);
_mainWindowController.AppInfo.Changelog =
@"* Added Cairo backend that can be used in case of problems with OpenGL. To activate, run the program with environment variable CAVALIER_RENDERER=cairo
* All drawing modes except Splitter now have Circle variants
* Added an easter egg (run the program with --help to find how to activate it)
* Fixed an issue where the app wasn't drawing correctly with >100% display scaling
* Updated translations (Thanks everyone on Weblate!)";
_application.OnActivate += OnActivate;
if (File.Exists(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) + "/org.nickvision.cavalier.gresource"))
Expand Down
115 changes: 109 additions & 6 deletions NickvisionCavalier.GNOME/Views/PreferencesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public partial class PreferencesDialog : Adw.PreferencesWindow
private readonly PreferencesViewController _controller;
private readonly uint[] _framerates;

[Gtk.Connect] private readonly Gtk.ToggleButton _boxButton;
[Gtk.Connect] private readonly Gtk.CheckButton _waveCheckButton;
[Gtk.Connect] private readonly Gtk.CheckButton _levelsCheckButton;
[Gtk.Connect] private readonly Gtk.CheckButton _particlesCheckButton;
[Gtk.Connect] private readonly Gtk.CheckButton _barsCheckButton;
[Gtk.Connect] private readonly Adw.ActionRow _spineRow;
[Gtk.Connect] private readonly Gtk.CheckButton _spineCheckButton;
[Gtk.Connect] private readonly Gtk.CheckButton _splitterCheckButton;
[Gtk.Connect] private readonly Gtk.Scale _radiusScale;
[Gtk.Connect] private readonly Adw.ComboRow _mirrorRow;
[Gtk.Connect] private readonly Adw.ActionRow _reverseMirrorRow;
[Gtk.Connect] private readonly Gtk.Switch _reverseMirrorSwitch;
Expand Down Expand Up @@ -77,27 +79,39 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
var actNextMode = Gio.SimpleAction.New("next-mode", null);
actNextMode.OnActivate += (sender, e) =>
{
if (_controller.Mode < DrawingMode.SpineBox)
if (_controller.Mode < DrawingMode.SpineCircle)
{
switch (_controller.Mode + 1)
{
case DrawingMode.WaveCircle:
_waveCheckButton.SetActive(true);
_boxButton.SetActive(false);
break;
case DrawingMode.LevelsBox:
case DrawingMode.LevelsCircle:
_levelsCheckButton.SetActive(true);
break;
case DrawingMode.ParticlesBox:
case DrawingMode.ParticlesCircle:
_particlesCheckButton.SetActive(true);
break;
case DrawingMode.BarsBox:
case DrawingMode.BarsCircle:
_barsCheckButton.SetActive(true);
break;
case DrawingMode.SpineBox:
case DrawingMode.SpineCircle:
_spineCheckButton.SetActive(true);
break;
case DrawingMode.SplitterBox:
_splitterCheckButton.SetActive(true);
break;
}
}
else
{
_waveCheckButton.SetActive(true);
_boxButton.SetActive(true);
}
};
application.AddAction(actNextMode);
Expand All @@ -111,30 +125,69 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
switch (_controller.Mode - 1)
{
case DrawingMode.WaveBox:
case DrawingMode.WaveCircle:
_waveCheckButton.SetActive(true);
break;
case DrawingMode.LevelsBox:
case DrawingMode.LevelsCircle:
_levelsCheckButton.SetActive(true);
break;
case DrawingMode.ParticlesBox:
case DrawingMode.ParticlesCircle:
_particlesCheckButton.SetActive(true);
break;
case DrawingMode.BarsBox:
case DrawingMode.BarsCircle:
_barsCheckButton.SetActive(true);
break;
case DrawingMode.SpineBox:
case DrawingMode.SpineCircle:
_spineCheckButton.SetActive(true);
break;
case DrawingMode.SplitterBox:
_boxButton.SetActive(true);
_splitterCheckButton.SetActive(true);
break;
}
}
else
{
_spineCheckButton.SetActive(true);
_boxButton.SetActive(false);
}
};
application.AddAction(actPrevMode);
application.SetAccelsForAction("app.prev-mode", new string[] { "<Shift>d" });
//Increase Inner Radius Action
var actIncRadius = Gio.SimpleAction.New("inc-radius", null);
actIncRadius.OnActivate += (sender, e) =>
{
if (_radiusScale.GetValue() < 0.8)
{
_radiusScale.SetValue(_radiusScale.GetValue() + 0.05);
}
};
application.AddAction(actIncRadius);
application.SetAccelsForAction("app.inc-radius", new string[] { "u" });
//Decreate Inner Radius Action

Check failure on line 172 in NickvisionCavalier.GNOME/Views/PreferencesDialog.cs

View workflow job for this annotation

GitHub Actions / codespell

Decreate ==> Decrease, Discrete, Destroy, Desecrate
var actDecRadius = Gio.SimpleAction.New("dec-radius", null);
actDecRadius.OnActivate += (sender, e) =>
{
if (_radiusScale.GetValue() > 0.2)
{
_radiusScale.SetValue(_radiusScale.GetValue() - 0.05);
}
};
application.AddAction(actDecRadius);
application.SetAccelsForAction("app.dec-radius", new string[] { "<Shift>u" });
//Next Mirror Mode Action
var actNextMirror = Gio.SimpleAction.New("next-mirror", null);
actNextMirror.OnActivate += (sender, e) =>
{
if (!_mirrorRow.GetSensitive())
{
return;
}
var maxMirror = _controller.Stereo ? Mirror.SplitChannels : Mirror.Full;
_mirrorRow.SetSelected(_controller.Mirror < maxMirror ? (uint)_controller.Mirror + 1 : 0);
};
Expand All @@ -144,6 +197,10 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
var actPrevMirror = Gio.SimpleAction.New("prev-mirror", null);
actPrevMirror.OnActivate += (sender, e) =>
{
if (!_mirrorRow.GetSensitive())
{
return;
}
var maxMirror = _controller.Stereo ? Mirror.SplitChannels : Mirror.Full;
_mirrorRow.SetSelected(_controller.Mirror > Mirror.Off ? (uint)_controller.Mirror - 1 : (uint)maxMirror);
};
Expand Down Expand Up @@ -351,11 +408,36 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
UpdateImagesList();
LoadInstantSettings();
LoadCAVASettings();
_boxButton.OnToggled += (sender, e) =>
{
_mirrorRow.SetSensitive(true);
if (_boxButton.GetActive())
{
_controller.Mode -= 6;
}
else
{
if ((uint)_controller.Mode + 6 > (uint)DrawingMode.SpineCircle)
{
_controller.Mode = DrawingMode.SpineCircle;
_spineCheckButton.SetActive(true);
}
else
{
_controller.Mode += 6;
}
}
};
_waveCheckButton.OnToggled += (sender, e) =>
{
if (_waveCheckButton.GetActive())
{
_controller.Mode = DrawingMode.WaveBox;
_controller.Mode = _controller.Mode >= DrawingMode.WaveCircle ? DrawingMode.WaveCircle : DrawingMode.WaveBox;
if (_controller.Mode == DrawingMode.WaveCircle)
{
_mirrorRow.SetSelected(0u);
_mirrorRow.SetSensitive(false);
}
_offsetRow.SetSensitive(false);
_roundnessRow.SetSensitive(false);
}
Expand All @@ -364,7 +446,8 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
{
if (_levelsCheckButton.GetActive())
{
_controller.Mode = DrawingMode.LevelsBox;
_controller.Mode = _controller.Mode >= DrawingMode.WaveCircle ? DrawingMode.LevelsCircle : DrawingMode.LevelsBox;
_mirrorRow.SetSensitive(true);
_offsetRow.SetSensitive(true);
_roundnessRow.SetSensitive(true);
}
Expand All @@ -373,7 +456,8 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
{
if (_particlesCheckButton.GetActive())
{
_controller.Mode = DrawingMode.ParticlesBox;
_controller.Mode = _controller.Mode >= DrawingMode.WaveCircle ? DrawingMode.ParticlesCircle : DrawingMode.ParticlesBox;
_mirrorRow.SetSensitive(true);
_offsetRow.SetSensitive(true);
_roundnessRow.SetSensitive(true);
}
Expand All @@ -382,7 +466,8 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
{
if (_barsCheckButton.GetActive())
{
_controller.Mode = DrawingMode.BarsBox;
_controller.Mode = _controller.Mode >= DrawingMode.WaveCircle ? DrawingMode.BarsCircle : DrawingMode.BarsBox;
_mirrorRow.SetSensitive(true);
_offsetRow.SetSensitive(true);
_roundnessRow.SetSensitive(false);
}
Expand All @@ -391,7 +476,8 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
{
if (_spineCheckButton.GetActive())
{
_controller.Mode = DrawingMode.SpineBox;
_controller.Mode = _controller.Mode >= DrawingMode.WaveCircle ? DrawingMode.SpineCircle : DrawingMode.SpineBox;
_mirrorRow.SetSensitive(true);
_offsetRow.SetSensitive(true);
_roundnessRow.SetSensitive(true);
}
Expand All @@ -401,12 +487,18 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
if (_splitterCheckButton.GetActive())
{
_controller.Mode = DrawingMode.SplitterBox;
_mirrorRow.SetSensitive(true);
_offsetRow.SetSensitive(false);
_roundnessRow.SetSensitive(false);
}
};
_mirrorRow.SetSensitive(_controller.Mode != DrawingMode.WaveCircle);
_offsetRow.SetSensitive(_controller.Mode != DrawingMode.WaveBox);
_roundnessRow.SetSensitive(_controller.Mode != DrawingMode.WaveBox && _controller.Mode != DrawingMode.BarsBox);
_radiusScale.OnValueChanged += (sender, e) =>
{
_controller.InnerRadius = (float)_radiusScale.GetValue();
};
_mirrorRow.OnNotify += (sender, e) =>
{
if (e.Pspec.GetName() == "selected")
Expand Down Expand Up @@ -639,27 +731,38 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
/// </summary>
public bool LoadInstantSettings()
{
_boxButton.SetActive(_controller.Mode < DrawingMode.WaveCircle);
if (_controller.Mode == DrawingMode.WaveCircle)
{
_controller.Mirror = Mirror.Off;
}
switch (_controller.Mode)
{
case DrawingMode.WaveBox:
case DrawingMode.WaveCircle:
_waveCheckButton.SetActive(true);
break;
case DrawingMode.LevelsBox:
case DrawingMode.LevelsCircle:
_levelsCheckButton.SetActive(true);
break;
case DrawingMode.ParticlesBox:
case DrawingMode.ParticlesCircle:
_particlesCheckButton.SetActive(true);
break;
case DrawingMode.BarsBox:
case DrawingMode.BarsCircle:
_barsCheckButton.SetActive(true);
break;
case DrawingMode.SpineBox:
case DrawingMode.SpineCircle:
_spineCheckButton.SetActive(true);
break;
case DrawingMode.SplitterBox:
_splitterCheckButton.SetActive(true);
break;
}
_radiusScale.SetValue((double)_controller.InnerRadius);
var mirror = (uint)_controller.Mirror; // saving mirror state to apply after changing the model
if (_controller.Stereo)
{
Expand Down
Loading

0 comments on commit e3ce0c0

Please sign in to comment.