~ubuntu-branches/ubuntu/wily/aegisub/wily-proposed

« back to all changes in this revision

Viewing changes to src/command/keyframe.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel, Pascal De Vuyst, Juan Picca, Sebastian Reichel
  • Date: 2015-08-04 21:40:50 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150804214050-y2aghm9vdksoc8t7
Tags: 3.2.2+dfsg-1
[ Pascal De Vuyst ]
* Fix Typo in package description (Closes: #739219)

[ Juan Picca ]
* Add patch to fix reproducible build (Closes: #789728)

[ Sebastian Reichel ]
* New upstream release
 - remove vendor directory from orig tarball
* Update Debian Standards Version to 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
//
30
30
// Aegisub Project http://www.aegisub.org/
31
31
 
32
 
#include "../config.h"
33
 
 
34
32
#include "command.h"
35
33
 
36
34
#include "../include/aegisub/context.h"
 
35
#include "../libresrc/libresrc.h"
37
36
#include "../options.h"
 
37
#include "../project.h"
38
38
#include "../utils.h"
39
 
#include "../video_context.h"
40
39
 
41
 
#include <libaegisub/util.h>
 
40
#include <libaegisub/keyframe.h>
 
41
#include <libaegisub/make_unique.h>
42
42
 
43
43
namespace {
44
44
        using cmd::Command;
45
45
 
46
 
struct keyframe_close : public Command {
 
46
struct keyframe_close final : public Command {
47
47
        CMD_NAME("keyframe/close")
 
48
        CMD_ICON(close_keyframes_menu)
48
49
        STR_MENU("Close Keyframes")
49
50
        STR_DISP("Close Keyframes")
50
51
        STR_HELP("Discard the currently loaded keyframes and use those from the video, if any")
51
52
        CMD_TYPE(COMMAND_VALIDATE)
52
53
 
53
54
        bool Validate(const agi::Context *c) override {
54
 
                return c->videoController->OverKeyFramesLoaded();
 
55
                return c->project->CanCloseKeyframes();
55
56
        }
56
57
 
57
58
        void operator()(agi::Context *c) override {
58
 
                c->videoController->CloseKeyframes();
 
59
                c->project->CloseKeyframes();
59
60
        }
60
61
};
61
62
 
62
 
struct keyframe_open : public Command {
 
63
struct keyframe_open final : public Command {
63
64
        CMD_NAME("keyframe/open")
 
65
        CMD_ICON(open_keyframes_menu)
64
66
        STR_MENU("Open Keyframes...")
65
67
        STR_DISP("Open Keyframes")
66
68
        STR_HELP("Open a keyframe list file")
73
75
                        c->parent);
74
76
 
75
77
                if (!filename.empty())
76
 
                        c->videoController->LoadKeyframes(filename);
 
78
                        c->project->LoadKeyframes(filename);
77
79
        }
78
80
};
79
81
 
80
 
struct keyframe_save : public Command {
 
82
struct keyframe_save final : public Command {
81
83
        CMD_NAME("keyframe/save")
 
84
        CMD_ICON(save_keyframes_menu)
82
85
        STR_MENU("Save Keyframes...")
83
86
        STR_DISP("Save Keyframes")
84
87
        STR_HELP("Save the current list of keyframes to a file")
85
88
        CMD_TYPE(COMMAND_VALIDATE)
86
89
 
87
90
        bool Validate(const agi::Context *c) override {
88
 
                return c->videoController->KeyFramesLoaded();
 
91
                return !c->project->Keyframes().empty();
89
92
        }
90
93
 
91
94
        void operator()(agi::Context *c) override {
92
95
                auto filename = SaveFileSelector(_("Save keyframes file"), "Path/Last/Keyframes", "", "*.key.txt", "Text files (*.txt)|*.txt", c->parent);
93
 
                if (!filename.empty())
94
 
                        c->videoController->SaveKeyframes(filename);
 
96
                if (filename.empty()) return;
 
97
 
 
98
                agi::keyframe::Save(filename, c->project->Keyframes());
 
99
                config::mru->Add("Keyframes", filename);
95
100
        }
96
101
};
97
102
}
98
103
 
99
104
namespace cmd {
100
105
        void init_keyframe() {
101
 
                reg(agi::util::make_unique<keyframe_close>());
102
 
                reg(agi::util::make_unique<keyframe_open>());
103
 
                reg(agi::util::make_unique<keyframe_save>());
 
106
                reg(agi::make_unique<keyframe_close>());
 
107
                reg(agi::make_unique<keyframe_open>());
 
108
                reg(agi::make_unique<keyframe_save>());
104
109
        }
105
110
}