Skip to content

Commit

Permalink
Add setting to allow repositioning of SSA/ASS dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
madshi authored and Cyberbeing committed Sep 24, 2018
1 parent 7851b67 commit 1b6f195
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/filters/transform/vsfilter/DirectVobSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ CDirectVobSub::CDirectVobSub( const Option *options, CCritSec * pLock )

m_xy_int_opt[INT_SELECTED_LANGUAGE] = 0;
m_xy_bool_opt[BOOL_HIDE_SUBTITLES] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0);
m_xy_bool_opt[BOOL_ALLOW_MOVING] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), 0);
m_xy_bool_opt[BOOL_PRE_BUFFERING] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), 1);

m_xy_int_opt[INT_COLOR_SPACE] = GetCompatibleProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), YuvMatrix_AUTO);
Expand Down Expand Up @@ -1309,6 +1310,7 @@ STDMETHODIMP CDirectVobSub::UpdateRegistry()
CAutoLock cAutoLock(m_propsLock);

theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_xy_bool_opt[BOOL_HIDE_SUBTITLES]);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), m_xy_bool_opt[BOOL_ALLOW_MOVING]);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), m_xy_bool_opt[BOOL_PRE_BUFFERING]);

theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_YUV_RANGE), m_xy_int_opt[INT_YUV_RANGE]);
Expand Down Expand Up @@ -1450,6 +1452,7 @@ CDVS4XySubFilter::CDVS4XySubFilter( const Option *options, CCritSec * pLock )

m_xy_int_opt [INT_SELECTED_LANGUAGE] = 0;
m_xy_bool_opt[BOOL_HIDE_SUBTITLES ] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0);
m_xy_bool_opt[BOOL_ALLOW_MOVING ] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), 0);


CString str_color_space = theApp.GetProfileString(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), _T("AUTO"));
Expand Down Expand Up @@ -1680,6 +1683,7 @@ STDMETHODIMP CDVS4XySubFilter::UpdateRegistry()
CAutoLock cAutoLock(m_propsLock);

theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_xy_bool_opt[BOOL_HIDE_SUBTITLES]);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), m_xy_bool_opt[BOOL_ALLOW_MOVING]);

CString str_color_space;
switch(m_xy_int_opt[INT_YUV_RANGE])
Expand Down
10 changes: 5 additions & 5 deletions src/filters/transform/vsfilter/DirectVobSub.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ class DirectVobSubImpl : public IDirectVobSub2, public XyOptionsImpl, public IFi

STDMETHODIMP get_FileName(WCHAR* fn);
STDMETHODIMP put_FileName(WCHAR* fn);
STDMETHODIMP get_LanguageCount(int* nLangs);
STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
STDMETHODIMP get_SelectedLanguage(int* iSelected);
STDMETHODIMP put_SelectedLanguage(int iSelected);
STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles);
STDMETHODIMP get_LanguageCount(int* nLangs);
STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
STDMETHODIMP get_SelectedLanguage(int* iSelected);
STDMETHODIMP put_SelectedLanguage(int iSelected);
STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles);
STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
STDMETHODIMP get_PreBuffering(bool* fDoPreBuffering);
STDMETHODIMP put_PreBuffering(bool fDoPreBuffering);
Expand Down
7 changes: 7 additions & 0 deletions src/filters/transform/vsfilter/DirectVobSubPropPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ CXySubFilterMorePPage::CXySubFilterMorePPage(LPUNKNOWN pUnk, HRESULT* phr)
BindControl(IDC_SPIN_LAYOUT_SIZE_X, m_layout_size_x);
BindControl(IDC_SPIN_LAYOUT_SIZE_Y, m_layout_size_y);

BindControl(IDC_CHECKBOX_ALLOW_MOVING, m_allowmoving);
BindControl(IDC_HIDE, m_hidesub);
BindControl(IDC_AUTORELOAD, m_autoreload);
BindControl(IDC_INSTANTUPDATE, m_instupd);
Expand Down Expand Up @@ -2027,6 +2028,8 @@ void CXySubFilterMorePPage::UpdateObjectData(bool fSave)
hr = m_pDirectVobSubXy->XySetSize(DirectVobSubXyOptions::SIZE_USER_SPECIFIED_LAYOUT_SIZE, m_layout_size);
CHECK_N_LOG(hr, "Failed to set option");
hr = m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
CHECK_N_LOG(hr, "Failed to set option");
hr = m_pDirectVobSubXy->XySetBool(DirectVobSubXyOptions::BOOL_ALLOW_MOVING, m_fAllowMoving);
CHECK_N_LOG(hr, "Failed to set option");
hr = m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
CHECK_N_LOG(hr, "Failed to set option");
Expand Down Expand Up @@ -2063,6 +2066,8 @@ void CXySubFilterMorePPage::UpdateObjectData(bool fSave)
CHECK_N_LOG(hr, "Failed to get option");
hr = m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
CHECK_N_LOG(hr, "Failed to get option");
hr = m_pDirectVobSubXy->XyGetBool(DirectVobSubXyOptions::BOOL_ALLOW_MOVING, &m_fAllowMoving);
CHECK_N_LOG(hr, "Failed to get option");
hr = m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled);
CHECK_N_LOG(hr, "Failed to get option");

