Almost time for the real stuff.
This commit is contained in:
parent
339f8bd602
commit
29aa27267f
@ -1,3 +1,4 @@
|
|||||||
#include "basic_types.hpp"
|
#include "basic_types.hpp"
|
||||||
|
#include "enums.hpp"
|
||||||
#include "global_misc.hpp"
|
#include "global_misc.hpp"
|
||||||
#include "window_types.hpp"
|
#include "window_types.hpp"
|
||||||
|
|||||||
11
include/sharpsoft/enums.hpp
Normal file
11
include/sharpsoft/enums.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
namespace sharp
|
||||||
|
{
|
||||||
|
enum window_flags : uint32_t
|
||||||
|
{
|
||||||
|
WINDOW_ACTIVE = 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "sharpsoft/basic_types.hpp"
|
#include "sharpsoft/basic_types.hpp"
|
||||||
|
#include "sharpsoft/window_types.hpp"
|
||||||
|
|
||||||
namespace sharp
|
namespace sharp
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <string>
|
||||||
#include "sharpsoft/basic_types.hpp"
|
#include "sharpsoft/basic_types.hpp"
|
||||||
|
#include "sharpsoft/enums.hpp"
|
||||||
|
|
||||||
namespace sharp
|
namespace sharp
|
||||||
{
|
{
|
||||||
@ -10,14 +12,27 @@ namespace sharp
|
|||||||
private:
|
private:
|
||||||
uint16_t posX, posY;
|
uint16_t posX, posY;
|
||||||
uint16_t width, height;
|
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:
|
public:
|
||||||
const int2 get_pos() const;
|
const int2 get_pos() const;
|
||||||
const int2 get_size() const;
|
const int2 get_size() const;
|
||||||
const int_rect get_window_rect() 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_pos(const int2& new_pos);
|
||||||
void set_size(const int2& new_size);
|
void set_size(const int2& new_size);
|
||||||
void set_window_rect(const int_rect& new_rect);
|
void set_window_rect(const int_rect& new_rect);
|
||||||
|
void set_title(const std::string& new_title);
|
||||||
|
|
||||||
|
void show();
|
||||||
|
void hide();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/main.cpp
17
src/main.cpp
@ -4,11 +4,28 @@
|
|||||||
// This library is intended to be referenced by the prefix `sharp::`
|
// This library is intended to be referenced by the prefix `sharp::`
|
||||||
// Including `using namespace sharp;` is not recommended.
|
// 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()
|
void initialize()
|
||||||
{
|
{
|
||||||
// Initialize Sharpsoft.
|
// Initialize Sharpsoft.
|
||||||
sharp::initialize();
|
sharp::initialize();
|
||||||
|
|
||||||
|
test_window moment = test_window();
|
||||||
|
|
||||||
sharp::start();
|
sharp::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,19 @@
|
|||||||
|
#include "enums.hpp"
|
||||||
#include "sharpsoft/window_types.hpp"
|
#include "sharpsoft/window_types.hpp"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
using namespace sharp;
|
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
|
const int2 sharp::window_base::get_pos() const
|
||||||
{
|
{
|
||||||
return int2(posX, posY);
|
return int2(posX, posY);
|
||||||
@ -14,6 +26,14 @@ const int_rect sharp::window_base::get_window_rect() const
|
|||||||
{
|
{
|
||||||
return int_rect(posX, posY, width, height);
|
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)
|
||||||
{
|
{
|
||||||
@ -35,3 +55,20 @@ void sharp::window_base::set_window_rect(const int_rect &new_rect)
|
|||||||
width = new_rect.width;
|
width = new_rect.width;
|
||||||
height = new_rect.height;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user