diff --git a/aegisub/src/auto4_lua_dialog.cpp b/aegisub/src/auto4_lua_dialog.cpp index 446aed671..757ac14cf 100644 --- a/aegisub/src/auto4_lua_dialog.cpp +++ b/aegisub/src/auto4_lua_dialog.cpp @@ -246,7 +246,7 @@ namespace Automation4 { wxControl *Create(wxWindow *parent) { agi::Color colour(from_wx(text)); - wxControl *cw = new ColourButton(parent, wxSize(50*width,10*height), colour, ColorValidator(&text)); + wxControl *cw = new ColourButton(parent, wxSize(50*width,10*height), false, colour, ColorValidator(&text)); cw->SetToolTip(hint); return cw; } diff --git a/aegisub/src/colour_button.cpp b/aegisub/src/colour_button.cpp index 19bcbbe21..7483aa1d7 100644 --- a/aegisub/src/colour_button.cpp +++ b/aegisub/src/colour_button.cpp @@ -25,14 +25,14 @@ wxDEFINE_EVENT(EVT_COLOR, wxThreadEvent); -ColourButton::ColourButton(wxWindow *parent, wxSize const& size, agi::Color col, wxValidator const& validator) +ColourButton::ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi::Color col, wxValidator const& validator) : wxButton(parent, -1, "", wxDefaultPosition, wxSize(size.GetWidth() + 6, size.GetHeight() + 6), 0, validator) , bmp(size) , colour(col) { UpdateBitmap(); Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent&) { - GetColorFromUser(GetParent(), colour, [=](agi::Color new_color) { + GetColorFromUser(GetParent(), colour, alpha, [=](agi::Color new_color) { colour = new_color; UpdateBitmap(); diff --git a/aegisub/src/colour_button.h b/aegisub/src/colour_button.h index af317c9d3..559281bb5 100644 --- a/aegisub/src/colour_button.h +++ b/aegisub/src/colour_button.h @@ -35,8 +35,9 @@ public: /// Constructor /// @param parent Parent window /// @param size Size of the bitmap (note: not the size of the button) + /// @param alpha Let the user adjust the color's alpha /// @param color Initial color to display - ColourButton(wxWindow *parent, wxSize const& size, agi::Color color = agi::Color(), wxValidator const& validator = wxDefaultValidator); + ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi::Color color = agi::Color(), wxValidator const& validator = wxDefaultValidator); /// Get the currently selected color agi::Color GetColor() { return colour; } diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index 1e606857a..67f56e4b4 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -310,7 +310,7 @@ void show_color_picker(const agi::Context *c, agi::Color (AssStyle::*field), con color = get_value(blocks, blockn, color, tag, alt); int commit_id = -1; - bool ok = GetColorFromUser(c->parent, color, [&](agi::Color new_color) { + bool ok = GetColorFromUser(c->parent, color, true, [&](agi::Color new_color) { set_tag(line, blocks, tag, new_color.GetAssOverrideFormatted(), sel_start, sel_end); set_tag(line, blocks, alpha, str(boost::format("&H%02X&") % (int)new_color.a), sel_start, sel_end); commit_text(c, _("set color"), sel_start, sel_end, &commit_id); diff --git a/aegisub/src/dialog_colorpicker.cpp b/aegisub/src/dialog_colorpicker.cpp index 974f2e449..66d2210b4 100644 --- a/aegisub/src/dialog_colorpicker.cpp +++ b/aegisub/src/dialog_colorpicker.cpp @@ -514,7 +514,7 @@ class DialogColorPicker : public wxDialog { std::function callback; public: - DialogColorPicker(wxWindow *parent, agi::Color initial_color, std::function callback); + DialogColorPicker(wxWindow *parent, agi::Color initial_color, std::function callback, bool alpha); ~DialogColorPicker(); void SetColor(agi::Color new_color); @@ -532,7 +532,7 @@ static wxBitmap make_slider(Func func) { return wxBitmap(img); } -DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, std::function callback) +DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, std::function callback, bool alpha) : wxDialog(parent, -1, _("Select Color")) , callback(callback) { @@ -603,6 +603,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, spectop_sizer->Add(colorspace_choice, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT); spectop_sizer->Add(5, 5, 1, wxEXPAND); spectop_sizer->Add(preview_box, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT); + wxSizer *spectrum_sizer = new wxFlexGridSizer(3, 5, 5); spectrum_sizer->Add(spectop_sizer, wxEXPAND); spectrum_sizer->AddStretchSpacer(1); @@ -610,6 +611,9 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, spectrum_sizer->Add(spectrum); spectrum_sizer->Add(slider); spectrum_sizer->Add(alpha_slider); + if (!alpha) + spectrum_sizer->Hide(alpha_slider); + spectrum_box->Add(spectrum_sizer, 0, wxALL, 3); wxString rgb_labels[] = { _("Red:"), _("Green:"), _("Blue:") }; @@ -617,7 +621,10 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, wxString ass_labels[] = { "ASS:", "HTML:", _("Alpha:") }; wxControl *ass_ctrls[] = { ass_input, html_input, alpha_input }; - rgb_box->Add(MakeColorInputSizer(ass_labels, ass_ctrls), 0, wxALL|wxCENTER|wxEXPAND, 3); + auto ass_colors_sizer = MakeColorInputSizer(ass_labels, ass_ctrls); + if (!alpha) + ass_colors_sizer->Hide(alpha_input); + rgb_box->Add(ass_colors_sizer, 0, wxALL|wxCENTER|wxEXPAND, 3); wxString hsl_labels[] = { _("Hue:"), _("Sat.:"), _("Lum.:") }; hsl_box->Add(MakeColorInputSizer(hsl_labels, hsl_input), 0, wxALL|wxEXPAND, 3); @@ -1106,8 +1113,8 @@ void DialogColorPicker::OnCaptureLost(wxMouseCaptureLostEvent&) { } -bool GetColorFromUser(wxWindow* parent, agi::Color original, std::function callback) { - DialogColorPicker dialog(parent, original, callback); +bool GetColorFromUser(wxWindow* parent, agi::Color original, bool alpha, std::function callback) { + DialogColorPicker dialog(parent, original, callback, alpha); bool ok = dialog.ShowModal() == wxID_OK; if (!ok) callback(original); diff --git a/aegisub/src/dialog_colorpicker.h b/aegisub/src/dialog_colorpicker.h index 676eaf8e3..1ae5f4e43 100644 --- a/aegisub/src/dialog_colorpicker.h +++ b/aegisub/src/dialog_colorpicker.h @@ -28,6 +28,7 @@ class wxWindow; /// @brief Get a color from the user via a color picker dialog /// @param parent Parent window /// @param original Initial color to select +/// @param alpha Include controls for alpha /// @param callback Function called whenever the selected color changes /// @return Did the user accept the new color? -bool GetColorFromUser(wxWindow* parent, agi::Color original, std::function callback); +bool GetColorFromUser(wxWindow* parent, agi::Color original, bool alpha, std::function callback); diff --git a/aegisub/src/dialog_dummy_video.cpp b/aegisub/src/dialog_dummy_video.cpp index 75bd6c36e..151982ae4 100644 --- a/aegisub/src/dialog_dummy_video.cpp +++ b/aegisub/src/dialog_dummy_video.cpp @@ -104,7 +104,7 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent) res_sizer->Add(spin_ctrl(this, 1, 10000, &height), wxSizerFlags(1).Expand()); wxBoxSizer *color_sizer = new wxBoxSizer(wxHORIZONTAL); - ColourButton *color_btn = new ColourButton(this, wxSize(30, 17), color); + ColourButton *color_btn = new ColourButton(this, wxSize(30, 17), false, color); color_sizer->Add(color_btn, wxSizerFlags().DoubleBorder(wxRIGHT)); color_sizer->Add(new wxCheckBox(this, -1, _("Checkerboard &pattern"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&pattern)), wxSizerFlags(1).Center()); diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 569f17927..b4c38e7a5 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -191,10 +191,10 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con BoxItalic = new wxCheckBox(this, -1, _("&Italic")); BoxUnderline = new wxCheckBox(this, -1, _("&Underline")); BoxStrikeout = new wxCheckBox(this, -1, _("&Strikeout")); - colorButton[0] = new ColourButton(this, wxSize(55, 16), style->primary); - colorButton[1] = new ColourButton(this, wxSize(55, 16), style->secondary); - colorButton[2] = new ColourButton(this, wxSize(55, 16), style->outline); - colorButton[3] = new ColourButton(this, wxSize(55, 16), style->shadow); + colorButton[0] = new ColourButton(this, wxSize(55, 16), true, style->primary); + colorButton[1] = new ColourButton(this, wxSize(55, 16), true, style->secondary); + colorButton[2] = new ColourButton(this, wxSize(55, 16), true, style->outline); + colorButton[3] = new ColourButton(this, wxSize(55, 16), true, style->shadow); for (int i = 0; i < 3; i++) margin[i] = spin_ctrl(this, style->Margin[i], 9999); Alignment = new wxRadioBox(this, -1, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS); @@ -324,7 +324,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con ColourButton *previewButton = 0; if (!SubtitlesProviderFactory::GetClasses().empty()) { PreviewText = new wxTextCtrl(this, -1, to_wx(OPT_GET("Tool/Style Editor/Preview Text")->GetString())); - previewButton = new ColourButton(this, wxSize(45, 16), OPT_GET("Colour/Style Editor/Background/Preview")->GetColor()); + previewButton = new ColourButton(this, wxSize(45, 16), false, OPT_GET("Colour/Style Editor/Background/Preview")->GetColor()); SubsPreview = new SubtitlesPreview(this, wxSize(100, 60), wxSUNKEN_BORDER, OPT_GET("Colour/Style Editor/Background/Preview")->GetColor()); SubsPreview->SetToolTip(_("Preview of current style")); diff --git a/aegisub/src/preferences_base.cpp b/aegisub/src/preferences_base.cpp index 4ee0768a8..f85569894 100644 --- a/aegisub/src/preferences_base.cpp +++ b/aegisub/src/preferences_base.cpp @@ -150,7 +150,7 @@ wxControl *OptionPage::OptionAdd(wxFlexGridSizer *flex, const wxString &name, co } case agi::OptionValue::Type_Color: { - ColourButton *cb = new ColourButton(this, wxSize(40,10), opt->GetColor()); + ColourButton *cb = new ColourButton(this, wxSize(40,10), false, opt->GetColor()); cb->Bind(EVT_COLOR, ColourUpdater(opt_name, parent)); Add(flex, name, cb); return cb;