CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.9k stars 548 forks source link

How to create a GUI with Mouse ? #3043

Closed SanskarSontakke closed 1 month ago

SanskarSontakke commented 1 month ago

Area of Cosmos - 2022 dev kit

Expected Behaviour - I want a mouse

I want to create a GUI with mouse. Here is my current code :

using System;
using System.Collections.Generic;
using Cosmos.System.Graphics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.System;
using Sys = Cosmos.System;

namespace WindOS.Graphics
{
    public class GUI
    {
        private Canvas canvas;
        private MouseState prevMouseState;
        private TabBar tabBar;

        public GUI()
        {

            this.canvas = FullScreenCanvas.GetFullScreenCanvas();
            this.canvas.Clear(Color.AliceBlue);

            this.prevMouseState = MouseState.None;

            this.tabBar = new TabBar(this.canvas);

            MouseManager.ScreenHeight = (UInt32)1080;
            MouseManager.ScreenWidth = (UInt32)1920;

        }

        public void HandleGUIInputs()
        {

        }
    }
}

I want to use the function "HandleGUIInputs()" to show the mouse. I think that I should MouseManager.X and MouseManager.Y. But I don't know how to exactly use it. This is just a sub file and not the Kernel.cs. The linking and all stuff works perfect and I have tested it with many shapes. I just want it to show a mouse like a big dot or something like corsshair.

SzymekkYT commented 1 month ago

You should just draw an alpha image or just a filled rectangle for test: this.canvas.DrawFilledRectangle(Color.Black, MouseManager.X, MouseManager.Y, 10, 10);

SanskarSontakke commented 1 month ago

yes I did it but the screen gets flooded with the rectangles. I think so to delete the previous rectangle somehow.

SzymekkYT commented 1 month ago

Uhh you are not clearing your canvas. You can see a small cosmos OS here. Also with such things it's best to go to the official cosmos discord or discussions on github

SanskarSontakke commented 1 month ago

Thank you It helped a lot. I think so I should close it.