diff options
author | kasper93 <kasper93@gmail.com> | 2014-05-04 04:05:35 +0400 |
---|---|---|
committer | kasper93 <kasper93@gmail.com> | 2014-05-11 20:16:02 +0400 |
commit | 0796a6294294162f688ed3b431c5e8e7620c897a (patch) | |
tree | 432b92274759c28cb6f677e52bc73e08dba08445 /src/filters/transform | |
parent | c883a4b1a8a151c6c3bd837f0e217d9070f1db92 (diff) |
Sync code of the subtitle editor between VSFilter and MPC-HC
Diffstat (limited to 'src/filters/transform')
-rw-r--r-- | src/filters/transform/VSFilter/StyleEditorDialog.cpp | 182 | ||||
-rw-r--r-- | src/filters/transform/VSFilter/StyleEditorDialog.h | 30 | ||||
-rw-r--r-- | src/filters/transform/VSFilter/VSFilter.rc | 20 | ||||
-rw-r--r-- | src/filters/transform/VSFilter/VSFilter.vcxproj | 2 | ||||
-rw-r--r-- | src/filters/transform/VSFilter/VSFilter.vcxproj.filters | 6 |
5 files changed, 105 insertions, 135 deletions
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.cpp b/src/filters/transform/VSFilter/StyleEditorDialog.cpp index 499f808a5..bef6edfe3 100644 --- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp +++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp @@ -1,6 +1,6 @@ /*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2014 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -19,21 +19,11 @@ *
*/
-// StyleEditorDialog.cpp : implementation file
-//
-
#include "stdafx.h"
-#include <math.h>
#include <algorithm>
#include <afxdlgs.h>
#include "StyleEditorDialog.h"
-IMPLEMENT_DYNAMIC(CColorStatic, CStatic)
-
-BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
-END_MESSAGE_MAP()
-
-
// CStyleEditorDialog dialog
#pragma warning(push)
@@ -107,95 +97,22 @@ void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
}
-void CStyleEditorDialog::UpdateControlData(bool fSave)
-{
- if (fSave) {
- UpdateData();
-
- if (m_iCharset >= 0) {
- m_stss.charSet = (int)m_charset.GetItemData(m_iCharset);
- }
- m_stss.fontSpacing = m_spacing;
- m_stss.fontAngleZ = m_angle;
- m_stss.fontScaleX = m_scalex;
- m_stss.fontScaleY = m_scaley;
-
- m_stss.borderStyle = m_borderstyle;
- m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
- m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
-
- m_stss.scrAlignment = m_screenalignment + 1;
- m_stss.marginRect = m_margin;
-
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_stss.alpha[i] = 255 - m_alpha[i];
- }
- } else {
- m_font.SetWindowText(m_stss.fontName);
- m_iCharset = -1;
- for (int i = 0; i < CharSetLen; i++) {
- CString str;
- str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- m_charset.AddString(str);
- m_charset.SetItemData(i, CharSetList[i]);
- if (m_stss.charSet == CharSetList[i]) {
- m_iCharset = i;
- }
- }
- // TODO: allow floats in these edit boxes
- m_spacing = (int)m_stss.fontSpacing;
- m_spacingspin.SetRange32(-10000, 10000);
- while (m_stss.fontAngleZ < 0) {
- m_stss.fontAngleZ += 360;
- }
- m_angle = (int)fmod(m_stss.fontAngleZ, 360);
- m_anglespin.SetRange32(0, 359);
- m_scalex = (int)m_stss.fontScaleX;
- m_scalexspin.SetRange32(-10000, 10000);
- m_scaley = (int)m_stss.fontScaleY;
- m_scaleyspin.SetRange32(-10000, 10000);
-
- m_borderstyle = m_stss.borderStyle;
- m_borderwidth = (int)std::min(m_stss.outlineWidthX, m_stss.outlineWidthY);
- m_borderwidthspin.SetRange32(0, 10000);
- m_shadowdepth = (int)std::min(m_stss.shadowDepthX, m_stss.shadowDepthY);
- m_shadowdepthspin.SetRange32(0, 10000);
-
- m_screenalignment = m_stss.scrAlignment - 1;
- m_margin = m_stss.marginRect;
- m_marginleftspin.SetRange32(-10000, 10000);
- m_marginrightspin.SetRange32(-10000, 10000);
- m_margintopspin.SetRange32(-10000, 10000);
- m_marginbottomspin.SetRange32(-10000, 10000);
-
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_color[i].SetColorPtr(&m_stss.colors[i]);
- m_alpha[i] = 255 - m_stss.alpha[i];
- m_alphasliders[i].SetRange(0, 255);
- }
-
- m_linkalphasliders = FALSE;
-
- UpdateData(FALSE);
- }
-}
-
void CStyleEditorDialog::AskColor(int i)
{
CColorDialog dlg(m_stss.colors[i]);
dlg.m_cc.Flags |= CC_FULLOPEN;
if (dlg.DoModal() == IDOK) {
m_stss.colors[i] = dlg.m_cc.rgbResult;
- m_color[i].Invalidate();
+ m_color[i].SetColor(dlg.m_cc.rgbResult);
}
}
BEGIN_MESSAGE_MAP(CStyleEditorDialog, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
- ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
- ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
- ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
+ ON_BN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
+ ON_BN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
+ ON_BN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
+ ON_BN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
ON_WM_HSCROLL()
END_MESSAGE_MAP()
@@ -205,11 +122,56 @@ END_MESSAGE_MAP() BOOL CStyleEditorDialog::OnInitDialog()
{
- CDialog::OnInitDialog();
+ __super::OnInitDialog();
SetWindowText(_T("Style Editor - \"") + m_title + _T("\""));
- UpdateControlData(false);
+ m_font.SetWindowText(m_stss.fontName);
+ m_iCharset = -1;
+ for (int i = 0; i < CharSetLen; i++) {
+ CString str;
+ str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ m_charset.AddString(str);
+ m_charset.SetItemData(i, CharSetList[i]);
+ if (m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
+ }
+ // TODO: allow floats in these edit boxes
+ m_spacing = (int)m_stss.fontSpacing;
+ m_spacingspin.SetRange32(-10000, 10000);
+ while (m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
+ m_angle = (int)fmod(m_stss.fontAngleZ, 360);
+ m_anglespin.SetRange32(0, 359);
+ m_scalex = (int)m_stss.fontScaleX;
+ m_scalexspin.SetRange32(-10000, 10000);
+ m_scaley = (int)m_stss.fontScaleY;
+ m_scaleyspin.SetRange32(-10000, 10000);
+
+ m_borderstyle = m_stss.borderStyle;
+ m_borderwidth = (int)std::min(m_stss.outlineWidthX, m_stss.outlineWidthY);
+ m_borderwidthspin.SetRange32(0, 10000);
+ m_shadowdepth = (int)std::min(m_stss.shadowDepthX, m_stss.shadowDepthY);
+ m_shadowdepthspin.SetRange32(0, 10000);
+
+ m_screenalignment = m_stss.scrAlignment - 1;
+ m_margin = m_stss.marginRect;
+ m_marginleftspin.SetRange32(-10000, 10000);
+ m_marginrightspin.SetRange32(-10000, 10000);
+ m_margintopspin.SetRange32(-10000, 10000);
+ m_marginbottomspin.SetRange32(-10000, 10000);
+
+ for (int i = 0; i < 4; i++) {
+ m_color[i].SetColor(m_stss.colors[i]);
+ m_alpha[i] = 255 - m_stss.alpha[i];
+ m_alphasliders[i].SetRange(0, 255);
+ }
+
+ m_linkalphasliders = FALSE;
+
+ UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -217,17 +179,41 @@ BOOL CStyleEditorDialog::OnInitDialog() void CStyleEditorDialog::OnOK()
{
- UpdateControlData(true);
+ UpdateData();
- CDialog::OnOK();
+ if (m_iCharset >= 0) {
+ m_stss.charSet = (int)m_charset.GetItemData(m_iCharset);
+ }
+ m_stss.fontSpacing = m_spacing;
+ m_stss.fontAngleZ = m_angle;
+ m_stss.fontScaleX = m_scalex;
+ m_stss.fontScaleY = m_scaley;
+
+ m_stss.borderStyle = m_borderstyle;
+ m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
+ m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
+
+ m_stss.scrAlignment = m_screenalignment + 1;
+ m_stss.marginRect = m_margin;
+
+ for (int i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255 - m_alpha[i];
+ }
+
+ __super::OnOK();
}
void CStyleEditorDialog::OnBnClickedButton1()
{
+ UpdateData();
+
LOGFONT lf;
lf <<= m_stss;
+ if (m_iCharset >= 0) {
+ lf.lfCharSet = (BYTE)m_charset.GetItemData(m_iCharset);
+ }
- CFontDialog dlg(&lf, CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCALABLEONLY | CF_EFFECTS);
+ CFontDialog dlg(&lf, CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCALABLEONLY);
if (dlg.DoModal() == IDOK) {
CString str(lf.lfFaceName);
if (str.GetLength() > 16) {
@@ -271,11 +257,11 @@ void CStyleEditorDialog::OnBnClickedCheck1() UpdateData();
int avg = 0;
- for (ptrdiff_t i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
avg += m_alphasliders[i].GetPos();
}
avg /= 4;
- for (ptrdiff_t i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
m_alphasliders[i].SetPos(avg);
}
}
@@ -284,10 +270,10 @@ void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollB {
if (m_linkalphasliders && pScrollBar) {
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for (ptrdiff_t i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
m_alphasliders[i].SetPos(pos);
}
}
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.h b/src/filters/transform/VSFilter/StyleEditorDialog.h index 8170f35dc..a175c7832 100644 --- a/src/filters/transform/VSFilter/StyleEditorDialog.h +++ b/src/filters/transform/VSFilter/StyleEditorDialog.h @@ -1,6 +1,6 @@ /*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2014 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -24,32 +24,9 @@ #include "resource.h"
#include <afxwin.h>
#include <afxcmn.h>
+#include "../../../mpc-hc/ColorButton.h"
#include "../../../Subtitles/STS.h"
-// CColorStatic dialog
-
-class CColorStatic : public CStatic
-{
- DECLARE_DYNAMIC(CColorStatic)
-
- COLORREF* m_pColor;
-
-public:
- CColorStatic(CWnd* pParent = nullptr) : m_pColor(nullptr) {}
- virtual ~CColorStatic() {}
-
- void SetColorPtr(COLORREF* pColor) { m_pColor = pColor; }
-
- DECLARE_MESSAGE_MAP()
-
-protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
- CRect r;
- GetClientRect(r);
- CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
- }
-};
-
// CStyleEditorDialog dialog
class CStyleEditorDialog : public CDialog
@@ -59,7 +36,6 @@ class CStyleEditorDialog : public CDialog CString m_title;
CWnd* m_pParent;
- void UpdateControlData(bool fSave);
void AskColor(int i);
public:
@@ -101,7 +77,7 @@ public: CSpinButtonCtrl m_marginrightspin;
CSpinButtonCtrl m_margintopspin;
CSpinButtonCtrl m_marginbottomspin;
- CColorStatic m_color[4];
+ CColorButton m_color[4];
int m_alpha[4];
CSliderCtrl m_alphasliders[4];
BOOL m_linkalphasliders;
diff --git a/src/filters/transform/VSFilter/VSFilter.rc b/src/filters/transform/VSFilter/VSFilter.rc index 9e4a4c19d..d1edb214c 100644 --- a/src/filters/transform/VSFilter/VSFilter.rc +++ b/src/filters/transform/VSFilter/VSFilter.rc @@ -257,23 +257,23 @@ BEGIN EDITTEXT IDC_EDIT10,268,37,34,14,ES_RIGHT | ES_AUTOHSCROLL
CONTROL "",IDC_SPIN9,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,296,37,11,14
GROUPBOX "Colors && Transparency",IDC_STATIC,125,63,187,110
+ LTEXT "0%",IDC_STATIC,198,75,12,8
+ LTEXT "100%",IDC_STATIC,288,75,20,8
LTEXT "Primary",IDC_STATIC,133,88,25,8
- CONTROL "",IDC_COLORPRI,"Static",SS_OWNERDRAW | SS_NOTIFY,175,85,16,14,WS_EX_DLGMODALFRAME
- CONTROL "",IDC_SLIDER2,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,86,103,13
+ CONTROL "",IDC_COLORPRI,"Button",BS_OWNERDRAW | WS_TABSTOP,175,85,20,14
+ CONTROL "",IDC_SLIDER2,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,86,110,13
LTEXT "Secondary",IDC_STATIC,133,105,34,8
- CONTROL "",IDC_COLORSEC,"Static",SS_OWNERDRAW | SS_NOTIFY,175,102,16,14,WS_EX_DLGMODALFRAME
- CONTROL "",IDC_SLIDER3,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,103,103,13
+ CONTROL "",IDC_COLORSEC,"Button",BS_OWNERDRAW | WS_TABSTOP,175,102,20,14
+ CONTROL "",IDC_SLIDER3,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,103,110,13
LTEXT "Outline",IDC_STATIC,133,122,24,8
- CONTROL "",IDC_COLOROUTL,"Static",SS_OWNERDRAW | SS_NOTIFY,175,119,16,14,WS_EX_DLGMODALFRAME
- CONTROL "",IDC_SLIDER5,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,120,103,13
+ CONTROL "",IDC_COLOROUTL,"Button",BS_OWNERDRAW | WS_TABSTOP,175,119,20,14
+ CONTROL "",IDC_SLIDER5,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,120,110,13
LTEXT "Shadow",IDC_STATIC,133,139,26,8
- CONTROL "",IDC_COLORSHAD,"Static",SS_OWNERDRAW | SS_NOTIFY,175,136,16,14,WS_EX_DLGMODALFRAME
- CONTROL "",IDC_SLIDER6,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,137,103,13
+ CONTROL "",IDC_COLORSHAD,"Button",BS_OWNERDRAW | WS_TABSTOP,175,136,20,14
+ CONTROL "",IDC_SLIDER6,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,198,137,110,13
CONTROL "Link alpha channels",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,213,154,76,10
PUSHBUTTON "Cancel",IDCANCEL,211,197,50,14
DEFPUSHBUTTON "OK",IDOK,265,197,50,14
- LTEXT "100%",IDC_STATIC,289,76,20,8
- LTEXT "0%",IDC_STATIC,200,76,12,8
END
diff --git a/src/filters/transform/VSFilter/VSFilter.vcxproj b/src/filters/transform/VSFilter/VSFilter.vcxproj index 380ac9d54..ff7c49aaa 100644 --- a/src/filters/transform/VSFilter/VSFilter.vcxproj +++ b/src/filters/transform/VSFilter/VSFilter.vcxproj @@ -135,6 +135,7 @@ <ItemGroup>
<ClCompile Include="AvgLines.cpp" />
<ClCompile Include="Copy.cpp" />
+ <ClCompile Include="..\..\..\mpc-hc\ColorButton.cpp" />
<ClCompile Include="csriapi.cpp" />
<ClCompile Include="DirectVobSub.cpp" />
<ClCompile Include="DirectVobSubFilter.cpp" />
@@ -160,6 +161,7 @@ <ItemGroup>
<ClInclude Include="AvgLines.h" />
<ClInclude Include="csri.h" />
+ <ClInclude Include="..\..\..\mpc-hc\ColorButton.h" />
<ClInclude Include="DirectVobSub.h" />
<ClInclude Include="DirectVobSubFilter.h" />
<ClInclude Include="DirectVobSubPropPage.h" />
diff --git a/src/filters/transform/VSFilter/VSFilter.vcxproj.filters b/src/filters/transform/VSFilter/VSFilter.vcxproj.filters index e0a95fba0..0c975605b 100644 --- a/src/filters/transform/VSFilter/VSFilter.vcxproj.filters +++ b/src/filters/transform/VSFilter/VSFilter.vcxproj.filters @@ -57,6 +57,9 @@ <ClCompile Include="VSFilter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\mpc-hc\ColorButton.cpp">
+ <Filter>Controls</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="VSFilter.def">
@@ -112,6 +115,9 @@ <ClInclude Include="resource.h">
<Filter>Resource Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\mpc-hc\ColorButton.h">
+ <Filter>Controls</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="VSFilter.rc">
|