diff --git a/src/placeholder_ctrl.h b/src/placeholder_ctrl.h deleted file mode 100644 index 9e4bd37211..0000000000 --- a/src/placeholder_ctrl.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2012, Thomas Goyne -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// Aegisub Project http://www.aegisub.org/ - -#include - -// Defined in osx_utils.mm -void SetPlaceholderText(wxWindow *window, wxString const& placeholder); - -/// @class Placeholder -/// @brief A wrapper around a control to add placeholder text -/// -/// This control wraps a base control to add default greyed-out placeholder -/// text describing the control when the value would otherwise be empty, which -/// is removed when the control is focused to begin typing in it, and restored -/// when the control loses focus and the value is empty -template -class Placeholder final : public BaseCtrl { - wxString placeholder; ///< Placeholder string - bool is_placeholder; ///< Should the value be cleared on focus? - - /// Wrapper around Create to make it possible to override it for specific - /// base classes - inline void Create(wxWindow *parent, wxSize const& size, long style) { - BaseCtrl::Create(parent, -1, placeholder, wxDefaultPosition, size, style); - } - -#ifndef __WXOSX__ - /// Focus gained event handler - void OnSetFocus(wxFocusEvent& evt) { - evt.Skip(); - - if (is_placeholder) { - BaseCtrl::ChangeValue(""); - BaseCtrl::SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - } - } - - /// Focus lost event handler - void OnKillFocus(wxFocusEvent& evt) { - evt.Skip(); - ChangeValue(BaseCtrl::GetValue()); - } - -public: - /// Constructor - /// @param parent Parent window - /// @param placeholder Placeholder string - /// @param size Control size - /// @param style Style flags to pass to the base control - /// @param tooltip Tooltip string - Placeholder(wxWindow *parent, wxString const& placeholder, wxSize const& size, long style, wxString const& tooltip) - : placeholder(placeholder) - , is_placeholder(true) - { - Create(parent, size, style); - BaseCtrl::SetToolTip(tooltip); - BaseCtrl::SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); - - BaseCtrl::Bind(wxEVT_SET_FOCUS, &Placeholder::OnSetFocus, this); - BaseCtrl::Bind(wxEVT_KILL_FOCUS, &Placeholder::OnKillFocus, this); - } - - /// @brief Change the value of the control without triggering events - /// @param new_value New value of the control - /// - /// If new_value is empty, the control will switch to placeholder mode - void ChangeValue(wxString new_value) { - if (new_value.empty() && !this->HasFocus()) { - is_placeholder = true; - new_value = placeholder; - BaseCtrl::SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); - } - else { - is_placeholder = false; - BaseCtrl::SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - } - - // This check should be pointless, but wxGTK is awesome and generates - // change events in wxComboBox::ChangeValue - if (new_value != BaseCtrl::GetValue()) - BaseCtrl::ChangeValue(new_value); - } - - /// Override GetValue to return empty when in placeholder mode rather than the placeholder text - wxString GetValue() const { - if (is_placeholder && !this->HasFocus()) - return ""; - return BaseCtrl::GetValue(); - } -#else -public: - Placeholder(wxWindow *parent, wxString const& placeholder, wxSize const& size, long style, wxString const& tooltip) - : placeholder(placeholder) - { - Create(parent, size, style); - BaseCtrl::SetToolTip(tooltip); - SetPlaceholderText(this, placeholder); - } -#endif -}; - -template<> inline void Placeholder::Create(wxWindow *parent, wxSize const& size, long style) { - wxComboBox::Create(parent, -1, "", wxDefaultPosition, size, 0, nullptr, style); -} diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 9c4bb1f49d..d6bdbcbc30 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -45,7 +45,6 @@ #include "include/aegisub/hotkey.h" #include "initial_line_state.h" #include "options.h" -#include "placeholder_ctrl.h" #include "project.h" #include "retina_helper.h" #include "selection_controller.h" @@ -135,12 +134,16 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) }); top_sizer->Add(style_edit_button, wxSizerFlags().Center().Border(wxRIGHT)); - actor_box = new Placeholder(this, _("Actor"), wxSize(110, -1), wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Actor name for this speech. This is only for reference, and is mainly useless.")); + actor_box = new wxComboBox(this, -1, _("Actor"), wxDefaultPosition, wxSize(110, -1), 0, nullptr, wxCB_DROPDOWN | wxTE_PROCESS_ENTER); + actor_box->SetToolTip(_("Actor name for this speech. This is only for reference, and is mainly useless.")); + actor_box->SetHint(_("Actor")); Bind(wxEVT_TEXT, &SubsEditBox::OnActorChange, this, actor_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnActorChange, this, actor_box->GetId()); top_sizer->Add(actor_box, wxSizerFlags(2).Center().Border(wxRIGHT)); - effect_box = new Placeholder(this, _("Effect"), wxSize(80,-1), wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); + effect_box = new wxComboBox(this, -1, _("Effect"), wxDefaultPosition, wxSize(80, -1), 0, nullptr, wxCB_DROPDOWN | wxTE_PROCESS_ENTER); + effect_box->SetToolTip(_("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); + effect_box->SetHint(_("Effect")); Bind(wxEVT_TEXT, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); top_sizer->Add(effect_box, 3, wxALIGN_CENTER, 5); diff --git a/src/subs_edit_box.h b/src/subs_edit_box.h index 0443adbdcc..7e63a98d57 100644 --- a/src/subs_edit_box.h +++ b/src/subs_edit_box.h @@ -56,8 +56,6 @@ class wxStyledTextEvent; class wxTextCtrl; struct AssDialogueBase; -template class Placeholder; - /// @brief Main subtitle edit box /// /// Controls the text edit and all surrounding controls @@ -87,13 +85,13 @@ class SubsEditBox final : public wxPanel { wxCheckBox *comment_box; wxComboBox *style_box; wxButton *style_edit_button; - Placeholder *actor_box; + wxComboBox *actor_box; TimeEdit *start_time; TimeEdit *end_time; TimeEdit *duration; wxSpinCtrl *layer; std::array margin; - Placeholder *effect_box; + wxComboBox *effect_box; wxRadioButton *by_time; wxRadioButton *by_frame; wxTextCtrl *char_count; @@ -156,8 +154,6 @@ class SubsEditBox final : public wxPanel { void OnSize(wxSizeEvent &event); void OnSplit(wxCommandEvent&); - void SetPlaceholderCtrl(wxControl *ctrl, wxString const& value); - /// @brief Set a field in each selected line to a specified value /// @param set Callable which updates a passed line /// @param desc Undo description to use