Skip to content

Commit

Permalink
✨ Implement taskbar transparency in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbreiz committed Mar 4, 2024
1 parent 2499f92 commit 9d11866
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 24 deletions.
2 changes: 1 addition & 1 deletion SRC/Aura_OS/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Aura_OS
{
public class VersionInfo
{
public static string revision = "040320241545";
public static string revision = "040320241613";
}
}
24 changes: 23 additions & 1 deletion SRC/Aura_OS/System/Graphics/UI/GUI/Components/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,38 @@
*/

using Cosmos.System;
using UniLua;

namespace Aura_OS.System.Graphics.UI.GUI.Components
{
public class Slider : Component
{
public int Value = 0;
public int Value
{
get { return _value; }
set
{
_value = value;
int newPositionX = (_value * (Width - _slide.Width)) / 255;
if (newPositionX < 0)
{
newPositionX = 0;
}
else if (newPositionX > Width - _slide.Width)
{
newPositionX = Width - _slide.Width;
}

_slide.X = newPositionX;
_slide.MarkDirty();
MarkDirty();
}
}

private Button _slide;
private bool _sliderPressed = false;
private int _firstX;
private int _value = 0;

public Slider(int x, int y, int width, int height) : base(x, y, width, height)
{
Expand Down
21 changes: 20 additions & 1 deletion SRC/Aura_OS/System/Graphics/UI/GUI/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Aura_OS.System.Graphics.UI.GUI.Components;
using Rectangle = Aura_OS.System.Graphics.UI.GUI.Rectangle;
using Component = Aura_OS.System.Graphics.UI.GUI.Components.Component;
using Aura_OS.System.Utils;

namespace Aura_OS
{
Expand All @@ -22,6 +23,7 @@ public class WindowManager : IManager
public Application FocusedApp { get; set; }
public RightClick ContextMenu { get; set; }
public byte WindowsTransparency { get; set; }
public byte TaskbarTransparency { get; set; }

public List<Application> Applications;
public List<Rectangle> ClipRects;
Expand All @@ -35,7 +37,20 @@ public void Initialize()

Applications = new List<Application>();
ClipRects = new List<Rectangle>();
WindowsTransparency = 0xFF;

if (Kernel.Installed)
{
Settings config = new Settings(@"0:\System\settings.ini");
byte windowsTransparency = byte.Parse(config.GetValue("windowsTransparency"));
byte taskbarTransparency = byte.Parse(config.GetValue("taskbarTransparency"));
WindowsTransparency = windowsTransparency;
TaskbarTransparency = taskbarTransparency;
}
else
{
WindowsTransparency = 0xFF;
TaskbarTransparency = 0xFF;
}
}

public void AddComponent(Component component)
Expand Down Expand Up @@ -177,6 +192,10 @@ public void DrawComponentAndChildren(Component component)
{
_screen.DrawImageAlpha(component.GetBuffer(), component.X, component.Y, WindowsTransparency);
}
else if (component is Taskbar)
{
_screen.DrawImageAlpha(component.GetBuffer(), component.X, component.Y, TaskbarTransparency);
}
else
{
_screen.DrawImage(component.GetBuffer(), component.X, component.Y);
Expand Down
28 changes: 14 additions & 14 deletions SRC/Aura_OS/System/Processing/ApplicationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class ApplicationConfig
public Type Template;
public int X;
public int Y;
public int Weight;
public int Width;
public int Height;

public ApplicationConfig(Type template, int x, int y, int weight, int height)
public ApplicationConfig(Type template, int x, int y, int width, int height)
{
Template = template;
X = x;
Y = y;
Weight = weight;
Width = width;
Height = height;
}
}
Expand Down Expand Up @@ -57,17 +57,17 @@ public void LoadApplications()
RegisterApplication(typeof(CubeApp), 40, 40, 200, 200);
RegisterApplication(typeof(GameBoyApp), 40, 40, 160 + 6, 144 + 26);
RegisterApplication(typeof(SampleApp), 40, 40, 500, 500);
RegisterApplication(typeof(SettingsApp), 40, 40, 450, 350);
RegisterApplication(typeof(SettingsApp), 40, 40, 340, 350);
}

public void RegisterApplication(ApplicationConfig config)
{
ApplicationTemplates.Add(config);
}

public void RegisterApplication(Type template, int x, int y, int weight, int height)
public void RegisterApplication(Type template, int x, int y, int width, int height)
{
ApplicationConfig config = new(template, x, y, weight, height);
ApplicationConfig config = new(template, x, y, width, height);
ApplicationTemplates.Add(config);
}

Expand Down Expand Up @@ -116,39 +116,39 @@ public Application Instantiate(ApplicationConfig config)

if (config.Template == typeof(TerminalApp))
{
app = new TerminalApp(config.Weight, config.Height, config.X, config.Y);
app = new TerminalApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(CubeApp))
{
app = new CubeApp(config.Weight, config.Height, config.X, config.Y);
app = new CubeApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(SystemInfoApp))
{
app = new SystemInfoApp(config.Weight, config.Height, config.X, config.Y);
app = new SystemInfoApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(MemoryInfoApp))
{
app = new MemoryInfoApp(config.Weight, config.Height, config.X, config.Y);
app = new MemoryInfoApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(GameBoyApp))
{
app = new GameBoyApp(config.Weight, config.Height, config.X, config.Y);
app = new GameBoyApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(SampleApp))
{
app = new SampleApp(config.Weight, config.Height, config.X, config.Y);
app = new SampleApp(config.Width, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(SettingsApp))
{
app = new SettingsApp(config.Weight, config.Height, config.X, config.Y);
app = new SettingsApp(config.Width, config.Height, config.X, config.Y);
}
/*else if (config.Template == typeof(ExplorerApp))
{
app = new ExplorerApp(Kernel.CurrentVolume, config.Weight, config.Height, config.X, config.Y);
}*/
else if (config.Template == typeof(EditorApp))
{
app = new EditorApp("", config.Weight, config.Height, config.X, config.Y);
app = new EditorApp("", config.Width, config.Height, config.X, config.Y);
}
else
{
Expand Down
36 changes: 29 additions & 7 deletions SRC/Aura_OS/System/Processing/Applications/SettingsApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public class SettingsApp : Application
Label _themeBmpPathLabel;
Label _themeXmlPathLabel;
Label _windowsAlphaLabel;
Label _taskbarAlphaLabel;

Checkbox _autoLogin;

Slider _windowsAlpha;
Slider _taskbarAlpha;

Button _save;

Expand All @@ -52,7 +54,8 @@ public SettingsApp(int width, int height, int x = 0, int y = 0) : base(Applicati
_computerNameLabel = new Label("Computer Name: ", Color.Black, labelX, baseY + (23 + spacing) * 2);
_themeBmpPathLabel = new Label("Theme BMP Path: ", Color.Black, labelX, baseY + (23 + spacing) * 3);
_themeXmlPathLabel = new Label("Theme XML Path: ", Color.Black, labelX, baseY + (23 + spacing) * 4);
_windowsAlphaLabel = new Label("Windows Alpha: ", Color.Black, labelX, baseY + (23 + spacing) * 6);
_windowsAlphaLabel = new Label("Windows Alpha: ", Color.Black, labelX, baseY + (23 + spacing) * 5);
_taskbarAlphaLabel = new Label("Taskbar Alpha: ", Color.Black, labelX, baseY + (23 + spacing) * 6);

int textBoxXOffset = 6 + (_themeXmlPathLabel.Text.Length * Kernel.font.Width);

Expand All @@ -61,25 +64,34 @@ public SettingsApp(int width, int height, int x = 0, int y = 0) : base(Applicati
_computerName = new TextBox(textBoxXOffset, baseY + (23 + spacing) * 2, 200, 23, "");
_themeBmpPath = new TextBox(textBoxXOffset, baseY + (23 + spacing) * 3, 200, 23, "");
_themeXmlPath = new TextBox(textBoxXOffset, baseY + (23 + spacing) * 4, 200, 23, "");

_windowsAlpha = new Slider(textBoxXOffset, baseY + (23 + spacing) * 6, 200, 23);
_windowsAlpha = new Slider(textBoxXOffset, baseY + (23 + spacing) * 5, 200, 23);
_taskbarAlpha = new Slider(textBoxXOffset, baseY + (23 + spacing) * 6, 200, 23);

if (Kernel.Installed)
{
Settings config = new Settings(@"0:\System\settings.ini");
string autologin = config.GetValue("autologin");
byte windowsTransparency = byte.Parse(config.GetValue("windowsTransparency"));
_windowsAlpha.Value = windowsTransparency;
byte taskbarTransparency = byte.Parse(config.GetValue("taskbarTransparency"));
_taskbarAlpha.Value = taskbarTransparency;

if (autologin == "true")
{
_autoLogin = new Checkbox("Auto LogIn: ", Color.Black, labelX, baseY + (23 + spacing) * 5, true);
_autoLogin = new Checkbox("Auto LogIn: ", Color.Black, labelX, baseY + (23 + spacing) * 7, true);
}
else
{
_autoLogin = new Checkbox("Auto LogIn: ", Color.Black, labelX, baseY + (23 + spacing) * 5);
_autoLogin = new Checkbox("Auto LogIn: ", Color.Black, labelX, baseY + (23 + spacing) * 7);
}
}

_save = new Button("Save Settings", Width / 2 - 100 / 2, baseY + (23 + spacing) * 7, 100, 23);
_save = new Button("Save Settings", Width / 2 - 100 / 2, baseY + (23 + spacing) * 8, 100, 23);
}
else
{
_save = new Button("Save Settings", Width / 2 - 100 / 2, baseY + (23 + spacing) * 7, 100, 23);
}

_save.Click = new Action(() =>
{
_showDialog = true;
Expand All @@ -91,13 +103,16 @@ public SettingsApp(int width, int height, int x = 0, int y = 0) : base(Applicati
Kernel.ThemeManager.BmpPath = _themeBmpPath.Text;
Kernel.ThemeManager.XmlPath = _themeXmlPath.Text;
Explorer.WindowManager.WindowsTransparency = (byte)_windowsAlpha.Value;
Explorer.WindowManager.TaskbarTransparency = (byte)_taskbarAlpha.Value;

if (Kernel.Installed)
{
Settings config = new Settings(@"0:\System\settings.ini");
config.EditValue("hostname", Kernel.ComputerName);
config.EditValue("themeBmpPath", Kernel.ThemeManager.BmpPath);
config.EditValue("themeXmlPath", Kernel.ThemeManager.XmlPath);
config.EditValue("windowsTransparency", Explorer.WindowManager.WindowsTransparency.ToString());
config.EditValue("taskbarTransparency", Explorer.WindowManager.TaskbarTransparency.ToString());
if (_autoLogin.Checked)
{
config.EditValue("autologin", "true");
Expand Down Expand Up @@ -130,13 +145,15 @@ public SettingsApp(int width, int height, int x = 0, int y = 0) : base(Applicati
AddChild(_themeBmpPath);
AddChild(_themeXmlPath);
AddChild(_windowsAlpha);
AddChild(_taskbarAlpha);

AddChild(_usernameLabel);
AddChild(_passwordLabel);
AddChild(_computerNameLabel);
AddChild(_themeBmpPathLabel);
AddChild(_themeXmlPathLabel);
AddChild(_windowsAlphaLabel);
AddChild(_taskbarAlphaLabel);

AddChild(_dialog);

Expand Down Expand Up @@ -164,6 +181,7 @@ public override void Update()
_themeBmpPath.Update();
_themeXmlPath.Update();
_windowsAlpha.Update();
_taskbarAlpha.Update();

if (Kernel.Installed)
{
Expand Down Expand Up @@ -196,6 +214,8 @@ public override void Draw()
_themeXmlPath.DrawInParent();
_windowsAlpha.Update();
_windowsAlpha.DrawInParent();
_taskbarAlpha.Update();
_taskbarAlpha.DrawInParent();

_usernameLabel.Draw();
_usernameLabel.DrawInParent();
Expand All @@ -209,6 +229,8 @@ public override void Draw()
_themeXmlPathLabel.DrawInParent();
_windowsAlphaLabel.Update();
_windowsAlphaLabel.DrawInParent();
_taskbarAlphaLabel.Update();
_taskbarAlphaLabel.DrawInParent();

if (Kernel.Installed)
{
Expand Down
2 changes: 2 additions & 0 deletions SRC/Aura_OS/System/Users/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ public void Installation()

config.PutValue("themeBmpPath", @"0:\System\Themes\Suave.bmp");
config.PutValue("themeXmlPath", @"0:\System\Themes\Suave.xml");
config.PutValue("windowsTransparency", "255");
config.PutValue("taskbarTransparency", "255");

config.PutValue("debugger", "off");

Expand Down

0 comments on commit 9d11866

Please sign in to comment.