Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "060320241546";
public static string revision = "100320242144";
}
}
30 changes: 30 additions & 0 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ public static void AddClipRect(Rectangle addedRect)
Explorer.WindowManager.ClipRects.Add(addedRect);
}

public static void AddClickRect(Rectangle addedRect)
{
int i = 0;
while (i < Explorer.WindowManager.ClickRects.Count)
{
Rectangle curRect = Explorer.WindowManager.ClickRects[i];

if (!(curRect.Left <= addedRect.Right &&
curRect.Right >= addedRect.Left &&
curRect.Top <= addedRect.Bottom &&
curRect.Bottom >= addedRect.Top))
{
i++;
continue;
}

Explorer.WindowManager.ClickRects.RemoveAt(i);
List<Rectangle> splitRects = RectSplit(curRect, addedRect);

foreach (var splitRect in splitRects)
{
Explorer.WindowManager.ClickRects.Add(splitRect);
}

i = 0;
}

Explorer.WindowManager.ClickRects.Add(addedRect);
}

public bool Intersects(Rectangle other)
{
return !(Left > other.Right || Right < other.Left || Top > other.Bottom || Bottom < other.Top);
Expand Down
52 changes: 49 additions & 3 deletions SRC/Aura_OS/System/Graphics/UI/GUI/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class WindowManager : IManager
public List<Application> Applications;
public List<Rectangle> ClipRects;

public List<Rectangle> ClickRects;

private int _highestZIndex = -1;
private DirectBitmap _screen;

Expand All @@ -37,6 +39,7 @@ public void Initialize()

Applications = new List<Application>();
ClipRects = new List<Rectangle>();
ClickRects = new List<Rectangle>();

if (Kernel.Installed)
{
Expand Down Expand Up @@ -95,6 +98,7 @@ public void DrawWindows()
if (Kernel.GuiDebug)
{
ClipRects.Clear();
ClickRects.Clear();
}

// Sort x index
Expand All @@ -117,6 +121,18 @@ public void DrawWindows()
Rectangle.AddClipRect(component.GetRectangle());
}
}

if (Kernel.GuiDebug)
{
if (component is Button)
{
Button button = component as Button;
if (button.Click != null)
{
Rectangle.AddClickRect(component.GetRectangle());
}
}
}
}

for (int j = 0; j < component.Children.Count; j++)
Expand All @@ -136,6 +152,26 @@ public void DrawWindows()
int left = parentRect.Left + childRect.Left;
Rectangle realRect = new Rectangle(top, left, childRect.Height + top, childRect.Width + left);
Rectangle.AddClipRect(realRect);


}
}

if (Kernel.GuiDebug)
{
if (child.Visible && child is Button)
{
Button button = child as Button;
if (button.Click != null)
{
Rectangle childRect = child.GetRectangle();
Rectangle parentRect = child.Parent.GetRectangle();
int top = parentRect.Top + childRect.Top;
int left = parentRect.Left + childRect.Left;
Rectangle realRect = new Rectangle(top, left, childRect.Height + top, childRect.Width + left);

Rectangle.AddClickRect(realRect);
}
}
}
}
Expand Down Expand Up @@ -180,7 +216,16 @@ public void DrawWindows()
var tempRect = Explorer.WindowManager.ClipRects[i];
DrawRect(tempRect.Left, tempRect.Top,
tempRect.Right - tempRect.Left + 1,
tempRect.Bottom - tempRect.Top + 1);
tempRect.Bottom - tempRect.Top + 1, green);
}

// Draw click rects
for (int i = 0; i < Explorer.WindowManager.ClickRects.Count; i++)
{
var tempRect = Explorer.WindowManager.ClickRects[i];
DrawRect(tempRect.Left, tempRect.Top,
tempRect.Right - tempRect.Left + 1,
tempRect.Bottom - tempRect.Top + 1, red);
}
}
}
Expand All @@ -202,10 +247,11 @@ public void DrawComponentAndChildren(Component component)
}

private int green = Color.Green.ToArgb();
private int red = Color.Red.ToArgb();

public void DrawRect(int x, int y, int width, int height)
public void DrawRect(int x, int y, int width, int height, int color)
{
_screen.DrawRectangle(green, x, y, width, height);
_screen.DrawRectangle(color, x, y, width, height);
}

public void SetScreen(DirectBitmap Screen)
Expand Down
12 changes: 12 additions & 0 deletions SRC/Aura_OS/System/Processing/ApplicationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public void StartApplication(Type appType)
Explorer.Taskbar.UpdateApplicationButtons();
}

public void StartApplication(Application app)
{
app.Initialize();
app.MarkFocused();
app.Visible = true;

Explorer.WindowManager.Applications.Add(app);
Kernel.ProcessManager.Start(app);

Explorer.Taskbar.UpdateApplicationButtons();
}

