Use generated FrameProperties widget in FramePropertiesCommand

This commit is contained in:
David Capello 2015-02-19 20:29:48 -03:00
parent adf3e6c00d
commit 4376647fcd
2 changed files with 15 additions and 16 deletions

View File

@ -1,7 +1,8 @@
<!-- ASEPRITE --> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2001-2013 by David Capello --> <!-- Aseprite -->
<!-- Copyright (C) 2001-2015 by David Capello -->
<gui> <gui>
<window text="Frame Duration" id="frame_duration"> <window text="Frame Properties" id="frame_properties">
<grid columns="3"> <grid columns="3">
<label text="Frame number:" /> <label text="Frame number:" />
<label text="" id="frame" /> <label text="" id="frame" />

View File

@ -23,6 +23,8 @@
#include "doc/sprite.h" #include "doc/sprite.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "generated_frame_properties.h"
namespace app { namespace app {
using namespace ui; using namespace ui;
@ -82,13 +84,9 @@ void FramePropertiesCommand::onExecute(Context* context)
const ContextReader reader(context); const ContextReader reader(context);
const Sprite* sprite = reader.sprite(); const Sprite* sprite = reader.sprite();
base::UniquePtr<Window> window(app::load_widget<Window>("frame_duration.xml", "frame_duration")); app::gen::FrameProperties window;
Widget* frame = app::find_widget<Widget>(window, "frame"); frame_t firstFrame = 0;
Widget* frlen = app::find_widget<Widget>(window, "frlen"); frame_t lastFrame = 0;
Widget* ok = app::find_widget<Widget>(window, "ok");
frame_t firstFrame(0);
frame_t lastFrame(0);
switch (m_target) { switch (m_target) {
@ -115,15 +113,15 @@ void FramePropertiesCommand::onExecute(Context* context)
} }
if (firstFrame != lastFrame) if (firstFrame != lastFrame)
frame->setTextf("[%d...%d]", (int)firstFrame+1, (int)lastFrame+1); window.frame()->setTextf("[%d...%d]", (int)firstFrame+1, (int)lastFrame+1);
else else
frame->setTextf("%d", (int)firstFrame+1); window.frame()->setTextf("%d", (int)firstFrame+1);
frlen->setTextf("%d", sprite->frameDuration(firstFrame)); window.frlen()->setTextf("%d", sprite->frameDuration(firstFrame));
window->openWindowInForeground(); window.openWindowInForeground();
if (window->getKiller() == ok) { if (window.getKiller() == window.ok()) {
int num = frlen->getTextInt(); int num = window.frlen()->getTextInt();
ContextWriter writer(reader); ContextWriter writer(reader);
Transaction transaction(writer.context(), "Frame Duration"); Transaction transaction(writer.context(), "Frame Duration");