update timeline layout and frame counter, add 500ms update timer on windows to force redraw, fix animation frames export

This commit is contained in:
2018-03-10 18:28:41 +01:00
parent f45a7c2e67
commit 660a7ea1ef
4 changed files with 29 additions and 30 deletions

View File

@@ -649,7 +649,6 @@
<button id="btn-open" width="50" height="100%" margin="0 5 0 0" text="Open"/>
<button id="btn-save" width="50" height="100%" margin="0 5 0 0" text="Save"/>
<button id="btn-export" width="50" height="100%" margin="0 5 0 0" text="Export"/>
<button id="btn-anim" width="50" height="100%" margin="0 5 0 0" text="Anim"/>
<button id="btn-clear" width="50" height="100%" margin="0 5 0 15" text="Clear"/>
-->
<button-custom id="menu-file" width="50" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
@@ -666,6 +665,8 @@
<button-custom id="menu-about" width="60" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
<text text="About" font-face="arial" font-size="11"/>
</button-custom>
<button id="btn-anim" width="70" height="100%" margin="1 0 0 10" text="Animate"/>
<node dir="row" justify="center" grow="1">
<button id="btn-pen" width="50" height="100%" margin="0 0 0 0" text="Pen"/>
<button id="btn-pick" width="50" height="100%" margin="0 0 0 0" text="Pick"/>
@@ -724,9 +725,11 @@
</scroll>
</node>
<!-- timeline -->
<node height="100%" width="1" grow="1" dir="col" justify="flex-end">
<border color=".3 .3 .3 .4" height="50" width="100%" pad="10">
<slider-h id="frames-slider"></slider-h>
<node height="100%" width="1" grow="1" dir="col" justify="flex-start">
<border color=".3 .3 .3 .4" height="50" width="100%" pad="10" dir="row">
<text text="Timeline: " font-face="arial" font-size="11" margin="8 10 0 0"/>
<slider-h id="frames-slider" width="1" grow="1" margin="0 10 0 0"></slider-h>
<text id="timeline-frame" text="00" font-face="arial" font-size="30" margin="5 10 0 10"/>
</border>
</node>
</node>

View File

@@ -580,7 +580,8 @@ void App::initLayout()
if (auto* slider = layout[main_id]->find<NodeSliderH>("frames-slider"))
{
slider->on_value_changed = [this](Node*, float value)
auto frame_text = layout[main_id]->find<NodeText>("timeline-frame");
slider->on_value_changed = [this, frame_text](Node*, float value)
{
auto& c = *ui::Canvas::I;
@@ -590,7 +591,7 @@ void App::initLayout()
layers->handle_layer_opacity(l, .0f);
}
int current_layer = (int)floor(value * c.m_layers.size());
int current_layer = (int)std::min<int>(floor(value * c.m_layers.size()), c.m_layers.size() - 1);
auto l = layers->get_layer_at(current_layer);
layers->handle_layer_selected(l);
layers->handle_layer_opacity(l, 1.f);
@@ -599,8 +600,17 @@ void App::initLayout()
auto l = layers->get_layer_at(current_layer - 1);
layers->handle_layer_opacity(l, .25f);
}
if (frame_text)
{
char str[16];
snprintf(str, sizeof(str), "%02d", current_layer);
frame_text->set_text(str);
}
};
}
App::I.redraw = true;
};
LOG("initializing layout xml");
if (layout.m_loaded)

View File

@@ -1123,7 +1123,7 @@ void ui::Canvas::export_anim(std::string data_path)
// prepare common states
glViewport(0, 0, m_width, m_height);
glDisable(GL_BLEND);
glEnable(GL_BLEND);
RTT m_latlong;
m_latlong.create(m_width * 4, m_height * 2); // NOTE: w and h must be equal to make sense
@@ -1153,29 +1153,18 @@ void ui::Canvas::export_anim(std::string data_path)
ui::ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
m_plane.draw_fill();
// copy to tmp2 for layer blending
glActiveTexture(GL_TEXTURE0); // TODO: maybe remove this line
m_tex2[i].bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height);
m_tex2[i].unbind();
m_layers[layer_index].m_rtt[i].bindTexture();
glActiveTexture(GL_TEXTURE1);
m_tex2[i].bind();
m_sampler.bind(0);
m_sampler_bg.bind(1);
glActiveTexture(GL_TEXTURE0);
ShaderManager::use(ui::kShader::TextureAlpha);
ShaderManager::u_int(kShaderUniform::TexBG, 1);
ShaderManager::u_float(kShaderUniform::Alpha, 1);
ShaderManager::u_int(kShaderUniform::Highlight, false);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
m_sampler_mask.bind(0);
m_layers[layer_index].m_rtt[i].bindTexture();
m_plane.draw_fill();
m_sampler.unbind();
m_sampler_bg.unbind();
m_tex2[i].unbind();
glActiveTexture(GL_TEXTURE0);
m_layers[layer_index].m_rtt[i].unbindTexture();
m_sampler_mask.unbind();
// copy result to cubemap
glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);
@@ -1183,13 +1172,6 @@ void ui::Canvas::export_anim(std::string data_path)
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
m_tmp[i].unbindFramebuffer();
// m_layers[layer_index].m_rtt[i].bindFramebuffer();
// // copy result to cubemap
// glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);
// glCopyTexImage2D(faces[i], 0, GL_RGBA8, 0, 0, m_width, m_height, 0);
// glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
// m_layers[layer_index].m_rtt[i].unbindFramebuffer();
}
glViewport(0, 0, m_latlong.getWidth(), m_latlong.getHeight());

View File

@@ -379,6 +379,10 @@ int main(int argc, char** argv)
SendMessage(hWnd, WM_SETICON, ICON_SMALL,
(LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON1)));
SetTimer(hWnd, 1, 500, [](HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
App::I.redraw = true;
});
MSG msg;
bool running = true;
unsigned long t0 = GetTickCount();