Added Paste Over function, which allows you to paste subtitle lines over others, overwriting the fields of your choice.

Originally committed to SVN as r566.
This commit is contained in:
Rodrigo Braz Monteiro 2006-12-17 19:41:52 +00:00
parent c5e479875f
commit a5105d2552
5 changed files with 259 additions and 3 deletions

View File

@ -28,6 +28,7 @@ Please visit http://aegisub.net to download latest version
- Fixed line selection after pasting. (AMZ)
- Times can now be copy and pasted with ctrl+c and ctrl+v, as well as from context menu, in the time edit boxes. (AMZ)
- Plain-text lines can now be pasted into the grid. They will be inserted as default lines with the text as their content. (AMZ)
- Added Paste Over function, which allows you to paste subtitle lines over others, overwriting the fields of your choice. (AMZ)
= 1.10 beta - 2006.08.07 ===========================

172
core/dialog_paste_over.cpp Normal file
View File

@ -0,0 +1,172 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
///////////
// Headers
#include <wx/config.h>
#include "dialog_paste_over.h"
#include "options.h"
///////////////
// Constructor
DialogPasteOver::DialogPasteOver (wxWindow *parent)
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
{
// List box
wxArrayString choices;
choices.Add(_T("Layer"));
choices.Add(_T("Start Time"));
choices.Add(_T("End Time"));
choices.Add(_T("Style"));
choices.Add(_T("Actor"));
choices.Add(_T("Margin Left"));
choices.Add(_T("Margin Right"));
choices.Add(_T("Margin Vertical"));
choices.Add(_T("Effect"));
choices.Add(_T("Text"));
ListBox = new wxCheckListBox(this,-1,wxDefaultPosition,wxSize(250,170), choices);
// Load checked items
for (int i=0;i<10;i++) ListBox->Check(i,Options.AsBool(wxString::Format(_T("Paste Over #%i"),i)));
// Label and list sizer
wxStaticText *label = new wxStaticText(this,-1,_("Please select the fields that you want to paste over::"),wxDefaultPosition,wxDefaultSize);
wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Fields"));
ListSizer->Add(label,0,wxEXPAND,0);
ListSizer->Add(ListBox,0,wxEXPAND|wxTOP,5);
// Top buttons
wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL);
TopButtonSizer->Add(new wxButton(this, Paste_Over_All, _T("All")),1,0,0);
TopButtonSizer->Add(new wxButton(this, Paste_Over_None, _T("None")),1,0,0);
TopButtonSizer->Add(new wxButton(this, Paste_Over_Times, _T("Times")),1,0,0);
TopButtonSizer->Add(new wxButton(this, Paste_Over_Text, _T("Text")),1,0,0);
// Buttons
wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
ButtonSizer->AddStretchSpacer(1);
ButtonSizer->Add(new wxButton(this, wxID_OK),0,0,0);
ButtonSizer->Add(new wxButton(this, wxID_CANCEL),0,0,0);
// Main sizer
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5);
MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5);
MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5);
SetSizer(MainSizer);
MainSizer->SetSizeHints(this);
Center();
}
//////////////
// Destructor
DialogPasteOver::~DialogPasteOver() {
}
///////////////
// Event table
BEGIN_EVENT_TABLE(DialogPasteOver, wxDialog)
EVT_BUTTON(wxID_OK,DialogPasteOver::OnOK)
EVT_BUTTON(wxID_CANCEL,DialogPasteOver::OnCancel)
EVT_BUTTON(Paste_Over_All,DialogPasteOver::OnAll)
EVT_BUTTON(Paste_Over_None,DialogPasteOver::OnNone)
EVT_BUTTON(Paste_Over_Text,DialogPasteOver::OnText)
EVT_BUTTON(Paste_Over_Times,DialogPasteOver::OnTimes)
END_EVENT_TABLE()
//////////////
// OK pressed
void DialogPasteOver::OnOK(wxCommandEvent &event) {
// Set options
options.SetCount(10);
for (int i=0;i<10;i++) {
options[i] = ListBox->IsChecked(i) ? 1 : 0;
Options.SetBool(wxString::Format(_T("Paste Over #%i"),i),options[i]==1);
}
Options.Save();
// End
EndModal(1);
}
//////////////////
// Cancel pressed
void DialogPasteOver::OnCancel(wxCommandEvent &event) {
EndModal(0);
}
///////////////
// Select Text
void DialogPasteOver::OnText(wxCommandEvent &event) {
for (int i=0;i<9;i++) ListBox->Check(i,false);
ListBox->Check(9,true);
}
////////////////
// Select Times
void DialogPasteOver::OnTimes(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,false);
ListBox->Check(1,true);
ListBox->Check(2,true);
}
//////////////
// Select All
void DialogPasteOver::OnAll(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,true);
}
///////////////
// Select None
void DialogPasteOver::OnNone(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,false);
}
////////////////
// Get options
wxArrayInt DialogPasteOver::GetOptions() {
return options;
}

76
core/dialog_paste_over.h Normal file
View File

@ -0,0 +1,76 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
///////////
// Headers
#include <wx/wxprec.h>
//////////////////////////////////
// File associations dialog class
class DialogPasteOver : public wxDialog {
private:
wxCheckListBox *ListBox;
wxArrayInt options;
void OnOK(wxCommandEvent &event);
void OnCancel(wxCommandEvent &event);
void OnTimes(wxCommandEvent &event);
void OnText(wxCommandEvent &event);
void OnAll(wxCommandEvent &event);
void OnNone(wxCommandEvent &event);
public:
DialogPasteOver(wxWindow *parent);
~DialogPasteOver();
wxArrayInt GetOptions();
DECLARE_EVENT_TABLE()
};
///////
// IDs
enum {
Paste_Over_Times = 1620,
Paste_Over_Text,
Paste_Over_All,
Paste_Over_None
};

View File

@ -159,6 +159,9 @@ void OptionsManager::LoadDefaults() {
SetBool(_T("Highlight subs in frame"),true);
for (int i=0;i<9;i++) SetBool(wxString::Format(_T("Paste Over #%i"),i),false);
SetBool(_T("Paste Over #9"),true);
SetText(_T("Fonts Collector Destination"),_T("?script"));
SetBool(_T("Threaded Video"),false);

View File

@ -52,6 +52,7 @@
#include "hotkeys.h"
#include "utils.h"
#include "ass_override.h"
#include "dialog_paste_over.h"
///////////////
@ -889,9 +890,12 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
// Get list of options to paste over, if not asked yet
if (asked == false) {
asked = true;
// TODO: Replace this with dialog
for (int i=0;i<10;i++) pasteOverOptions.Add(0);
pasteOverOptions[9] = 1;
DialogPasteOver diag(NULL);
if (!diag.ShowModal()) {
delete curdiag;
return;
}
pasteOverOptions = diag.GetOptions();
}
// Paste over