Allow to set the input framerate when no document is loaded, as it may be used as...
[gn-sub.git] / src / GnomeSubtitles / Core / Command / ChangeFrameRateCommand.cs
blob3b815da1ef237dcd8359a59bb46eed6842a6ce3c
1 /*
2 * This file is part of Gnome Subtitles.
3 * Copyright (C) 2006-2010 Pedro Castro
5 * Gnome Subtitles is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * Gnome Subtitles is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 using GnomeSubtitles.Ui.View;
21 using Mono.Unix;
22 using SubLib.Core.Timing;
24 namespace GnomeSubtitles.Core.Command {
26 public abstract class ChangeFrameRateCommand : FixedMultipleSelectionCommand {
27 private float storedFrameRate = 0;
29 public ChangeFrameRateCommand (string description, float frameRate) : base(description, false, SelectionIntended.All, null, true) {
30 this.storedFrameRate = frameRate;
33 protected override bool ChangeValues () {
34 float previousFrameRate = GetFrameRate();
35 SetFrameRate(storedFrameRate);
36 storedFrameRate = previousFrameRate;
38 UpdateMenuItem();
39 return true;
42 protected abstract float GetFrameRate ();
43 protected abstract void SetFrameRate (float frameRate);
44 protected abstract void UpdateMenuItem ();
47 public class ChangeInputFrameRateCommand : ChangeFrameRateCommand {
48 private static string description = Catalog.GetString("Changing Input Frame Rate");
50 public ChangeInputFrameRateCommand (float frameRate) : base(description, frameRate) {
53 protected override float GetFrameRate () {
54 return Base.Document.Subtitles.Properties.OriginalFrameRate;
57 protected override void SetFrameRate (float frameRate) {
58 FrameRateOperator frameRateOp = new FrameRateOperator(Base.Document.Subtitles);
59 frameRateOp.ChangeOriginal(frameRate);
62 protected override void UpdateMenuItem () {
63 Base.Ui.Menus.UpdateActiveInputFrameRateMenuItem(true);
67 public class ChangeVideoFrameRateCommand : ChangeFrameRateCommand {
68 private static string description = Catalog.GetString("Changing Video Frame Rate");
70 public ChangeVideoFrameRateCommand (float frameRate) : base(description, frameRate) {
73 protected override float GetFrameRate () {
74 return Base.Document.Subtitles.Properties.CurrentFrameRate;
77 protected override void SetFrameRate (float frameRate) {
78 FrameRateOperator frameRateOp = new FrameRateOperator(Base.Document.Subtitles);
79 frameRateOp.ChangeCurrent(frameRate);
82 protected override void UpdateMenuItem () {
83 Base.Ui.Menus.UpdateActiveVideoFrameRateMenuItem();