Expand Down Expand Up @@ -2118,6 +2123,7 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave)
m_layout_size.cy = m_layout_size_y.GetPos32();

m_fHideSubtitles = !!m_hidesub.GetCheck();
m_fAllowMoving = !!m_allowmoving.GetCheck();
m_fReloaderDisabled = !m_autoreload.GetCheck();


Expand Down Expand Up @@ -2215,6 +2221,7 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave)
m_layout_size_y.SetPos32(m_layout_size.cy);

m_hidesub.SetCheck(m_fHideSubtitles);
m_allowmoving.SetCheck(m_fAllowMoving);
m_autoreload.SetCheck(!m_fReloaderDisabled);
m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1));

Expand Down
4 changes: 2 additions & 2 deletions src/filters/transform/vsfilter/DirectVobSubPropPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ class CXySubFilterMorePPage : public CDVSBasePPage
int m_yuv_matrix, m_yuv_range, m_rgb_level;
SIZE m_layout_size;

bool m_fHideSubtitles, m_fReloaderDisabled;
bool m_fHideSubtitles, m_fAllowMoving, m_fReloaderDisabled;
bool m_render_to_original_video_size;

int m_cache_size, m_auto_cache_size;

CButton m_hidesub, m_autoreload, m_instupd;
CButton m_hidesub, m_allowmoving, m_autoreload, m_instupd;

CSpinButtonCtrl m_path_cache, m_scanline_cache, m_overlay_no_blur_cache, m_overlay_cache;

Expand Down
4 changes: 4 additions & 0 deletions src/filters/transform/vsfilter/IDirectVobSubXy.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ namespace DirectVobSubXyOptions
void_ShowConfigDialog,
void_AdviseSubClock,

BOOL_ALLOW_MOVING,

OPTION_COUNT
};
struct ColorSpaceOpt
Expand Down Expand Up @@ -242,6 +244,7 @@ namespace DirectVobSubXyOptions
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_TRAY_ICON},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_SUBTITLES},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_ALLOW_MOVING},

{XyOptionsImpl::OPTION_TYPE_SIZE , XyOptionsImpl::OPTION_MODE_READ, SIZE_ORIGINAL_VIDEO},
{XyOptionsImpl::OPTION_TYPE_SIZE , XyOptionsImpl::OPTION_MODE_READ, SIZE_ASS_PLAY_RESOLUTION},
Expand Down Expand Up @@ -331,6 +334,7 @@ namespace DirectVobSubXyOptions

{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_TRAY_ICON},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_SUBTITLES},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_ALLOW_MOVING},

{XyOptionsImpl::OPTION_TYPE_INT , XyOptionsImpl::OPTION_MODE_RW, INT_MAX_BITMAP_COUNT},
{XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_COMBINE_BITMAPS},
Expand Down
4 changes: 3 additions & 1 deletion src/filters/transform/vsfilter/VSFilter.rc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ BEGIN
CONTROL "Force Default",IDC_CHECKBOX_FORCE_DEFAULT_STYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,107,55,12
END

IDD_XY_SUB_FILTER_MOREPAGE DIALOGEX 0, 0, 247, 282
IDD_XY_SUB_FILTER_MOREPAGE DIALOGEX 0, 0, 247, 297
STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
FONT 8, "MS Sans Serif", 400, 0, 0x1
BEGIN
Expand Down Expand Up @@ -454,6 +454,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,212,224,10
LTEXT " (reloading is disabled while showing the property pages)",IDC_STATIC,25,222,182,8
CONTROL "Appl&y changes immediately",IDC_INSTANTUPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,236,104,10
CONTROL "Allow video renderer to &reposition simple SSA/ASS subtitles",IDC_CHECKBOX_ALLOW_MOVING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,251,224,10
CONTROL "Render To Original Video Size",IDC_CHECKBOX_RENDER_TO_ORIGINAL_VIDEO_SIZE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,127,132,10
EDITTEXT IDC_EDIT_CACHE_SIZE,22,72,40,14,ES_AUTOHSCROLL,WS_EX_RIGHT
Expand Down Expand Up @@ -742,6 +743,7 @@ BEGIN
IDS_RG_EMBEDDEDLOAD "emb_load"
IDS_RG_DISABLERELOADER "disable_reloader"
IDS_RG_HIDE "hide"
IDS_RG_ALLOWMOVING "allow_moving"
IDS_RG_COLOR_SPACE "color_space"
IDS_RG_BT601_WIDTH "bt_601_width_for_guess"
IDS_RG_BT601_HEIGHT "bt_601_height_for_guess"
Expand Down
2 changes: 2 additions & 0 deletions src/filters/transform/vsfilter/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
#define IDC_COLORSEC 1064
#define IDC_COLOROUTL 1065
#define IDC_COLORSHAD 1066
#define IDS_RG_ALLOWMOVING 1070
#define IDC_CHECKBOX_ALLOW_MOVING 1071

