added asset loading class, zoom factor, vbo switch, shader version

This commit is contained in:
2017-03-13 01:16:20 +00:00
parent a2a221b17a
commit ee6d352fc6
25 changed files with 345 additions and 108 deletions

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "layout.h"
#include "util.h"
#include "asset.h"
Plane NodeBorder::m_plane;
Plane NodeImage::m_plane;
@@ -11,11 +12,19 @@ kEventResult Node::on_event(Event* e)
{
kEventResult ret = kEventResult::Available;
for (auto it = m_children.rbegin(); it != m_children.rend(); ++it)
{
if ((*it)->on_event(e) == kEventResult::Consumed)
{
if (m_flood_events)
{
ret = kEventResult::Consumed;
}
else
{
return kEventResult::Consumed;
}
}
}
if (ret == kEventResult::Consumed)
return ret;
switch (e->m_cat)
@@ -51,6 +60,8 @@ kEventResult Node::on_event(Event* e)
handle_event(&e2);
}
break;
default:
break;
}
break;
}
@@ -80,12 +91,13 @@ void Node::remove_child(Node* n)
}
}
void Node::update(float width, float height)
void Node::update(float width, float height, float zoom)
{
YGNodeStyleSetWidth(y_node, width);
YGNodeStyleSetHeight(y_node, height);
m_zoom = zoom;
YGNodeStyleSetWidth(y_node, width / zoom);
YGNodeStyleSetHeight(y_node, height / zoom);
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
m_proj = glm::ortho(0.f, width, height, 0.f, -1.f, 1.f);
m_proj = glm::ortho(0.f, width / zoom, height / zoom, 0.f, -1.f, 1.f);
update_internal({ 0, 0 }, m_proj);
}
@@ -462,18 +474,25 @@ void Node::clone_children(Node* dest) const
bool LayoutManager::load(const char* path)
{
#ifndef __ANDROID__
struct stat tmp_info;
if (stat(path, &tmp_info) != 0)
return false;
if (tmp_info.st_mtime <= m_file_info.st_mtime)
return false;
m_file_info = tmp_info;
#endif // __ANDROID__
m_path = path;
auto old = std::move(m_layouts);
Asset file;
if (!(file.open(path) && file.read_all()))
return false;
tinyxml2::XMLDocument xml;
auto ret = xml.LoadFile(path);
auto ret = xml.Parse((char*)file.m_data, file.m_len);
file.close();
if (ret != tinyxml2::XMLError::XML_SUCCESS)
return false;