From 48321dc86887e52f3d3d1e108fef2873a47a91f4 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 2 Jan 2007 22:10:45 +0000 Subject: [PATCH] Implemented ColourButton class Originally committed to SVN as r685. --- aegisub/ass_dialogue.cpp | 8 ---- aegisub/ass_dialogue.h | 2 - aegisub/base_grid.h | 2 +- aegisub/dialog_style_editor.cpp | 65 +++++++-------------------------- aegisub/dialog_style_editor.h | 6 +-- aegisub/main.cpp | 1 - aegisub/options.cpp | 34 ++++++++--------- aegisub/subs_edit_ctrl.cpp | 3 ++ 8 files changed, 36 insertions(+), 85 deletions(-) diff --git a/aegisub/ass_dialogue.cpp b/aegisub/ass_dialogue.cpp index e206a48b7..c1a49be69 100644 --- a/aegisub/ass_dialogue.cpp +++ b/aegisub/ass_dialogue.cpp @@ -213,11 +213,6 @@ bool AssDialogue::Parse(wxString rawData, bool IsSSA) { } -////////////////// -// Keep data flag -bool AssDialogue::keepData = true; - - ///////////// // Make data wxString AssDialogue::MakeData() { @@ -256,14 +251,12 @@ wxString AssDialogue::MakeData() { ////////////////////////////////// // Update AssDialogue's data line void AssDialogue::UpdateData () { - if (keepData) SetEntryData(MakeData()); } ////////////////// // Get entry data const wxString AssDialogue::GetEntryData() { - if (keepData) return AssEntry::GetEntryData(); return MakeData(); } @@ -271,7 +264,6 @@ const wxString AssDialogue::GetEntryData() { ////////////////// // Set entry data void AssDialogue::SetEntryData(wxString newData) { - if (keepData) AssEntry::SetEntryData(newData); } diff --git a/aegisub/ass_dialogue.h b/aegisub/ass_dialogue.h index 47a34830e..33e73eddf 100644 --- a/aegisub/ass_dialogue.h +++ b/aegisub/ass_dialogue.h @@ -160,8 +160,6 @@ private: wxString MakeData(); public: - static bool keepData; - std::vector Blocks; // Contains information about each block of text bool Comment; // Is this a comment line? diff --git a/aegisub/base_grid.h b/aegisub/base_grid.h index b5c491c6f..1ba85bb75 100644 --- a/aegisub/base_grid.h +++ b/aegisub/base_grid.h @@ -39,7 +39,7 @@ //////////// // Includes -#include +#include #include #include #include diff --git a/aegisub/dialog_style_editor.cpp b/aegisub/dialog_style_editor.cpp index ddc2b31e0..be918dd69 100644 --- a/aegisub/dialog_style_editor.cpp +++ b/aegisub/dialog_style_editor.cpp @@ -47,6 +47,7 @@ #include "subs_grid.h" #include "utils.h" #include "dialog_colorpicker.h" +#include "colour_button.h" /////////////// @@ -107,18 +108,14 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit ColorsSizer->Add(ColorSizer3,0,wxLEFT,5); ColorsSizer->Add(ColorSizer4,0,wxLEFT,5); ColorsSizer->AddStretchSpacer(1); - ColorButton1 = new wxBitmapButton(this,BUTTON_COLOR_1,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize); - ColorButton2 = new wxBitmapButton(this,BUTTON_COLOR_2,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize); - ColorButton3 = new wxBitmapButton(this,BUTTON_COLOR_3,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize); - ColorButton4 = new wxBitmapButton(this,BUTTON_COLOR_4,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize); - SetBitmapColor(1,style->primary.GetWXColor()); - SetBitmapColor(2,style->secondary.GetWXColor()); - SetBitmapColor(3,style->outline.GetWXColor()); - SetBitmapColor(4,style->shadow.GetWXColor()); - ColorButton1->SetToolTip(_("Click to choose color")); - ColorButton2->SetToolTip(_("Click to choose color")); - ColorButton3->SetToolTip(_("Click to choose color")); - ColorButton4->SetToolTip(_("Click to choose color")); + colorButton[0] = new ColourButton(this,BUTTON_COLOR_1,wxSize(45,16),style->primary.GetWXColor()); + colorButton[1] = new ColourButton(this,BUTTON_COLOR_2,wxSize(45,16),style->secondary.GetWXColor()); + colorButton[2] = new ColourButton(this,BUTTON_COLOR_3,wxSize(45,16),style->outline.GetWXColor()); + colorButton[3] = new ColourButton(this,BUTTON_COLOR_4,wxSize(45,16),style->shadow.GetWXColor()); + colorButton[0]->SetToolTip(_("Click to choose primary color")); + colorButton[1]->SetToolTip(_("Click to choose secondary color")); + colorButton[2]->SetToolTip(_("Click to choose outline color")); + colorButton[3]->SetToolTip(_("Click to choose shadow color")); ColorAlpha1Value = wxString::Format(_T("%i"),style->primary.a); ColorAlpha1 = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&ColorAlpha1Value)); ColorAlpha2Value = wxString::Format(_T("%i"),style->secondary.a); @@ -135,10 +132,10 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit ColorSizer2->Add(new wxStaticText(this,-1,_("Secondary")),0,wxBOTTOM | wxALIGN_CENTER,5); ColorSizer3->Add(new wxStaticText(this,-1,_("Outline")),0,wxBOTTOM | wxALIGN_CENTER,5); ColorSizer4->Add(new wxStaticText(this,-1,_("Shadow")),0,wxBOTTOM | wxALIGN_CENTER,5); - ColorSizer1->Add(ColorButton1,0,wxBOTTOM | wxALIGN_CENTER,5); - ColorSizer2->Add(ColorButton2,0,wxBOTTOM | wxALIGN_CENTER,5); - ColorSizer3->Add(ColorButton3,0,wxBOTTOM | wxALIGN_CENTER,5); - ColorSizer4->Add(ColorButton4,0,wxBOTTOM | wxALIGN_CENTER,5); + ColorSizer1->Add(colorButton[0],0,wxBOTTOM | wxALIGN_CENTER,5); + ColorSizer2->Add(colorButton[1],0,wxBOTTOM | wxALIGN_CENTER,5); + ColorSizer3->Add(colorButton[2],0,wxBOTTOM | wxALIGN_CENTER,5); + ColorSizer4->Add(colorButton[3],0,wxBOTTOM | wxALIGN_CENTER,5); ColorSizer1->Add(ColorAlpha1,0,wxALIGN_CENTER,0); ColorSizer2->Add(ColorAlpha2,0,wxALIGN_CENTER,0); ColorSizer3->Add(ColorAlpha3,0,wxALIGN_CENTER,0); @@ -311,28 +308,6 @@ DialogStyleEditor::~DialogStyleEditor () { } -//////////////////////////////////////////// -// Sets the color of the bitmap of a button -void DialogStyleEditor::SetBitmapColor (int n,wxColour color) { - wxBitmapButton *but; - switch (n) { - case 1: but = ColorButton1; break; - case 2: but = ColorButton2; break; - case 3: but = ColorButton3; break; - case 4: but = ColorButton4; break; - default: return; - } - wxBitmap bmp (but->GetBitmapLabel()); - wxMemoryDC dc; - dc.SelectObject(bmp); - dc.SetPen(*wxBLACK_PEN); - wxBrush brush(color); - dc.SetBrush(brush); - dc.DrawRectangle(0,0,bmp.GetWidth(),bmp.GetHeight()); - but->SetBitmapLabel(bmp); -} - - /////////////// // Event table BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog) @@ -524,19 +499,7 @@ void DialogStyleEditor::OnSetColor (int n) { case 4: modify = &work->shadow; break; default: throw _T("Never gets here"); } - DialogColorPicker dlg(this, modify->GetWXColor()); - if (dlg.ShowModal() == wxID_OK) { - wxColour color = dlg.GetColor(); - modify->SetWXColor(color); - SetBitmapColor(n, color); - } - /* - wxColour newColor = wxGetColourFromUser(this,modify->GetWXColor()); - if (newColor.Ok()) { - modify->SetWXColor(newColor); - SetBitmapColor(n,newColor); - } - */ + modify->SetWXColor(colorButton[n-1]->GetColour()); } diff --git a/aegisub/dialog_style_editor.h b/aegisub/dialog_style_editor.h index b0eb7daa2..62037ef41 100644 --- a/aegisub/dialog_style_editor.h +++ b/aegisub/dialog_style_editor.h @@ -41,6 +41,7 @@ //////////// // Includes #include +#include "colour_button.h" ////////////// @@ -81,10 +82,7 @@ private: wxCheckBox *BoxItalic; wxCheckBox *BoxUnderline; wxCheckBox *BoxStrikeout; - wxBitmapButton *ColorButton1; - wxBitmapButton *ColorButton2; - wxBitmapButton *ColorButton3; - wxBitmapButton *ColorButton4; + ColourButton *colorButton[4]; wxTextCtrl *ColorAlpha1; wxTextCtrl *ColorAlpha2; wxTextCtrl *ColorAlpha3; diff --git a/aegisub/main.cpp b/aegisub/main.cpp index 7713677dd..5097cade4 100644 --- a/aegisub/main.cpp +++ b/aegisub/main.cpp @@ -82,7 +82,6 @@ bool AegisubApp::OnInit() { Options.SetFile(folderName + _T("/config.dat")); Options.Load(); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); - AssDialogue::keepData = Options.AsBool(_T("Keep raw dialogue data")); // Set hotkeys file Hotkeys.SetFile(folderName + _T("/hotkeys.dat")); diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 4b78e4e01..59681df80 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -92,6 +92,8 @@ void OptionsManager::LoadDefaults() { SetText(_T("Auto save path"),_T("autosave")); SetText(_T("Auto recovery path"),_T("recovered")); SetInt(_T("Autoload linked files"),2); + SetText(_T("Text actor separator"),_T(":")); + SetText(_T("Text comment starter"),_T("#")); // Dictionary SetText(_T("Dictionaries path"),_T("dictionaries")); @@ -112,11 +114,6 @@ void OptionsManager::LoadDefaults() { SetText(_T("Video resizer"),_T("BilinearResize")); // Audio Options - SetBool(_T("Audio Link"),true); - SetBool(_T("Audio Autocommit"),false); - SetBool(_T("Audio Autoscroll"),true); - SetBool(_T("Audio SSA Mode"),false); - SetBool(_T("Audio Medusa Timing Hotkeys"),false); SetBool(_T("Audio SSA Next Line on Commit"),true); SetBool(_T("Audio SSA Allow Autocommit"),false); SetBool(_T("Audio Autofocus"),false); @@ -131,6 +128,8 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Audio Cache"),1); SetInt(_T("Audio Sample Rate"),0); SetText(_T("Audio Downmixer"),_T("ConvertToMono")); + SetText(_T("Audio HD Cache Location"),_T("default")); + SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp")); // Automation SetText(_T("Automation Base Path"), AegisubApp::folderName + _T("automation/")); @@ -139,6 +138,7 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Automation Trace Level"), 3); // Edit box cosmetic + SetBool(_T("Call Tips Enabled"),true); SetBool(_T("Syntax Highlight Enabled"),true); SetColour(_T("Syntax Highlight Normal"),wxColour(0,0,0)); SetColour(_T("Syntax Highlight Brackets"),wxColour(20,50,255)); @@ -190,6 +190,11 @@ void OptionsManager::LoadDefaults() { SetText(_T("Grid hide overrides char"),temp); SetBool(_T("Grid allow focus"),true); SetBool(_T("Highlight subs in frame"),true); +#if defined(__WINDOWS__) + SetInt(_T("Grid font size"),8); +#else + SetInt(_T("Grid font size"),10); +#endif // Audio Cosmetic SetInt(_T("Audio Spectrum Cutoff"),32); @@ -218,10 +223,14 @@ void OptionsManager::LoadDefaults() { ///// INTERNAL ////// // Options that are set by the program itself SetInt(_T("Locale Code"),-1); - SetBool(_T("Keep raw dialogue data"),false); - SetBool(_T("Sync video with subs"),true); + SetBool(_T("Audio Link"),true); + SetBool(_T("Audio Autocommit"),false); + SetBool(_T("Audio Autoscroll"),true); + SetBool(_T("Audio SSA Mode"),false); + SetBool(_T("Audio Medusa Timing Hotkeys"),false); + SetBool(_T("Shift Times ByTime"),true); SetInt(_T("Shift Times Type"),0); SetInt(_T("Shift Times Length"),0); @@ -241,12 +250,6 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Grid hide overrides"),1); for (int i=0;i<10;i++) SetBool(_T("Grid show column ") + IntegerToString(i),true); -#if defined(__WINDOWS__) - SetInt(_T("Grid font size"),8); -#else - SetInt(_T("Grid font size"),10); -#endif - for (int i=0;i<9;i++) SetBool(wxString::Format(_T("Paste Over #%i"),i),false); SetBool(_T("Paste Over #9"),true); @@ -256,8 +259,6 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Audio Display Height"),100); SetBool(_T("Audio Spectrum"),false); - SetText(_T("Audio HD Cache Location"),_T("default")); - SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp")); SetInt(_T("Timing processor key start before thres"),5); SetInt(_T("Timing processor key start after thres"),4); @@ -279,9 +280,6 @@ void OptionsManager::LoadDefaults() { SetBool(_T("Select Match dialogues"),true); SetBool(_T("Select Match comments"),false); - SetText(_T("Text actor separator"),_T(":")); - SetText(_T("Text comment starter"),_T("#")); - SetText(_T("Color Picker Recent"), _T("&H000000& &H0000FF& &H00FFFF& &H00FF00& &HFFFF00& &HFF0000& &HFF00FF& &HFFFFFF&")); SetInt(_T("Color Picker Mode"), 4); diff --git a/aegisub/subs_edit_ctrl.cpp b/aegisub/subs_edit_ctrl.cpp index 45dc5b475..a29571462 100644 --- a/aegisub/subs_edit_ctrl.cpp +++ b/aegisub/subs_edit_ctrl.cpp @@ -378,6 +378,9 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) { /////////////////// // Update call tip void SubsTextEditCtrl::UpdateCallTip() { + // Enabled? + if (!Options.AsBool(_T("Call tips enabled"))) return; + // Get position and text const unsigned int pos = GetReverseUnicodePosition(GetCurrentPos()); wxString text = GetText();