/SleekThink.depend
75634,7 → 75634,7
"GameEngine.h"
"GameIntro.h"
 
1423266049 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.h
1423335739 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.h
"../sleek/start.h"
"../sleek/gui/interface.h"
"GuiEventMapper.h"
76299,7 → 76299,7
"../math/vector2d.h"
<string>
 
1324743708 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/type.h
1423328898 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/type.h
 
1324743708 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/core/device/keycode.h
 
77410,9 → 77410,10
"../../gui/cursor.h"
"../../texture/fbo.h"
 
1420934427 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/frame.h
1423337629 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/frame.h
"font.h"
"type.h"
"../compile.h"
"../driver/texture.h"
"../driver/material.h"
"../device/event.h"
77558,13 → 77559,7
<FTGL/ftgl.h>
<FTGL/ftgl.h>
 
1421725968 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.h
"button.h"
"font.h"
"picture.h"
"progressbar.h"
"statictext.h"
"window.h"
1423332480 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.h
"../driver/driver.h"
"../driver/material.h"
 
77601,7 → 77596,7
"../sleek/start.h"
"../sleek/driver/mesh.h"
 
1423266033 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
1423332303 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
"GameCore.h"
"GameEngine.h"
"../sleek/loader/texture_loader.h"
77608,11 → 77603,13
 
1422762241 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/light.h
 
1423170875 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
1423336301 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
"GameCore.h"
"GameMenu.h"
"../sleek/loader/texture_loader.h"
"../sleek/gui/frame.h"
"../sleek/gui/button.h"
"../sleek/gui/colorpicker.h"
"../sleek/gui/font.h"
 
1324743736 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/texture/fractal.h
77844,7 → 77841,7
"ppuid.h"
"ppuid.h"
 
1420912122 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/button.cpp
1423320920 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/button.cpp
"interface.h"
"button.h"
 
77879,28 → 77876,35
"font.h"
<ft2build.h>
 
1420934427 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/frame.cpp
1423337629 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/frame.cpp
"interface.h"
"frame.h"
 
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/picture.cpp
1423320895 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/picture.cpp
"interface.h"
"picture.h"
 
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/progressbar.cpp
1423320986 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/progressbar.cpp
"interface.h"
"progressbar.h"
 
1420912245 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/statictext.cpp
1423321013 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/statictext.cpp
"interface.h"
"statictext.h"
 
1420904829 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.cpp
1423337804 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.cpp
"interface.h"
"../driver/driver.h"
"theme.h"
"button.h"
"font.h"
"picture.h"
"progressbar.h"
"statictext.h"
"window.h"
"scrollbar.h"
 
1423259805 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/window.cpp
1423337654 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/window.cpp
"interface.h"
"window.h"
 
80909,7 → 80913,7
<string>
"../math/vector2d.h"
 
1421724821 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.h
1423324421 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.h
"font.h"
"frame.h"
"theme.h"
80970,8 → 80974,14
"../compile.h"
<string.h>
 
1421724810 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.cpp
1423324939 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.cpp
"interface.h"
"button.h"
"statictext.h"
"progressbar.h"
"scrollbar.h"
"picture.h"
"window.h"
 
1420936619 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/texture.h
<iosfwd>
80990,7 → 81000,7
"../library/glm/vec3.hpp"
"../define.h"
 
1420769874 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/pixel.h
1423323505 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/pixel.h
"../define.h"
 
1421726113 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/reference.h
81006,7 → 81016,7
"vector2d.h"
"vector3d.h"
 
1421726113 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.h
1423332786 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.h
"fbo.h"
"texture.h"
"../device/device.h"
81171,7 → 81181,7
<iostream>
"console/spdlog.h"
 
1423175311 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
1423320711 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
 
1419891890 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl_driver.cpp
"../device/device.h"
81223,8 → 81233,9
"texture_array.h"
"texture3d.h"
 
1420904887 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/pixel.cpp
1423323548 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/pixel.cpp
"pixel.h"
"../math/function.h"
 
1420904887 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/timer.cpp
"timer.h"
81272,7 → 81283,7
1420573455 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl/ogl_driver.h
"../driver.h"
 
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.cpp
1423330144 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.cpp
"../device/device.h"
"driver.h"
 
81322,7 → 81333,7
"vertex.h"
"index.h"
 
1421726414 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.h
1423327887 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.h
"shader.h"
"rtype.h"
"../math/vector3d.h"
81351,7 → 81362,7
<vector>
"mesh.h"
 
1423175311 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.cpp
1423332326 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.cpp
"../compile.h"
"../define.h"
"context.h"
81500,12 → 81511,12
"ogl.h"
"../context.h"
 
1420936740 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.cpp
1423331502 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.cpp
"../../device/device.h"
"ogl_context.h"
"ogl_driver.h"
 
1422762373 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.h
1423331114 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.h
"ogl.h"
"../driver.h"
 
81516,7 → 81527,7
"ogl.h"
"../fbo.h"
 
1423175305 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_context.cpp
1423330165 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_context.cpp
"../../device/device.h"
"ogl_context.h"
"ogl_driver.h"
81690,7 → 81701,30
<GL/glx.h>
<windows.h>
 
1423266096 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GuiEventMapper.h
1423266416 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GuiEventMapper.h
"../gui/frame.h"
<map>
 
1423335463 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/scrollbar.cpp
"interface.h"
"scrollbar.h"
"../math/function.h"
 
1423333876 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/scrollbar.h
"frame.h"
 
1423335390 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/math/function.h
<memory>
 
1423337915 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/colorpicker.cpp
"colorpicker.h"
"interface.h"
"scrollbar.h"
"button.h"
"../driver/texture.h"
"../math/vector3d.h"
"../math/function.h"
 
1423336908 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/colorpicker.h
"frame.h"
 
/bin/SleekThink
Cannot display: file marked as a binary type.
svn:mime-type = application/x-executable
/bin/gmon.out
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/src/app/GameEngine.cpp
38,7 → 38,7
mat->setMaterialRender(driver::rmt_solid | driver::rmt_lighting);
mat->setTexture(0, crate->getIdentifier().get());
mat->setTexture(1, bundul->getIdentifier().get());
mat->setPointSize(2.f);
mat->setPointSize(1.f);
 
// shader creation sample
{
/src/app/GameMenu.cpp
3,6 → 3,8
 
#include "../sleek/loader/texture_loader.h"
#include "../sleek/gui/frame.h"
#include "../sleek/gui/button.h"
#include "../sleek/gui/colorpicker.h"
#include "../sleek/gui/font.h"
 
using namespace sleek;
62,7 → 64,10
core->changeState(GMS_GAME);
break;
case 11:
core->changeState(GMS_GAME);
{
auto color = std::make_shared<sleek::gui::colorpicker>(guienv);
guienv->addCustomFrame(color);
}
break;
case 12:
a->exit_msg = true;
69,6 → 74,9
break;
}
break;
case gui::IET_COLORPICKER_SELECTED:
guienv->removeFrame(a->gui.called->getptr());
break;
}
return false;
}
/src/sleek/compile.h
20,3 → 20,4
#define video_reader_audio_support
 
