Almost time for the real stuff.

This commit is contained in:
That_One_Nerd 2024-05-13 13:57:23 -04:00
parent 339f8bd602
commit 29aa27267f
6 changed files with 84 additions and 2 deletions

View File

@ -1,3 +1,4 @@
#include "basic_types.hpp"
#include "enums.hpp"
#include "global_misc.hpp"
#include "window_types.hpp"

View File

@ -0,0 +1,11 @@
#pragma once
#include <inttypes.h>
namespace sharp
{
enum window_flags : uint32_t
{
WINDOW_ACTIVE = 1,
};
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "sharpsoft/basic_types.hpp"
#include "sharpsoft/window_types.hpp"
namespace sharp
{

View File

@ -1,7 +1,9 @@
#pragma once
#include <inttypes.h>
#include <string>
#include "sharpsoft/basic_types.hpp"
#include "sharpsoft/enums.hpp"
namespace sharp
{
@ -10,14 +12,27 @@ namespace sharp
private:
uint16_t posX, posY;
uint16_t width, height;
std::string title;
window_flags flags;
protected:
window_base(const std::string& title, const int2& pos, const int2& size);
virtual void paint() = 0;
public:
const int2 get_pos() const;
const int2 get_size() const;
const int_rect get_window_rect() const;
const std::string get_title() const;
const bool is_active() const;
void set_pos(const int2& new_pos);
void set_size(const int2& new_size);
void set_window_rect(const int_rect& new_rect);
void set_title(const std::string& new_title);
void show();
void hide();
};
}

View File

@ -4,11 +4,28 @@
// This library is intended to be referenced by the prefix `sharp::`
// Including `using namespace sharp;` is not recommended.
class test_window : public sharp::window_base
{
protected:
void paint() override
{
}
public:
test_window() : window_base("Testing", sharp::int2(10, 10), sharp::int2(150, 100))
{
}
};
void initialize()
{
// Initialize Sharpsoft.
sharp::initialize();
test_window moment = test_window();
sharp::start();
}

View File

@ -1,7 +1,19 @@
#include "enums.hpp"
#include "sharpsoft/window_types.hpp"
using std::string;
using namespace sharp;
sharp::window_base::window_base(const string& title, const int2& pos, const int2& size)
{
this->title = title;
posX = pos.x;
posY = pos.y;
width = size.x;
width = size.y;
flags = (window_flags)0;
}
const int2 sharp::window_base::get_pos() const
{
return int2(posX, posY);
@ -14,8 +26,16 @@ const int_rect sharp::window_base::get_window_rect() const
{
return int_rect(posX, posY, width, height);
}
const string sharp::window_base::get_title() const
{
return title;
}
const bool sharp::window_base::is_active() const
{
return (flags & WINDOW_ACTIVE) > 0;
}
void sharp::window_base::set_pos(const int2 &new_pos)
void sharp::window_base::set_pos(const int2& new_pos)
{
// TODO: I'll have to re-render some parts.
posX = new_pos.x;
@ -27,7 +47,7 @@ void sharp::window_base::set_size(const int2& new_pos)
width = new_pos.x;
height = new_pos.y;
}
void sharp::window_base::set_window_rect(const int_rect &new_rect)
void sharp::window_base::set_window_rect(const int_rect& new_rect)
{
// TODO: I'll have to re-render some parts.
posX = new_rect.left;
@ -35,3 +55,20 @@ void sharp::window_base::set_window_rect(const int_rect &new_rect)
width = new_rect.width;
height = new_rect.height;
}
void sharp::window_base::set_title(const std::string& new_title)
{
title = new_title;
}
void sharp::window_base::hide()
{
// TODO: This will affect the renderer
flags = (window_flags)(flags & ~WINDOW_ACTIVE);
}
void sharp::window_base::show()
{
// TODO: This will affect the renderer
flags = (window_flags)(flags | WINDOW_ACTIVE);
}