More basic stuff. Soon we'll get into the actual rendering, but that's not quite yet.
This commit is contained in:
parent
16b1636316
commit
339f8bd602
@ -1,2 +1,3 @@
|
|||||||
#include "basic_types.hpp"
|
#include "basic_types.hpp"
|
||||||
#include "global_misc.hpp"
|
#include "global_misc.hpp"
|
||||||
|
#include "window_types.hpp"
|
||||||
|
|||||||
@ -41,4 +41,14 @@ namespace sharp
|
|||||||
|
|
||||||
operator int2() const;
|
operator int2() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct int_rect
|
||||||
|
{
|
||||||
|
int left, top;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
int_rect();
|
||||||
|
int_rect(int left, int top, int width, int height);
|
||||||
|
int_rect(const int2 pos, const int2 size);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace sharp
|
namespace sharp
|
||||||
{
|
{
|
||||||
|
constexpr int screen_width = 480, screen_height = 240;
|
||||||
|
|
||||||
struct global_properties
|
struct global_properties
|
||||||
{
|
{
|
||||||
static const global_properties defaults;
|
static const global_properties defaults;
|
||||||
@ -16,6 +18,9 @@ namespace sharp
|
|||||||
void uninitialize();
|
void uninitialize();
|
||||||
void re_initialize();
|
void re_initialize();
|
||||||
void re_initialize(const global_properties& flags);
|
void re_initialize(const global_properties& flags);
|
||||||
|
|
||||||
bool is_initialized();
|
bool is_initialized();
|
||||||
|
|
||||||
|
void start();
|
||||||
|
void end();
|
||||||
|
bool is_started();
|
||||||
}
|
}
|
||||||
|
|||||||
23
include/sharpsoft/window_types.hpp
Normal file
23
include/sharpsoft/window_types.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "sharpsoft/basic_types.hpp"
|
||||||
|
|
||||||
|
namespace sharp
|
||||||
|
{
|
||||||
|
class window_base
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
uint16_t posX, posY;
|
||||||
|
uint16_t width, height;
|
||||||
|
|
||||||
|
public:
|
||||||
|
const int2 get_pos() const;
|
||||||
|
const int2 get_size() const;
|
||||||
|
const int_rect get_window_rect() const;
|
||||||
|
|
||||||
|
void set_pos(const int2& new_pos);
|
||||||
|
void set_size(const int2& new_size);
|
||||||
|
void set_window_rect(const int_rect& new_rect);
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -8,6 +8,8 @@ void initialize()
|
|||||||
{
|
{
|
||||||
// Initialize Sharpsoft.
|
// Initialize Sharpsoft.
|
||||||
sharp::initialize();
|
sharp::initialize();
|
||||||
|
|
||||||
|
sharp::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void disabled() { }
|
void disabled() { }
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using namespace sharp;
|
using namespace sharp;
|
||||||
|
|
||||||
|
|
||||||
sharp::color::color()
|
sharp::color::color()
|
||||||
{
|
{
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -87,3 +86,25 @@ sharp::float2::operator int2() const
|
|||||||
{
|
{
|
||||||
return int2(x, y);
|
return int2(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sharp::int_rect::int_rect()
|
||||||
|
{
|
||||||
|
left = 0;
|
||||||
|
top = 0;
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
}
|
||||||
|
sharp::int_rect::int_rect(int left, int top, int width, int height)
|
||||||
|
{
|
||||||
|
this->left = left;
|
||||||
|
this->top = top;
|
||||||
|
this->width = width;
|
||||||
|
this->height = height;
|
||||||
|
}
|
||||||
|
sharp::int_rect::int_rect(const int2 pos, const int2 size)
|
||||||
|
{
|
||||||
|
left = pos.x;
|
||||||
|
top = pos.y;
|
||||||
|
width = size.x;
|
||||||
|
height = size.y;
|
||||||
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const global_properties global_properties::defaults =
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool init = false;
|
bool init = false;
|
||||||
|
bool started = false;
|
||||||
color back_col;
|
color back_col;
|
||||||
|
|
||||||
void sharp::initialize()
|
void sharp::initialize()
|
||||||
@ -27,6 +28,7 @@ void sharp::initialize(const global_properties& props)
|
|||||||
void sharp::uninitialize()
|
void sharp::uninitialize()
|
||||||
{
|
{
|
||||||
if (!init) return;
|
if (!init) return;
|
||||||
|
if (started) sharp::end();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
@ -35,18 +37,44 @@ void sharp::uninitialize()
|
|||||||
|
|
||||||
void sharp::re_initialize()
|
void sharp::re_initialize()
|
||||||
{
|
{
|
||||||
|
bool restart = started;
|
||||||
if (!init) return;
|
if (!init) return;
|
||||||
uninitialize();
|
uninitialize();
|
||||||
initialize();
|
initialize();
|
||||||
|
if (restart) start();
|
||||||
}
|
}
|
||||||
void sharp::re_initialize(const global_properties& props)
|
void sharp::re_initialize(const global_properties& props)
|
||||||
{
|
{
|
||||||
|
bool restart = started;
|
||||||
if (!init) return;
|
if (!init) return;
|
||||||
uninitialize();
|
uninitialize();
|
||||||
initialize();
|
initialize();
|
||||||
|
if (restart) start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sharp::is_initialized()
|
bool sharp::is_initialized()
|
||||||
{
|
{
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sharp::start()
|
||||||
|
{
|
||||||
|
if (!init || started) return;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
void sharp::end()
|
||||||
|
{
|
||||||
|
if (!init || !started) return;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sharp::is_started()
|
||||||
|
{
|
||||||
|
return started;
|
||||||
|
}
|
||||||
|
|||||||
37
src/sharpsoft/window_base.cpp
Normal file
37
src/sharpsoft/window_base.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "sharpsoft/window_types.hpp"
|
||||||
|
|
||||||
|
using namespace sharp;
|
||||||
|
|
||||||
|
const int2 sharp::window_base::get_pos() const
|
||||||
|
{
|
||||||
|
return int2(posX, posY);
|
||||||
|
}
|
||||||
|
const int2 sharp::window_base::get_size() const
|
||||||
|
{
|
||||||
|
return int2(width, height);
|
||||||
|
}
|
||||||
|
const int_rect sharp::window_base::get_window_rect() const
|
||||||
|
{
|
||||||
|
return int_rect(posX, posY, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharp::window_base::set_pos(const int2 &new_pos)
|
||||||
|
{
|
||||||
|
// TODO: I'll have to re-render some parts.
|
||||||
|
posX = new_pos.x;
|
||||||
|
posY = new_pos.y;
|
||||||
|
}
|
||||||
|
void sharp::window_base::set_size(const int2& new_pos)
|
||||||
|
{
|
||||||
|
// TODO: I'll have to re-render some parts.
|
||||||
|
width = new_pos.x;
|
||||||
|
height = new_pos.y;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
posY = new_rect.top;
|
||||||
|
width = new_rect.width;
|
||||||
|
height = new_rect.height;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user