#define reserved_texture 4
#define gui_frame_userdata 2
/src/sleek/driver/driver.cpp
5,8 → 5,8
{
namespace driver
{
driver::driver(std::shared_ptr<device::Device> dev) noexcept
: src(dev), mat(nullptr)
driver::driver(std::shared_ptr<device::Device> dev, std::shared_ptr<context> c) noexcept
: src(dev), ctx(c), mat(nullptr)
{
}
 
13,5 → 13,10
driver::~driver() noexcept
{
}
 
std::shared_ptr<context> driver::getContext()
{
return ctx;
}
}
}
/src/sleek/driver/driver.h
16,10 → 16,14
}
namespace driver
{
class context;
/**
* TODO const-correctness
*/
class driver : public std::enable_shared_from_this<driver>
{
public:
driver(std::shared_ptr<device::Device>) noexcept;
driver(std::shared_ptr<device::Device>, std::shared_ptr<context>) noexcept;
virtual ~driver() noexcept;
 
inline std::shared_ptr<driver> getptr() noexcept
27,47 → 31,51
return shared_from_this();
}
 
virtual void drawPixel(math::vector2di, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPixel(math::vector3df, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawLine(math::vector2di, math::vector2di, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawLine(math::vector3df, math::vector3df, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawArc(math::vector2di, u32, u32, u32, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPixel(math::vector2di, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawPixel(math::vector3df, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawLine(math::vector2di, math::vector2di, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawLine(math::vector3df, math::vector3df, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawArc(math::vector2di, u32, u32, u32, math::pixel c = math::pixel()) const noexcept = 0;
 
virtual void drawCube(math::aabbox2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawCube(math::aabbox3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawCube(math::vector2di, math::vector2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawCube(math::vector3df, math::vector3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawCube(math::aabbox2di, math::vector3df rot, math::pixel upperleft, math::pixel upperright, math::pixel lowerleft, math::pixel lowerright) const noexcept = 0;
virtual void drawCube(math::aabbox2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawCube(math::aabbox3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawCube(math::vector2di, math::vector2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawCube(math::vector3df, math::vector3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
 
virtual void drawCircle(math::vector2di pos, u32 radius = 5.f, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawCircle(math::vector2di pos, u32 radius = 5.f, math::pixel c = math::pixel()) const noexcept = 0;
 
virtual void drawPolygon(math::vector2di, math::vector2di, math::vector2di, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPolygon(math::vector3df, math::vector3df, math::vector3df, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPolygonList(math::vector2di *a, u32 n, math::vector2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPolygonList(math::vector3df *a, u32 n, math::vector3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept= 0;
virtual void drawPolygon(math::vector2di, math::vector2di, math::vector2di, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawPolygon(math::vector3df, math::vector3df, math::vector3df, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawPolygonList(math::vector2di *a, u32 n, math::vector2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
virtual void drawPolygonList(math::vector3df *a, u32 n, math::vector3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept = 0;
 
virtual void drawFBO(fbo*) const noexcept= 0;
virtual void drawFBO(fbo*) const noexcept = 0;
 
virtual void drawTexture(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept= 0;
virtual void drawTexture(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept= 0;
virtual void drawTexture(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
virtual void drawTexture(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
 
virtual void drawTextureCenter(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept= 0;
virtual void drawTextureCenter(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept= 0;
virtual void drawTextureCenter(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
virtual void drawTextureCenter(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
 
virtual void drawTextureScale(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}) const noexcept= 0;
virtual void drawTextureScale(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}) const noexcept= 0;
virtual void drawTextureScale(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
virtual void drawTextureScale(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept = 0;
 
virtual void drawMesh(MeshBuffer*, math::vector3df, math::vector3df rot = {0, 0, 0}) const noexcept= 0;
virtual void drawMesh(MeshBuffer*, math::vector3df, math::vector3df rot = {0, 0, 0}) const noexcept = 0;
 
virtual void setActiveMaterial(material*) noexcept = 0;
virtual material* getActiveMaterial() const noexcept= 0;
virtual material* getActiveMaterial() const noexcept = 0;
 
virtual void ObjectRenderBegin() const noexcept= 0;
virtual void ObjectRenderEnd() const noexcept= 0;
virtual void ObjectRenderBegin() const noexcept = 0;
virtual void ObjectRenderEnd() const noexcept = 0;
 
virtual void beginTo2D() const noexcept= 0;
virtual void endFrom2D() const noexcept= 0;
virtual void beginTo2D() const noexcept = 0;
virtual void endFrom2D() const noexcept = 0;
 
virtual std::shared_ptr<context> getContext();
protected:
std::shared_ptr<device::Device> src;
std::shared_ptr<context> ctx;
material *mat;
u32 tricounter;
};
/src/sleek/driver/material.cpp
7,7 → 7,7
{
namespace driver
{
material::material() noexcept : psize(1.f)
material::material() noexcept : psize(1)
{
scale = math::vector3df(1);
 
/src/sleek/driver/material.h
49,6 → 49,7
std::shared_ptr<identifier> effect;
std::vector<identifier*> Texture;
};
static material identitymaterial;
}
}
 
/src/sleek/driver/ogl3/ogl_context.cpp
157,7 → 157,7
 
std::shared_ptr<driver> ogl_context::createDriver() noexcept
{
return std::make_shared<ogl_driver>(win);
return std::make_shared<ogl_driver>(win, getptr());
}
 
std::shared_ptr<identifier> ogl_context::createTexture(texture *o, bool DSA) const noexcept
/src/sleek/driver/ogl3/ogl_driver.cpp
15,8 → 15,8
{
namespace driver
{
ogl_driver::ogl_driver(std::shared_ptr<device::Device> &dev) noexcept
: driver(dev)
ogl_driver::ogl_driver(std::shared_ptr<device::Device> dev, std::shared_ptr<context> c) noexcept
: driver(dev, c)
{
quad = glGenLists(1);
quadc = glGenLists(1);
146,6 → 146,40
}
}
 
void ogl_driver::drawCube(math::aabbox2di c, math::vector3df rot, math::pixel upperleft, math::pixel upperright, math::pixel lowerleft, math::pixel lowerright) const noexcept
{
if(!src->ready()) return;
math::vector2di pos = c.getCenter();
 
ObjectRenderBegin();
beginTo2D();
glTranslatef(pos.x,pos.y,0);
glRotatef(rot.x,rot.y,rot.z);
glScalef(c.getSize().x, c.getSize().y,1);
glBegin(ogl_render_mode[mat->getMode()]);
glNormal3f(0,0,0);
 
glColor4ub(lowerleft.red, lowerleft.green, lowerleft.blue, lowerleft.alpha);
glTexCoord3i(0,0,0);
glVertex3f(-0.5f, 0.5f,0);
 
glColor4ub(upperleft.red, upperleft.green, upperleft.blue, upperleft.alpha);
glTexCoord3i(0,1,0);
glVertex3f(-0.5f,-0.5f,0);
 
glColor4ub(upperright.red, upperright.green, upperright.blue, upperright.alpha);
glTexCoord3i(1,1,0);
glVertex3f( 0.5f,-0.5f,0);
 
glColor4ub(lowerright.red, lowerright.green, lowerright.blue, lowerright.alpha);
glTexCoord3i(1,0,0);
glVertex3f( 0.5f, 0.5f,0);
 
glEnd();
endFrom2D();
ObjectRenderEnd();
}
 
void ogl_driver::drawCube(math::aabbox2di c, math::vector3df rot, math::pixel clr) const noexcept
{
if(!src->ready()) return;
260,67 → 294,95
ObjectRenderEnd();
}
 
void ogl_driver::drawTexture(texture *tex, math::vector2di pos, math::vector3df rot) const noexcept
void ogl_driver::drawTexture(texture *tex, math::vector2di pos, math::vector3df rot, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
beginTo2D();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
tex->getIdentifier()->bind();
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,0);
glRotatef(rot.x,rot.y,rot.z);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glCallList(quad);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,0,0); glVertex3f(0,0,0);
glTexCoord3f(uv.x,0,0); glVertex3f(1,0,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f(1,1,0);
glTexCoord3f(0,uv.y,0); glVertex3f(0,1,0);
glEnd();
tex->getIdentifier()->unbind();
endFrom2D();
ObjectRenderEnd();
}
 
void ogl_driver::drawTexture(texture *tex, math::vector3df pos, math::vector3df rot) const noexcept
void ogl_driver::drawTexture(texture *tex, math::vector3df pos, math::vector3df rot, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
tex->getIdentifier()->bind();
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,pos.z);
glRotatef(rot.x,rot.y,rot.z);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glCallList(quadc);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,uv.y,0); glVertex3f(-0.5f,-0.5f,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f( 0.5f,-0.5f,0);
glTexCoord3f(uv.x,0,0); glVertex3f( 0.5f, 0.5f,0);
glTexCoord3f(0,0,0); glVertex3f(-0.5f, 0.5f,0);
glEnd();
tex->getIdentifier()->unbind();
ObjectRenderEnd();
}
 
void ogl_driver::drawTextureScale(texture *tex, math::vector2di pos, math::vector3df rot, math::vector3df scl) const noexcept
void ogl_driver::drawTextureScale(texture *tex, math::vector2di pos, math::vector3df rot, math::vector3df scl, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
beginTo2D();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
tex->getIdentifier()->bind();
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,0);
glRotatef(rot.x,rot.y,rot.z);
glScalef(scl.x,scl.y,scl.z);
glCallList(quad);
glScalef(scl.x,scl.y,scl.z);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,0,0); glVertex3f(0,0,0);
glTexCoord3f(uv.x,0,0); glVertex3f(1,0,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f(1,1,0);
glTexCoord3f(0,uv.y,0); glVertex3f(0,1,0);
glEnd();
tex->getIdentifier()->unbind();
endFrom2D();
ObjectRenderEnd();
}
 
void ogl_driver::drawTextureScale(texture *tex, math::vector3df pos, math::vector3df rot, math::vector3df scl) const noexcept
void ogl_driver::drawTextureScale(texture *tex, math::vector3df pos, math::vector3df rot, math::vector3df scl, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
tex->getIdentifier()->bind();
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,pos.z);
glRotatef(rot.x,rot.y,rot.z);
glScalef(scl.x,scl.y,scl.z);
glCallList(quadc);
glScalef(scl.x,scl.y,scl.z);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,uv.y,0); glVertex3f(-0.5f,-0.5f,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f( 0.5f,-0.5f,0);
glTexCoord3f(uv.x,0,0); glVertex3f( 0.5f, 0.5f,0);
glTexCoord3f(0,0,0); glVertex3f(-0.5f, 0.5f,0);
glEnd();
tex->getIdentifier()->unbind();
ObjectRenderEnd();
}
 
void ogl_driver::drawTextureCenter(texture *tex, math::vector2di pos, math::vector3df rot) const noexcept
void ogl_driver::drawTextureCenter(texture *tex, math::vector2di pos, math::vector3df rot, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
beginTo2D();
330,23 → 392,36
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,0);
glRotatef(rot.x,rot.y,rot.z);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glCallList(quadc);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,uv.y,0); glVertex3f(-0.5f,-0.5f,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f( 0.5f,-0.5f,0);
glTexCoord3f(uv.x,0,0); glVertex3f( 0.5f, 0.5f,0);
glTexCoord3f(0,0,0); glVertex3f(-0.5f, 0.5f,0);
glEnd();
tex->getIdentifier()->unbind();
endFrom2D();
ObjectRenderEnd();
}
 
void ogl_driver::drawTextureCenter(texture *tex, math::vector3df pos, math::vector3df rot) const noexcept
void ogl_driver::drawTextureCenter(texture *tex, math::vector3df pos, math::vector3df rot, math::vector2df uv) const noexcept
{
ObjectRenderBegin();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
tex->getIdentifier()->bind();
glColor4ub(255,255,255,255);
glTranslatef(pos.x,pos.y,pos.z);
glRotatef(rot.x,rot.y,rot.z);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glCallList(quadc);
glScalef(tex->getOriginalSize().x,tex->getOriginalSize().y,1);
glBegin(GL_QUADS);
glNormal3f(0,0,0);
glTexCoord3f(0,uv.y,0); glVertex3f(-0.5f,-0.5f,0);
glTexCoord3f(uv.x,uv.y,0); glVertex3f( 0.5f,-0.5f,0);
glTexCoord3f(uv.x,0,0); glVertex3f( 0.5f, 0.5f,0);
glTexCoord3f(0,0,0); glVertex3f(-0.5f, 0.5f,0);
glEnd();
glDisable(GL_TEXTURE_2D);
ObjectRenderEnd();
}
/src/sleek/driver/ogl3/ogl_driver.h
15,7 → 15,7
class ogl_driver : public driver
{
public:
ogl_driver(std::shared_ptr<device::Device>&) noexcept;
ogl_driver(std::shared_ptr<device::Device>, std::shared_ptr<context>) noexcept;
virtual ~ogl_driver() noexcept;
 
virtual void drawPixel(math::vector2di, math::pixel c = math::pixel()) const noexcept;
22,8 → 22,9
virtual void drawPixel(math::vector3df, math::pixel c = math::pixel()) const noexcept;
virtual void drawLine(math::vector2di, math::vector2di, math::pixel c = math::pixel()) const noexcept;
virtual void drawLine(math::vector3df, math::vector3df, math::pixel c = math::pixel()) const noexcept;
virtual void drawArc(math::vector2di, u32, u32, u32, math::pixel c = math::pixel()) const noexcept;
virtual void drawArc(math::vector2di, u32, u32, u32, math::pixel c = math::pixel()) const noexcept;
 
virtual void drawCube(math::aabbox2di, math::vector3df rot, math::pixel upperleft, math::pixel upperright, math::pixel lowerleft, math::pixel lowerright) const noexcept;
virtual void drawCube(math::aabbox2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept;
virtual void drawCube(math::aabbox3df, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept;
virtual void drawCube(math::vector2di, math::vector2di, math::vector3df rot = {0, 0, 0}, math::pixel c = math::pixel()) const noexcept;
38,14 → 39,14
 
virtual void drawFBO(fbo*) const noexcept;
 
virtual void drawTexture(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept;
virtual void drawTexture(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept;
virtual void drawTexture(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
virtual void drawTexture(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
 
virtual void drawTextureCenter(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept;
virtual void drawTextureCenter(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}) const noexcept;
virtual void drawTextureCenter(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
virtual void drawTextureCenter(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
 
virtual void drawTextureScale(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}) const noexcept;
virtual void drawTextureScale(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}) const noexcept;
virtual void drawTextureScale(texture*, math::vector2di pos = {0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
virtual void drawTextureScale(texture*, math::vector3df pos = {0, 0, 0}, math::vector3df rot = {0, 0, 0}, math::vector3df scl = {0, 0, 0}, math::vector2df uv = {1.f, 1.f}) const noexcept;
 
virtual void drawMesh(MeshBuffer*, math::vector3df, math::vector3df rot = {0, 0, 0}) const noexcept;
 
/src/sleek/gui/button.cpp
39,10 → 39,20
bool button::manage(device::input* e) noexcept
{
bool CHovored = hovored, CPushed = pushed;
if(frame::manage(e)) { pushed = hovored; hovored = false; return true; }
 
if(e->type == device::EVENT_MOUSSE_MOVED) hovored = box.intersect(e->mouse_pos);
if(e->type == device::EVENT_MOUSSE_DOWN && e->mouse[device::MOUSE_LEFT] && hovored) pushed = true;
if(frame::manage(e))
{
pushed = hovored;
hovored = false;
return true;
}
 
if(e->type == device::EVENT_MOUSSE_MOVED)
hovored = box.intersect(e->mouse_pos);
 
if(e->type == device::EVENT_MOUSSE_DOWN && e->mouse[device::MOUSE_LEFT] && hovored)
pushed = true;
 
if(e->type == device::EVENT_MOUSSE_UP && e->mouse[device::MOUSE_LEFT])
{
if(hovored && pushed)
65,10 → 75,12
if(CHovored != hovored)
{
e->gui.called = this;
if(hovored) e->gui.code = gui::IET_BUTTON_HOVERED;
else e->gui.code = gui::IET_BUTTON_FOCUSED;
e->gui.code = hovored ?
gui::IET_BUTTON_HOVERED :
gui::IET_BUTTON_FOCUSED;
return true;
}
 
return false;
}
 
/src/sleek/gui/colorpicker.cpp
0,0 → 1,312
#include "colorpicker.h"
 
#include "interface.h"
#include "scrollbar.h"
#include "button.h"
#include "../driver/texture.h"
#include "../math/vector3d.h"
#include "../math/function.h"
 
namespace sleek
{
inline math::vector3df RGBftoHSV(const math::pixel &rgb)
{
math::vector3df hsv;
 
f32 M = math::max(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
f32 m = math::min(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
f32 C = M - m;
 
if(C == 0)
hsv.x = 0;
else if(M <= rgb.getRed())
hsv.x =((rgb.getGreen() - rgb.getBlue()) / C);
else if(M <= rgb.getGreen())
hsv.x =((rgb.getBlue() - rgb.getRed()) / C) + 2;
else if(M <= rgb.getBlue())
hsv.x =((rgb.getRed() - rgb.getGreen()) / C) + 4;
 
hsv.x *= 60;
if(hsv.x < 0)
hsv.x += 360;
 
hsv.y = M;
 
if(hsv.y == 0) hsv.z = 0;
else hsv.z = C / hsv.y;
 
return hsv;
}
namespace gui
{
colorpicker::colorpicker(interface *guienv) noexcept
: frame(guienv), background{64, 255, 255, 255}, white{255, 255, 255, 255}, black{0, 0, 0, 255},
colorpos(0), isGradient(false), isColor(false)
{
mat.setMode(driver::rmd_quad);
 
close = guienv->addButton("take this color", {5, 140, 85, 156});
close->setParent(this);
 
scroll = guienv->addScrollbar(true, {5, 125, 85, 135});
scroll->setParent(this);
scroll->setMin(0);
scroll->setMax(255);
scroll->setValue(255);
 
createAlphaTexture();
createGradientTexture();
 
setPickedColor({255, 64, 64, 128});
}
colorpicker::~colorpicker() noexcept
{
}
void colorpicker::createAlphaTexture() noexcept
{
img[0] = std::make_shared<driver::texture>(math::vector2di{16, 16});
math::pixel color;
 
#define square(colorstart, sx, sy, sz, sw) \
color = colorstart; \
for(int y=sy; y<sw; ++y) \
for(int x=sx; x<sz; ++x) \
img[0]->setPixel({x, y}, color); \
 
square(math::pixel(153, 153, 153), 0, 0, 8, 8);
square(math::pixel(153, 153, 153), 8, 8, 16, 16);
square(math::pixel(102, 102, 102), 8, 0, 16, 8);
square(math::pixel(102, 102, 102), 0, 8, 8, 16);
 
#undef square
 
img[0]->createIdentifier(mom->getDrawManager()->getContext().get());
img[0]->getIdentifier()->update();
}
void colorpicker::createGradientTexture() noexcept
{
img[1] = std::make_shared<driver::texture>(math::vector2di{15, 151});
 
math::pixel from;
math::pixel to;
 
#define interpolate(colorstart, colorend, start, end) \
from = colorstart; \
to = colorend; \
\
for(int y=start; y<end; ++y) \
{ \
math::pixel c = to.getInterpolated( \
from, (y-start)/25.f \
); \
\
for(int x=0; x<15; ++x) \
img[1]->setPixel({x, y}, c); \
}
 
interpolate(math::pixel(255, 0, 0), math::pixel(255, 0, 255), 0, 25);
interpolate(math::pixel(255, 0, 255), math::pixel( 0, 0, 255), 25, 50);
 
interpolate(math::pixel(0, 0, 255), math::pixel(0, 255, 255), 50, 75);
interpolate(math::pixel(0, 255, 255), math::pixel(0, 255, 0), 75, 100);
 
interpolate(math::pixel( 0, 255, 0), math::pixel(255, 255, 0), 100, 125);
interpolate(math::pixel(255, 255, 0), math::pixel(255, 0, 0), 125, 151);
 
#undef interpolate
 
img[1]->createIdentifier(mom->getDrawManager()->getContext().get());
img[1]->getIdentifier()->update();
}
void colorpicker::setScale(math::vector2di i) noexcept
{
colorpicker::setScale({110, 160});
}
bool colorpicker::manage(device::input *e) noexcept
{
math::vector2di pos(e->mouse_pos);
 
if(e->type == device::EVENT_MOUSSE_DOWN)
{
isGradient = gradient.intersect(pos);
isColor = colorbox.intersect(pos);
isInside = box.intersect(pos);
}
 
if(e->type == device::EVENT_MOUSSE_UP)
isGradient = isColor = false;
 
if(isGradient)
{
if(pos.x < gradient.upperleft.x)
pos.x = gradient.upperleft.x;
if(pos.y < gradient.upperleft.y)
pos.y = gradient.upperleft.y;
 
if(pos.x > gradient.lowerright.x)
pos.x = gradient.lowerright.x;
if(pos.y > gradient.lowerright.y)
pos.y = gradient.lowerright.y;
 
colorpos = pos.y - gradient.upperleft.y;
color = img[1]->getPixel({0, colorpos});
recalculatePickedColor();
}
 
if(isColor)
{
if(pos.x < colorbox.upperleft.x)
pos.x = colorbox.upperleft.x;
if(pos.y < colorbox.upperleft.y)
pos.y = colorbox.upperleft.y;
 
if(pos.x > colorbox.lowerright.x)
pos.x = colorbox.lowerright.x;
if(pos.y > colorbox.lowerright.y)
pos.y = colorbox.lowerright.y;
 
pickpos.x = pos.x - colorbox.upperleft.x;
pickpos.y = pos.y - colorbox.upperleft.y;
recalculatePickedColor();
}
 
if(isGradient || isColor)
{
e->gui.called = this;
e->gui.type = gui::IGT_COLORPICKER;
e->gui.code = gui::IET_COLORPICKER_UPDATED;
return true;
}
 
if(frame::manage(e))
{
switch(e->gui.code)
{
case IET_BUTTON_CLICKED:
e->gui.called = this;
e->gui.type = gui::IGT_COLORPICKER;
e->gui.code = gui::IET_COLORPICKER_SELECTED;
break;
case IET_SCROLLBAR_UPDATED:
recalculatePickedColor();
e->gui.called = this;
e->gui.type = gui::IGT_COLORPICKER;
e->gui.code = gui::IET_COLORPICKER_UPDATED;
break;
}
return true;
}
 
return false;
}
void colorpicker::recalculatePickedColor() noexcept
{
math::pixel hcolor = color.getInterpolated(white, pickpos.x/80.f);
 
pickcolor = black.getInterpolated(hcolor, pickpos.y/80.f);
pickcolor.setAlpha(scroll->getValue());
 
alpha = color;
alpha.setAlpha(0);
}
void colorpicker::setPickedColor(const math::pixel &c) noexcept
{
pickcolor = c;
 
math::vector3df hsv = RGBftoHSV(c);
 
colorpos = 150-hsv.x/360.f*150.f;
pickpos.x = hsv.y*80.f;
pickpos.y = 80-(hsv.z)*80.f;
 
color = img[1]->getPixel({0, colorpos});
color.setAlpha(255);
 
alpha = color;
alpha.setAlpha(0);
}
const math::pixel& colorpicker::getPickedColor() const noexcept
{
return pickcolor;
}
void colorpicker::setBackgroundColor(const math::pixel &b) noexcept
{
background = b;
}
const math::pixel& colorpicker::getBackgroundColor() const noexcept
{
return background;
}
void colorpicker::UpdateAbsolutePosition() noexcept
{
frame::UpdateAbsolutePosition();
 
colorbox.upperleft = box.upperleft;
colorbox.lowerright = box.upperleft;
colorbox.upperleft.x += 5;
colorbox.upperleft.y += 5;
colorbox.lowerright.x += 85;
colorbox.lowerright.y += 85;
 
gradient.upperleft = box.upperleft;
gradient.lowerright = box.upperleft;
gradient.upperleft.x += 90;
gradient.upperleft.y += 5;
gradient.lowerright.x += 105;
gradient.lowerright.y += 155;
 
pickbox.upperleft = box.upperleft;
pickbox.lowerright = box.upperleft;
pickbox.upperleft.x += 5;
pickbox.upperleft.y += 90;
pickbox.lowerright.x += 85;
pickbox.lowerright.y += 120;
}
void colorpicker::render() noexcept
{
if(!show) return;
 
frame::render();
 
mom->getDrawManager()->setActiveMaterial(&mat);
mom->getDrawManager()->drawTexture(img[1].get(), {
box.upperleft.x+90,
box.upperleft.y+5
});
 
// 2 draw because the interpolation in the diagonal is not well rendered
mom->getDrawManager()->drawCube(colorbox, {0, 0, 0}, black);
mom->getDrawManager()->drawCube(colorbox, {0, 0, 0}, white, color, alpha, alpha);
 
{
const math::vector2di start = {box.upperleft.x+90, box.upperleft.y+5+colorpos};
const math::vector2di end = {box.upperleft.x+105, box.upperleft.y+5+colorpos};
const math::vector2di hstart = {colorbox.upperleft.x, colorbox.upperleft.y+pickpos.y};
const math::vector2di hend = {colorbox.lowerright.x, colorbox.upperleft.y+pickpos.y};
const math::vector2di vstart = {colorbox.upperleft.x+pickpos.x, colorbox.upperleft.y};
const math::vector2di vend = {colorbox.upperleft.x+pickpos.x, colorbox.lowerright.y};
 
mom->getDrawManager()->drawLine({ start.x, start.y-1}, { end.x, end.y-1}, white);
mom->getDrawManager()->drawLine({ start.x, start.y+1}, { end.x, end.y+1}, white);
mom->getDrawManager()->drawLine({hstart.x, hstart.y-1}, {hend.x, hend.y-1}, white);
mom->getDrawManager()->drawLine({hstart.x, hstart.y+1}, {hend.x, hend.y+1}, white);
mom->getDrawManager()->drawLine({vstart.x-1, vstart.y}, {vend.x-1, vend.y }, white);
mom->getDrawManager()->drawLine({vstart.x+1, vstart.y}, {vend.x+1, vend.y }, white);
 
mom->getDrawManager()->drawLine(start, end, black);
mom->getDrawManager()->drawLine(hstart, hend, black);
mom->getDrawManager()->drawLine(vstart, vend, black);
}
 
auto scl = pickbox.getSize();
 
mom->getDrawManager()->drawTextureScale(
img[0].get(), pickbox.upperleft, {0, 0, 0},
{scl.x, scl.y, 0}, {scl.x/16.f, scl.y/16.f}
);
mom->getDrawManager()->drawCube(
pickbox, {0, 0, 0}, pickcolor
);
}
}
}
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/gui/colorpicker.h
===================================================================
--- src/sleek/gui/colorpicker.h (nonexistent)
+++ src/sleek/gui/colorpicker.h (revision 13)
@@ -0,0 +1,55 @@
+#ifndef COLOR_PICKER
+#define COLOR_PICKER
+
+#include "frame.h"
+
+namespace sleek
+{
+ namespace gui
+ {
+ class interface;
+ class scrollbar;
+ class button;
+
+ class colorpicker : public frame
+ {
+ public:
+ colorpicker(interface*) noexcept;
+ ~colorpicker() noexcept;
+
+ virtual INTERFACE_GUI_CODE getType() const noexcept { return IGT_COLORPICKER; }
+
+ virtual void setScale(math::vector2di i) noexcept;
+
+ virtual bool manage(device::input*) noexcept;
+
+ virtual void setPickedColor(const math::pixel&) noexcept;
+ virtual const math::pixel& getPickedColor() const noexcept;
+
+ virtual void setBackgroundColor(const math::pixel&) noexcept;
+ virtual const math::pixel& getBackgroundColor() const noexcept;
+
+ virtual void render() noexcept;
+ protected:
+ bool isGradient, isColor, isInside;
+ virtual void recalculatePickedColor() noexcept;
+ virtual void createAlphaTexture() noexcept;
+ virtual void createGradientTexture() noexcept;
+ virtual void UpdateAbsolutePosition() noexcept;
+ protected:
+ std::shared_ptr<button> close;
+ std::shared_ptr<scrollbar> scroll;
+ std::shared_ptr<driver::texture> img[2];
+ protected:
+ math::pixel pickcolor, color;
+ math::pixel background, white, black, alpha;
+ math::aabbox2di colorbox, pickbox, gradient;
+ math::vector2di pickpos;
+ int colorpos;
+ private:
+ driver::material mat;
+ };
+ }
+}
+
+#endif
/src/sleek/gui/colorpicker.h
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/gui/frame.cpp
===================================================================
--- src/sleek/gui/frame.cpp (revision 12)
+++ src/sleek/gui/frame.cpp (revision 13)
@@ -8,7 +8,7 @@
frame::frame(interface *m) noexcept : mom(m)
{
textsize = 12;
- parent = 0;
+ parent = nullptr;
show = true;
isActive = false;
ft2 = mom->getInternalFont();
@@ -16,8 +16,7 @@
}
frame::~frame() noexcept
- {
- child.clear();
+ {
}
void frame::setFontCache(std::shared_ptr<fontcache> i) noexcept
@@ -35,7 +34,7 @@
child.push_back(i);
i->relative = i->absolute;
i->absolute = absolute+relative;
- i->parent = getptr();
+ i->parent = this;
}
void frame::removeChild(std::shared_ptr<frame> i) noexcept
@@ -55,7 +54,7 @@
ft2 = i;
}
- void frame::setParent(std::shared_ptr<frame> i) noexcept
+ void frame::setParent(frame *i) noexcept
{
parent = i;
i->addChild(getptr());
@@ -81,7 +80,7 @@
return mom;
}
- std::shared_ptr<frame> frame::getParent() const noexcept
+ frame* frame::getParent() const noexcept
{
return parent;
}
/src/sleek/gui/frame.h
3,6 → 3,7
 
#include "font.h"
#include "type.h"
#include "../compile.h"
#include "../driver/texture.h"
#include "../driver/material.h"
#include "../device/event.h"
35,7 → 36,7
 
virtual void setFont(std::shared_ptr<font>) noexcept;
virtual void setVisible(bool) noexcept;
virtual void setParent(std::shared_ptr<frame>) noexcept;
virtual void setParent(frame*) noexcept;
virtual void setText(std::string) noexcept;
virtual void setTextSize(u32) noexcept;
virtual void setTextColor(const math::pixel&) noexcept;
46,7 → 47,7
virtual math::aabbox2di& getBoundingBox() noexcept;
virtual math::vector2di getScale() const noexcept;
virtual const std::string& getText() const noexcept;
virtual std::shared_ptr<frame> getParent() const noexcept;
virtual frame* getParent() const noexcept;
virtual std::shared_ptr<font> getFont() const noexcept;
virtual math::pixel getTextColor() const noexcept;
virtual u32 getTextSize() const noexcept;
57,6 → 58,8
 
virtual void move(math::vector2di) noexcept;
virtual bool manage(device::input*) noexcept;
 
void* user[gui_frame_userdata];
 
virtual void render() noexcept;
protected:
63,7 → 66,7
frame() noexcept {}
 
std::shared_ptr<font> ft2;
std::shared_ptr<frame> parent;
frame* parent;
interface *mom;
 
bool show, isActive;
/src/sleek/gui/interface.cpp
1,5 → 1,12
#include "interface.h"
#include "interface.h"
 
#include "button.h"
#include "statictext.h"
#include "progressbar.h"
#include "scrollbar.h"
#include "picture.h"
#include "window.h"
 
namespace sleek
{
namespace gui
41,6 → 48,14
return tmp;
}
 
std::shared_ptr<scrollbar> interface::addScrollbar(bool horizontal, const math::aabbox2di &pos) noexcept
{
auto tmp = std::make_shared<scrollbar>(this);
tmp->absolute = pos.upperleft;
tmp->box = pos.minimise();
return tmp;
}
 
std::shared_ptr<progressbar> interface::addProgressbar(const std::string &t, const math::aabbox2di &b) noexcept
{
auto tmp = std::make_shared<progressbar>(this);
/src/sleek/gui/interface.h
11,6 → 11,13
{
namespace gui
{
class picture;
class scrollbar;
class progressbar;
class button;
class statictext;
class window;
 
class interface : public std::enable_shared_from_this<interface>
{
public:
24,7 → 31,8
 
std::shared_ptr<frame> addFrame(const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<picture> addPicture(driver::texture*, const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<progressbar> addProgressbar(const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<scrollbar> addScrollbar(bool horizontal, const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<progressbar> addProgressbar(const std::string &text = "%f%%", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<button> addButton(const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<statictext> addStaticText(const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
std::shared_ptr<window> addWindow(const std::string &text = "", const math::aabbox2di &pos = math::aabbox2di()) noexcept;
/src/sleek/gui/picture.cpp
23,13 → 23,20
bool picture::manage(device::input *e) noexcept
{
bool CHovored = isHovored;
if(frame::manage(e)) { return false; }
if(e->type == device::EVENT_MOUSSE_MOVED) isHovored = box.intersect(e->mouse_pos);
 
if(frame::manage(e))
return true;
 
if(e->type == device::EVENT_MOUSSE_MOVED)
isHovored = box.intersect(e->mouse_pos);
 
if(CHovored != isHovored)
{
e->gui.called = this;
if(isHovored) { e->gui.code = gui::IET_PICTURE_HOVORED; return true; }
else { e->gui.code = gui::IET_PICTURE_FOCUSED; return true; }
e->gui.code = isHovored ?
gui::IET_PICTURE_HOVORED :
gui::IET_PICTURE_FOCUSED;
return true;
}
}
 
/src/sleek/gui/progressbar.cpp
60,20 → 60,30
bool progressbar::manage(device::input *e) noexcept
{
bool CHovored = isHovored;
if(frame::manage(e)) { return false; }
if(e->type == device::EVENT_MOUSSE_MOVED) isHovored = box.intersect(e->mouse_pos);
 
if(frame::manage(e))
return true;
 
if(e->type == device::EVENT_MOUSSE_MOVED)
isHovored = box.intersect(e->mouse_pos);
 
if(CHovored != isHovored)
{
e->gui.called = this;
if(isHovored) { e->gui.code = gui::IET_PROGRESSBAR_HOVORED; return true; }
else { e->gui.code = gui::IET_PROGRESSBAR_FOCUSED; return true; }
e->gui.code = isHovored ?
gui::IET_PROGRESSBAR_HOVORED :
gui::IET_PROGRESSBAR_FOCUSED;
return true;
}
 
if(per != lst)
{
e->gui.called = this;
e->gui.code = gui::IET_PROGRESSBAR_UPDATED;
return false;
return true;
}
 
return false;
}
 
void progressbar::render() noexcept
/src/sleek/gui/scrollbar.cpp
0,0 → 1,132
#include "interface.h"
#include "scrollbar.h"
 
#include "../math/function.h"
 
namespace sleek
{
namespace gui
{
scrollbar::scrollbar(interface *m) noexcept : frame(m)
{
min = 0;
max = 100;
per = 0.f;
orient = SBO_HORIZONTAL;
isLeftDown = false;
}
 
scrollbar::~scrollbar() noexcept
{
}
 
void scrollbar::setValue(const s32 i) noexcept
{
per = math::clamp(i, min, max)/(max-min);
}
 
void scrollbar::setMin(const s32 i) noexcept
{
min = i;
}
 
void scrollbar::setMax(const s32 i) noexcept
{
max = i;
}
 
void scrollbar::setOrientation(SCROLL_BAR_ORIANTATION i)
{
orient = i;
}
 
SCROLL_BAR_ORIANTATION scrollbar::getOrientation()
{
return orient;
}
 
void scrollbar::setPercentage(const f32 i) noexcept
{
per = i;
}
 
f32 scrollbar::getPercentage() const noexcept
{
return per;
}
 
s32 scrollbar::getMin() const noexcept
{
return min;
}
 
s32 scrollbar::getMax() const noexcept
{
return max;
}
 
s32 scrollbar::getValue() const noexcept
{
return min + (max-min)*per;
}
 
bool scrollbar::manage(device::input *e) noexcept
{
bool CHovored = isHovored;
 
if(frame::manage(e))
return true;
 
if(e->type == device::EVENT_MOUSSE_MOVED)
isHovored = box.intersect(e->mouse_pos);
 
if(e->type == device::EVENT_MOUSSE_DOWN)
isLeftDown = isHovored;
 
if(e->type == device::EVENT_MOUSSE_UP)
isLeftDown = false;
 
if(CHovored != isHovored)
{
e->gui.called = this;
e->gui.code = isHovored ?
gui::IET_SCROLLBAR_HOVORED :
gui::IET_SCROLLBAR_FOCUSED;
return true;
}
 
if(isLeftDown)
{
auto pos = e->mouse_pos;
 
if(orient == SBO_HORIZONTAL)
{
per = math::clamp(pos.x, box.upperleft.x, box.lowerright.x);
per -= box.upperleft.x;
per /= float(box.getSize().x);
}
else
{
per = math::clamp(pos.y, box.upperleft.y, box.lowerright.y);
per -= box.upperleft.y;
per /= float(box.getSize().y);
}
 
std::cout << std::to_string(per) << std::endl;
 
e->gui.called = this;
e->gui.code = gui::IET_SCROLLBAR_UPDATED;
return true;
}
 
return false;
}
 
void scrollbar::render() noexcept
{
if(!show) return;
mom->getTheme()->drawScrollbar(this);
renderChild();
}
}
}
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/gui/scrollbar.h
===================================================================
--- src/sleek/gui/scrollbar.h (nonexistent)
+++ src/sleek/gui/scrollbar.h (revision 13)
@@ -0,0 +1,50 @@
+#ifndef GUI_SCROLLBAR
+#define GUI_SCROLLBAR
+
+#include "frame.h"
+
+namespace sleek
+{
+ namespace gui
+ {
+ enum SCROLL_BAR_ORIANTATION
+ {
+ SBO_VERTICAL,
+ SBO_HORIZONTAL,
+ SBO_COUNT
+ };
+
+ class scrollbar : public frame
+ {
+ public:
+ scrollbar(interface*) noexcept;
+ ~scrollbar() noexcept;
+
+ virtual INTERFACE_GUI_CODE getType() const noexcept { return IGT_SCROLLBAR; }
+
+ virtual void setOrientation(SCROLL_BAR_ORIANTATION);
+ virtual SCROLL_BAR_ORIANTATION getOrientation();
+
+ virtual void setValue(const s32) noexcept;
+ virtual void setMin(const s32) noexcept;
+ virtual void setMax(const s32) noexcept;
+ virtual void setPercentage(const f32) noexcept;
+
+ virtual f32 getPercentage() const noexcept;
+ virtual s32 getMin() const noexcept;
+ virtual s32 getMax() const noexcept;
+ virtual s32 getValue() const noexcept;
+
+ virtual bool manage(device::input*) noexcept;
+
+ virtual void render() noexcept;
+ private:
+ s32 min, max;
+ f32 per;
+ SCROLL_BAR_ORIANTATION orient;
+ bool isHovored, isLeftDown;
+ };
+ }
+}
+
+#endif
/src/sleek/gui/scrollbar.h
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/gui/statictext.cpp
===================================================================
--- src/sleek/gui/statictext.cpp (revision 12)
+++ src/sleek/gui/statictext.cpp (revision 13)
@@ -39,14 +39,23 @@
bool statictext::manage(device::input *e) noexcept
{
bool CHovored = isHovored;
- if(frame::manage(e)) { return false; }
- if(e->type == device::EVENT_MOUSSE_MOVED) isHovored = box.intersect(e->mouse_pos);
+
+ if(frame::manage(e))
+ return true;
+
+ if(e->type == device::EVENT_MOUSSE_MOVED)
+ isHovored = box.intersect(e->mouse_pos);
+
if(CHovored != isHovored)
{
e->gui.called = this;
- if(isHovored) { e->gui.code = gui::IET_STATICTEXT_HOVORED; return true; }
- else { e->gui.code = gui::IET_STATICTEXT_FOCUSED; return true; }
+ e->gui.code = isHovored ?
+ gui::IET_STATICTEXT_HOVORED :
+ gui::IET_STATICTEXT_FOCUSED;
+ return true;
}
+
+ return false;
}
void statictext::render() noexcept
/src/sleek/gui/theme.cpp
2,6 → 2,15
#include "../driver/driver.h"
#include "theme.h"
 
#include "button.h"
#include "font.h"
#include "picture.h"
#include "progressbar.h"
#include "statictext.h"
#include "window.h"
#include "scrollbar.h"
 
 
namespace sleek
{
namespace gui
9,14 → 18,23
theme::theme(interface *i) noexcept : mom(i)
{
solid.setMode(driver::rmd_quad);
solid.setFaceCulling(driver::rfc_back);
solid.setAntialiasing(driver::ral_polygone);
solid.setMaterialRender(driver::rmt_solid);
 
line.setMode(driver::rmd_line_loop);
line.setFaceCulling(driver::rfc_back);
line.setAntialiasing(driver::ral_line);
line.setMaterialRender(driver::rmt_solid);
 
color[0] = math::pixel(25,25,25,128);
color[1] = math::pixel(128,255,255,255);
color[2] = math::pixel(25,25,25,100);
color[3] = math::pixel(25,25,25,200);
color[4] = math::pixel(128,25,25,128);
color[5] = math::pixel(0,0,255,255);
color[6] = math::pixel(25,25,25,150);
color[7] = math::pixel(0,255,0,255);
color[8] = math::pixel(25,128,255,128);
color[9] = math::pixel(25,25,25,255);
color[10] = math::pixel(255, 255, 255,255);
color[11] = math::pixel(0, 0, 0,255);
}
 
theme::~theme() noexcept
32,8 → 50,8
void theme::drawWindowMain(window *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(25,25,25,200)) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(25,25,25,100));
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[3]) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[2]);
}
 
void theme::drawWindowMainHovored(window *i) noexcept
44,14 → 62,14
void theme::drawWindowMainMoved(window *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(25,25,25,150));
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[6]);
}
 
void theme::drawWindowDecoration(window *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&line);
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(0,255,0,255)) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(128,255,255,255));
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[7]) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[1]);
 
// title s├ęparator
 
62,8 → 80,8
b.y = a.y;
b.x -= 1;
 
i->isActive ? mom->getDrawManager()->drawLine(a, b, math::pixel(0,255,0,255)) :
mom->getDrawManager()->drawLine(a, b, math::pixel(128,255,255,255));
i->isActive ? mom->getDrawManager()->drawLine(a, b, color[7]) :
mom->getDrawManager()->drawLine(a, b, color[1]);
}
 
void theme::drawWindowDecorationHovored(window *i) noexcept
91,33 → 109,33
void theme::drawButton(button *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(25,25,25,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[0]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(128,255,255,255));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[1]);
}
 
void theme::drawButtonPushed(button *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(128,25,25,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[4]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(25,25,25,255));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[9]);
}
 
void theme::drawButtonHovored(button *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(25,128,255,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[8]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(0,0,255,255));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[5]);
}
 
void theme::drawStaticText(statictext *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(0,0,0), math::pixel(25,25,25,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(0,0,0), color[0]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(0,0,0), math::pixel(128,255,255,255));
mom->getDrawManager()->drawCube(i->box, math::vector3df(0,0,0), color[1]);
drawFont(i);
}
 
124,19 → 142,55
void theme::drawProgressbar(progressbar *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(25,25,25,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[0]);
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(128,25,25,128));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[4]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), math::pixel(128,255,255,255));
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[1]);
}
 
void theme::drawScrollbar(scrollbar *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[0]);
 
if(i->getOrientation() == SBO_HORIZONTAL)
{
math::vector2di start, end;
start.x = i->getBoundingBox().upperleft.x + 1;
start.x += (i->getBoundingBox().getSize().x-2) * i->getPercentage();
start.y = i->getBoundingBox().upperleft.y;
end.x = start.x;
end.y = i->getBoundingBox().lowerright.y;
 
mom->getDrawManager()->drawLine({start.x-1, start.y}, {end.x-1, end.y}, color[10]);
mom->getDrawManager()->drawLine(start, end, color[11]);
mom->getDrawManager()->drawLine({start.x+1, start.y}, {end.x+1, end.y}, color[10]);
}
else
{
math::vector2di start, end;
start.x = i->getBoundingBox().upperleft.x;
start.y = i->getBoundingBox().upperleft.y+1;
start.y += (i->getBoundingBox().getSize().y-2) * i->getPercentage();
end.x = i->getBoundingBox().lowerright.x;
end.y = start.y;
 
mom->getDrawManager()->drawLine({start.x, start.y-1}, {end.x, end.y-1}, color[10]);
mom->getDrawManager()->drawLine(start, end, color[11]);
mom->getDrawManager()->drawLine({start.x, start.y+1}, {end.x, end.y+1}, color[10]);
}
 
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[1]);
}
 
void theme::drawFrame(frame *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(25,25,25,128));
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, math::pixel(128,255,255,255));
mom->getDrawManager()->setActiveMaterial(&solid);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[6]);
mom->getDrawManager()->setActiveMaterial(&line);
mom->getDrawManager()->drawCube(i->box, math::vector3df(), color[1]);
}
}
}
/src/sleek/gui/theme.h
1,13 → 1,6
#ifndef GUI_THEME
#define GUI_THEME
#define GUI_THEME
 
#include "button.h"
#include "font.h"
#include "picture.h"
#include "progressbar.h"
#include "statictext.h"
#include "window.h"
 
#include "../driver/driver.h"
#include "../driver/material.h"
 
14,7 → 7,15
namespace sleek
{
namespace gui
{
{
class button;
class font;
class picture;
class progressbar;
class statictext;
class window;
class scrollbar;
 
class theme : public std::enable_shared_from_this<theme>
{
public:
44,12 → 45,14
virtual void drawButtonPushed(button*) noexcept;
virtual void drawButtonHovored(button*) noexcept;
virtual void drawStaticText(statictext*) noexcept;
virtual void drawProgressbar(progressbar*) noexcept;
virtual void drawProgressbar(progressbar*) noexcept;
virtual void drawScrollbar(scrollbar*) noexcept;
virtual void drawFrame(frame*) noexcept;
protected:
interface *mom;
driver::texture *decor[IGT_COUNT*3];
driver::material solid, line;
driver::material solid, line;
math::pixel color[50];
};
}
}
/src/sleek/gui/type.h
14,6 → 14,8
IGT_EDITBOX,
IGT_FRAME,
IGT_PICTURE,
IGT_COLORPICKER,
IGT_SCROLLBAR,
IGT_PROGRESSBAR,
IGT_STATICTEXT,
IGT_WINDOW,
52,7 → 54,17
/** picture event **/
IET_PICTURE_FOCUSED,
IET_PICTURE_HOVORED,
/** progressbar event **/
IET_COLORPICKER_CLOSED,
IET_COLORPICKER_FOCUSED,
IET_COLORPICKER_HOVORED,
IET_COLORPICKER_UPDATED,
IET_COLORPICKER_SELECTED,
/** progressbar event **/
IET_SCROLLBAR_FOCUSED,
IET_SCROLLBAR_HOVORED,
IET_SCROLLBAR_UPDATED,
/** progressbar event **/
IET_PROGRESSBAR_FOCUSED,
IET_PROGRESSBAR_HOVORED,
IET_PROGRESSBAR_UPDATED,
/src/sleek/gui/window.cpp
13,7 → 13,7
close = new button(m);
close->box = math::aabbox2di(math::vector2di(0,0),math::vector2di(10,10));
close->relative = math::vector2di(box.getSize().x-15, 5);
close->parent = getptr();
close->setParent(this);
close->UpdateAbsolutePosition();
close->setText("Close");
}
70,7 → 70,7
}
 
if(frame::manage(e))
return false;
return true;
 
math::aabbox2di til(
box.getUpperLeft(),
82,10 → 82,13
 
if(e->type == device::EVENT_MOUSSE_DOWN && e->mouse[device::MOUSE_LEFT] && til.intersect(e->mouse_pos))
isMoved = true;
 
if(e->type == device::EVENT_MOUSSE_DOWN && e->mouse[device::MOUSE_LEFT] && box.intersect(e->mouse_pos))
mom->popFrame(getptr());
 
if(e->type == device::EVENT_MOUSSE_UP)
isMoved = false;
 
if(e->type == device::EVENT_MOUSSE_MOVED)
{
if(!isMoved)
/src/sleek/math/pixel.cpp
1,4 → 1,5
#include "pixel.h"
#include "../math/function.h"
 
namespace sleek
{
26,6 → 27,14
 
/* ***************************************** */
 
void pixel::set(const u8 r, const u8 g, const u8 b,const u8 a) noexcept
{
red = r;
green = g;
blue = b;
alpha = a;
}
 
void pixel::setRed(const u8 i) noexcept
{
red = i;
68,6 → 77,19
return alpha;
}
 
pixel pixel::getInterpolated(const pixel &other, f32 d) const
{
d = math::clamp(d, 0.f, 1.f);
const f32 inv = 1.0f - d;
 
return {
u8(other.red *inv + red *d),
u8(other.green*inv + green*d),
u8(other.blue *inv + blue *d),
u8(other.alpha*inv + alpha*d)
};
}
 
u8 pixel::getLuminaissance() const noexcept
{
return (red+green+blue)/3;
/src/sleek/math/pixel.h
11,9 → 11,11
{
public:
pixel(const u32 = 0xFFFFFFFF) noexcept;
pixel(const u8,const u8,const u8,const u8 a = 255) noexcept;
pixel(const u8 r, const u8 g, const u8 b,const u8 a = 255) noexcept;
virtual ~pixel() noexcept;
 
virtual void set(const u8 r, const u8 g, const u8 b,const u8 a = 255) noexcept;
 
virtual void setRed(const u8) noexcept;
virtual void setGreen(const u8) noexcept;
virtual void setBlue(const u8) noexcept;
24,6 → 26,8
virtual u8 getBlue() const noexcept;
virtual u8 getAlpha() const noexcept;
 
virtual pixel getInterpolated(const pixel &other, f32 d) const;
 
virtual pixel monochrome() const noexcept;
virtual pixel monochrome_with_alpha() const noexcept;
virtual u8 getLuminaissance() const noexcept;