public Application Instantiate(Type appType)
{
foreach (var config in ApplicationTemplates)
Expand Down
41 changes: 41 additions & 0 deletions SRC/Aura_OS/System/Processing/Applications/LuaApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* PROJECT: Aura Operating System Development
* CONTENT: CosmosExecutable application.
* PROGRAMMERS: Valentin Charbonnier <[email protected]>
*/

using Aura_OS.System.Graphics.UI.GUI;

namespace Aura_OS.System.Processing.Applications
{
public class LuaApp : Application
{
private int _luaProcessPid = 0;

public LuaApp(string name, int pid, int width, int height, int x = 0, int y = 0) : base(name, width, height, x, y)
{
_luaProcessPid = pid;
}

public override void Update()
{
base.Update();

foreach (var child in Window.Children)
{
child.Update();
}
}

public override void Draw()
{
base.Draw();

foreach (var child in Window.Children)
{
child.Draw();
child.DrawInParent();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* PROGRAMMER(S): DA CRUZ Alexy <[email protected]>
*/

using Aura_OS.Processing;
using Aura_OS.System.Processing.Processes;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -102,62 +104,11 @@ private ReturnInfo RunCexe(Executable executable, List<string> args)

private ReturnInfo RunLua(string filePath)
{
try
{
// create Lua VM instance
var Lua = LuaAPI.NewState();

// load base libraries
Lua.L_OpenLibs();

// load and run Lua script file
var LuaScriptFile = filePath;
var status = Lua.L_DoFile(LuaScriptFile);

// capture errors
if (status != ThreadStatus.LUA_OK)
{
throw new Exception(Lua.ToString(-1));
}

// ensuare the value returned by 'main.lua' is a Lua table
if (!Lua.IsTable(-1))
{
throw new Exception(
"start's return value is not a table");
}

var AwakeRef = StoreMethod("main");

Lua.Pop(1);

CallMethod(AwakeRef);

int StoreMethod(string name)
{
Lua.GetField(-1, name);
if (!Lua.IsFunction(-1))
{
throw new Exception(string.Format(
"method {0} not found!", name));
}
return Lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);
}

void CallMethod(int funcRef)
{
Lua.RawGetI(LuaDef.LUA_REGISTRYINDEX, funcRef);
var status = Lua.PCall(0, 0, 0);
if (status != ThreadStatus.LUA_OK)
{
Console.WriteLine(Lua.ToString(-1));
}
}
}
catch (Exception e)
{
return new ReturnInfo(this, ReturnCode.ERROR, e.ToString());
}
LuaProcess process = new LuaProcess(Path.GetFileName(filePath), filePath);
process.Initialize();

Kernel.ProcessManager.Register(process);
Kernel.ProcessManager.Start(process);

return new ReturnInfo(this, ReturnCode.OK);
}
Expand Down
16 changes: 14 additions & 2 deletions SRC/Aura_OS/System/Processing/Interpreter/UniLua/LuaAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ int YieldK( int numResults,

ThreadStatus Status { get; }

string DebugGetInstructionHistory();
int GetPid();

string DebugGetInstructionHistory();
}

public interface ILuaState : ILuaAPI, ILuaAuxLib
Expand All @@ -124,7 +126,12 @@ public interface ILuaState : ILuaAPI, ILuaAuxLib

public static class LuaAPI
{
public static ILuaState NewState()
public static ILuaState NewState(int pid)
{
return new LuaState(pid);
}

public static ILuaState NewState()
{
return new LuaState();
}
Expand Down Expand Up @@ -1626,6 +1633,11 @@ private bool Index2Addr( int index, out StkId addr )
}
}

public int GetPid()
{
return _pid;
}

// private void RegisterGlobalFunc( string name, CSharpFunctionDelegate f )
// {
// API.PushCSharpFunction( f );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ public void L_OpenLibs()
new NameFuncPair( LuaDebugLib.LIB_NAME, LuaDebugLib.OpenLib ),
new NameFuncPair( LuaEncLib.LIB_NAME, LuaEncLib.OpenLib ),
new NameFuncPair( LuaCosmosCryptoLib.LIB_NAME, LuaCosmosCryptoLib.OpenLib ),
new NameFuncPair( LuaCosmosUiLib.LIB_NAME, LuaCosmosUiLib.OpenLib ),
};

for( var i=0; i<define.Length; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static int CO_Create( ILuaState lua )
return 1;
}

private static int AuxResume( ILuaState lua, ILuaState co, int narg )
public static int AuxResume( ILuaState lua, ILuaState co, int narg )
{
if(!co.CheckStack(narg)) {
lua.PushString("too many arguments to resume");
Expand Down
Loading