// Next default values for new objects
//
Expand Down
12 changes: 10 additions & 2 deletions src/filters/transform/vsfilter/xy_sub_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ STDMETHODIMP XySubFilter::XySetBool(unsigned field, bool value)
return XyOptionsImpl::XySetBool(field, value);
}
break;
case BOOL_ALLOW_MOVING:
{
CAutoLock cAutolock1(&m_csFilter);
CRenderedTextSubtitle * rts = dynamic_cast<CRenderedTextSubtitle*>(m_curSubStream);
if (rts)
m_xy_bool_opt[BOOL_IS_MOVABLE] = ((rts->IsMovable()) && ((rts->IsSimple()) || (value)));
}
break;
}
return DirectVobSubImpl::XySetBool(field, value);
}
Expand Down Expand Up @@ -1237,7 +1245,7 @@ STDMETHODIMP XySubFilter::RequestFrame( REFERENCE_TIME start, REFERENCE_TIME sto
if (m_xy_bool_opt[BOOL_IS_MOVABLE])
{
CRenderedTextSubtitle * rts = dynamic_cast<CRenderedTextSubtitle*>(m_curSubStream);
if ((rts) && (!rts->IsMovable()))
if ((rts) && ((!rts->IsMovable()) || ((!rts->IsSimple()) && (!m_xy_bool_opt[BOOL_ALLOW_MOVING]))))
m_xy_bool_opt[BOOL_IS_MOVABLE] = false;
}
}
Expand Down Expand Up @@ -1750,7 +1758,7 @@ void XySubFilter::SetSubtitle( ISubStream* pSubStream, bool fApplyDefStyle /*= t
pRTS->Deinit();
playres = pRTS->m_dstScreenSize;
m_xy_bool_opt[BOOL_IS_BITMAP] = false;
m_xy_bool_opt[BOOL_IS_MOVABLE] = pRTS->IsMovable();
m_xy_bool_opt[BOOL_IS_MOVABLE] = ((pRTS->IsMovable()) && ((pRTS->IsSimple()) || (m_xy_bool_opt[BOOL_ALLOW_MOVING])));
}
else if(clsid == __uuidof(HdmvSubtitleProvider) || clsid == __uuidof(SupFileSubtitleProvider))
{
Expand Down
7 changes: 6 additions & 1 deletion src/subtitles/RTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3381,7 +3381,7 @@ STDMETHODIMP CRenderedTextSubtitle::RenderEx( IXySubRenderFrame**subRenderFrame,
while ( pos!=NULL )
{
const CSubtitle2& sub2 = sub2List.GetNext(pos);
if (sub2.s->m_hard_position_level >= POS_LVL_NONE || sub2.s->m_hard_position_level == -1)
if (sub2.s->m_hard_position_level > POS_LVL_NONE)
{
m_movable = false;
break;
Expand Down Expand Up @@ -3592,6 +3592,11 @@ STDMETHODIMP_(bool) CRenderedTextSubtitle::IsMovable()
return m_movable;
}

STDMETHODIMP_(bool) CRenderedTextSubtitle::IsSimple()
{
return m_simple;
}

STDMETHODIMP CRenderedTextSubtitle::Lock()
{
return CSubPicProviderImpl::Lock();
Expand Down
1 change: 1 addition & 0 deletions src/subtitles/RTS.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ class CRenderedTextSubtitle : public CSubPicProviderImpl, public ISubStream, pub
CompositeDrawItemList* compDrawItemList /*output*/);
STDMETHODIMP_(bool) IsColorTypeSupported(int type);
STDMETHODIMP_(bool) IsMovable();
STDMETHODIMP_(bool) IsSimple();

// IPersist
STDMETHODIMP GetClassID(CLSID* pClassID);
Expand Down

0 comments on commit 1b6f195

Please sign in to comment.