From 9f58957fd9634fdbd48a78809e6c1370f16912f9 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 16 Apr 2007 23:59:38 +0000 Subject: [PATCH] Styles editor seems totally finished, although it will probably still conflict on temporary subs filename. Originally committed to SVN as r1083. --- aegisub/dialog_style_editor.cpp | 26 +++++++++++++++++++++++--- aegisub/dialog_style_editor.h | 1 + aegisub/options.cpp | 2 +- aegisub/subs_preview.cpp | 9 +++++++-- aegisub/subs_preview.h | 2 ++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/aegisub/dialog_style_editor.cpp b/aegisub/dialog_style_editor.cpp index 92fbca258..e08a32c01 100644 --- a/aegisub/dialog_style_editor.cpp +++ b/aegisub/dialog_style_editor.cpp @@ -60,6 +60,7 @@ enum { CHECKBOX_STYLE_ITALIC, CHECKBOX_STYLE_UNDERLINE, CHECKBOX_STYLE_STRIKEOUT, + CHECKBOX_OUTLINE, BUTTON_COLOR_1, BUTTON_COLOR_2, BUTTON_COLOR_3, @@ -80,7 +81,8 @@ enum { TEXT_SCALE_Y, TEXT_ANGLE, TEXT_SPACING, - TEXT_PREVIEW + TEXT_PREVIEW, + COMBO_ENCODING }; @@ -140,12 +142,12 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit Alignment = new wxRadioBox(this, RADIO_ALIGNMENT, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS); Outline = new wxTextCtrl(this,TEXT_OUTLINE,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&OutlineValue)); Shadow = new wxTextCtrl(this,TEXT_SHADOW,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&ShadowValue)); - OutlineType = new wxCheckBox(this,-1,_("Opaque box")); + OutlineType = new wxCheckBox(this,CHECKBOX_OUTLINE,_("Opaque box")); ScaleX = new wxTextCtrl(this,TEXT_SCALE_X,_T(""),wxDefaultPosition, wxSize(70,20),0,wxTextValidator(wxFILTER_NUMERIC,&ScaleXValue)); ScaleY = new wxTextCtrl(this,TEXT_SCALE_Y,_T(""),wxDefaultPosition, wxSize(70,20),0,wxTextValidator(wxFILTER_NUMERIC,&ScaleYValue)); Angle = new wxTextCtrl(this,TEXT_ANGLE,_T(""),wxDefaultPosition, wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&AngleValue)); Spacing = new wxTextCtrl(this,TEXT_SPACING,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&SpacingValue)); - Encoding = new wxComboBox(this,-1,_T(""),wxDefaultPosition, wxDefaultSize, encodingStrings,wxCB_READONLY); + Encoding = new wxComboBox(this,COMBO_ENCODING,_T(""),wxDefaultPosition, wxDefaultSize, encodingStrings,wxCB_READONLY); SubsPreview = new SubtitlesPreview(this,-1,wxDefaultPosition,wxSize(100,60),wxSUNKEN_BORDER); PreviewText = NULL; // Yes, this IS necessary PreviewText = new wxTextCtrl(this,TEXT_PREVIEW,Options.AsText(_T("Style editor preview text"))); @@ -366,8 +368,15 @@ BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog) EVT_BUTTON(BUTTON_COLOR_2, DialogStyleEditor::OnSetColor2) EVT_BUTTON(BUTTON_COLOR_3, DialogStyleEditor::OnSetColor3) EVT_BUTTON(BUTTON_COLOR_4, DialogStyleEditor::OnSetColor4) + EVT_CHILD_FOCUS(DialogStyleEditor::OnChildFocus) EVT_TEXT(TEXT_PREVIEW, DialogStyleEditor::OnPreviewTextChange) + EVT_CHECKBOX(CHECKBOX_STYLE_BOLD, DialogStyleEditor::OnCommandPreviewUpdate) + EVT_CHECKBOX(CHECKBOX_STYLE_ITALIC, DialogStyleEditor::OnCommandPreviewUpdate) + EVT_CHECKBOX(CHECKBOX_STYLE_UNDERLINE, DialogStyleEditor::OnCommandPreviewUpdate) + EVT_CHECKBOX(CHECKBOX_STYLE_STRIKEOUT, DialogStyleEditor::OnCommandPreviewUpdate) + EVT_CHECKBOX(CHECKBOX_OUTLINE, DialogStyleEditor::OnCommandPreviewUpdate) + EVT_COMBOBOX(COMBO_ENCODING, DialogStyleEditor::OnCommandPreviewUpdate) END_EVENT_TABLE() @@ -550,6 +559,8 @@ void DialogStyleEditor::OnChooseFont (wxCommandEvent &event) { work->bold = (newfont.GetWeight() == wxFONTWEIGHT_BOLD); work->italic = (newfont.GetStyle() == wxFONTSTYLE_ITALIC); work->underline = newfont.GetUnderlined(); + UpdateWorkStyle(); + SubsPreview->SetStyle(work); // Comic sans warning if (newfont.GetFaceName() == _T("Comic Sans MS")) { @@ -594,6 +605,15 @@ void DialogStyleEditor::OnPreviewTextChange (wxCommandEvent &event) { } +/////////////////////////////////// +// Command event to update preview +void DialogStyleEditor::OnCommandPreviewUpdate (wxCommandEvent &event) { + UpdateWorkStyle(); + SubsPreview->SetStyle(work); + event.Skip(); +} + + /////////////////////////////////////// // Converts control value to alignment int DialogStyleEditor::ControlToAlign (int n) { diff --git a/aegisub/dialog_style_editor.h b/aegisub/dialog_style_editor.h index 3890b8fe9..1628fa7ec 100644 --- a/aegisub/dialog_style_editor.h +++ b/aegisub/dialog_style_editor.h @@ -118,6 +118,7 @@ private: void OnSetColor3 (wxCommandEvent &event); void OnSetColor4 (wxCommandEvent &event); void OnChildFocus (wxChildFocusEvent &event); + void OnCommandPreviewUpdate (wxCommandEvent &event); void OnPreviewTextChange (wxCommandEvent &event); public: diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 919a6ea10..e51d05534 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -343,7 +343,7 @@ void OptionsManager::LoadDefaults() { SetBool(_T("kanji timer interpolation"),true); - wxString previewText = _T("Aegisub 0123 "); + wxString previewText = _T("Aegisub\N0123 "); previewText += 0x6708; previewText += 0x8a9e; SetText(_T("Style editor preview text"),previewText); diff --git a/aegisub/subs_preview.cpp b/aegisub/subs_preview.cpp index 34a99fafc..1b6b58078 100644 --- a/aegisub/subs_preview.cpp +++ b/aegisub/subs_preview.cpp @@ -54,6 +54,7 @@ SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize si AssStyle temp; bmp = NULL; style = NULL; + vid = NULL; SetStyle(&temp); SetText(_T("preview")); SetSizeHints(size.GetWidth(),size.GetHeight(),-1,-1); @@ -65,6 +66,7 @@ SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize si SubtitlesPreview::~SubtitlesPreview() { delete bmp; delete style; + delete vid; } @@ -129,8 +131,9 @@ void SubtitlesPreview::UpdateBitmap(int w,int h) { } // Get AegiVideoFrame - DummyVideoProvider vid(0.0,10,w,h,wxColour(125,153,176),true); - AegiVideoFrame frame = vid.GetFrame(0); + if (!vid) vid = new DummyVideoProvider(0.0,10,w,h,wxColour(125,153,176),true); + AegiVideoFrame frame; + frame.CopyFrom(vid->GetFrame(0)); // Generate subtitles AssFile *subs = new AssFile(); @@ -179,5 +182,7 @@ void SubtitlesPreview::OnPaint(wxPaintEvent &event) { ////////////// // Size event void SubtitlesPreview::OnSize(wxSizeEvent &event) { + delete vid; + vid = NULL; UpdateBitmap(event.GetSize().GetWidth(),event.GetSize().GetHeight()); } diff --git a/aegisub/subs_preview.h b/aegisub/subs_preview.h index efb1a1475..46827b34d 100644 --- a/aegisub/subs_preview.h +++ b/aegisub/subs_preview.h @@ -45,6 +45,7 @@ ////////////// // Prototypes class AssStyle; +class VideoProvider; ///////////////////////// @@ -54,6 +55,7 @@ private: wxBitmap *bmp; AssStyle *style; wxString showText; + VideoProvider *vid; void UpdateBitmap(int w=-1,int h=-1); void OnSize(wxSizeEvent &event);