[ttssh2-commit] [10028] theme editorで入力した設定をすぐに反映できるようにした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 6月 27日 (月) 01:14:30 JST


Revision: 10028
          https://osdn.net/projects/ttssh2/scm/svn/commits/10028
Author:   zmatsuo
Date:     2022-06-27 01:14:29 +0900 (Mon, 27 Jun 2022)
Log Message:
-----------
theme editorで入力した設定をすぐに反映できるようにした

- [set]ボタン追加

Modified Paths:
--------------
    branches/theme/teraterm/common/tt_res.h
    branches/theme/teraterm/teraterm/ttermpro.rc
    branches/theme/teraterm/teraterm/vtdisp.c
    branches/theme/teraterm/teraterm/vtdisp.h
    branches/theme/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: branches/theme/teraterm/common/tt_res.h
===================================================================
--- branches/theme/teraterm/common/tt_res.h	2022-06-26 16:14:19 UTC (rev 10027)
+++ branches/theme/teraterm/common/tt_res.h	2022-06-26 16:14:29 UTC (rev 10028)
@@ -252,6 +252,7 @@
 #define IDC_BUTTON1                     2612
 #define IDC_BUTTON2                     2613
 #define IDC_BUTTON3                     2614
+#define IDC_BUTTON4                     2615
 #define IDC_COMBO1                      2616
 #define IDC_STATIC_HELP                 2617
 #define ID_ACC_SENDBREAK                50001

Modified: branches/theme/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/theme/teraterm/teraterm/ttermpro.rc	2022-06-26 16:14:19 UTC (rev 10027)
+++ branches/theme/teraterm/teraterm/ttermpro.rc	2022-06-26 16:14:29 UTC (rev 10028)
@@ -377,6 +377,7 @@
     LTEXT           "base",IDC_STATIC,22,58,16,8
     COMBOBOX        IDC_COMBO1,37,146,107,45,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
     LTEXT           "static text",IDC_STATIC_HELP,135,34,176,82
+    PUSHBUTTON      "Set",IDC_BUTTON4,78,53,50,14
 END
 
 

Modified: branches/theme/teraterm/teraterm/vtdisp.c
===================================================================
--- branches/theme/teraterm/teraterm/vtdisp.c	2022-06-26 16:14:19 UTC (rev 10027)
+++ branches/theme/teraterm/teraterm/vtdisp.c	2022-06-26 16:14:29 UTC (rev 10028)
@@ -1244,6 +1244,11 @@
 
   CopyRect(&BGPrevRect,&rect);
 
+  //\x95ǎ\x86 or \x94w\x8Ci\x82\xF0\x83v\x83\x8A\x83\x8D\x81[\x83h
+  BGPreloadSrc(&BGDest);
+  BGPreloadSrc(&BGSrc1);
+  BGPreloadSrc(&BGSrc2);
+
   #ifdef _DEBUG
     OutputDebugPrintf("BGSetupPrimary : BGInSizeMove = %d\n",BGInSizeMove);
   #endif
@@ -1608,40 +1613,40 @@
 		GetTempFileNameA(tempPath, "ttAK", 0, BGSrc2.fileTmp);
 	}
 
+	// AlphaBlend \x82̃A\x83h\x83\x8C\x83X\x82\xF0\x93ǂݍ\x9E\x82\xDD
+	if (ts.EtermLookfeel.BGUseAlphaBlendAPI) {
+		if (pAlphaBlend != NULL)
+			BGAlphaBlend = pAlphaBlend;
+		else
+			BGAlphaBlend = AlphaBlendWithoutAPI;
+	}
+	else {
+		BGAlphaBlend = AlphaBlendWithoutAPI;
+	}
+
+	BGLoadThemeFile(&ts);
+}
+
+void BGLoadThemeFile(TTTSet *pts)
+{
 	//\x90ݒ\xE8\x82̓ǂݏo\x82\xB5
-	BGReadIniFile(ts.SetupFNameW);
+	BGReadIniFile(pts->SetupFNameW);
 
 	// \x83R\x83\x93\x83t\x83B\x83O\x83t\x83@\x83C\x83\x8B(\x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B)\x82̌\x88\x92\xE8
-	if (ts.EtermLookfeel.BGEnable == 1 && ts.EtermLookfeel.BGThemeFileW != NULL) {
+	if (pts->EtermLookfeel.BGEnable == 1 && pts->EtermLookfeel.BGThemeFileW != NULL) {
 		// \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82̎w\x92肪\x82\xA0\x82\xE9
-		BGReadIniFile(ts.EtermLookfeel.BGThemeFileW);
+		BGReadIniFile(pts->EtermLookfeel.BGThemeFileW);
 	}
 	else {
 		// \x83\x89\x83\x93\x83_\x83\x80\x83e\x81[\x83} (or \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82\xF0\x8Ew\x92肪\x82Ȃ\xA2)
 		wchar_t *theme_mask;
 		wchar_t *theme_file;
-		aswprintf(&theme_mask, L"%s\\theme\\*.ini", ts.HomeDirW);
+		aswprintf(&theme_mask, L"%s\\theme\\*.ini", pts->HomeDirW);
 		theme_file = RandomFileW(theme_mask);
 		free(theme_mask);
 		BGReadIniFile(theme_file);
 		free(theme_file);
 	}
-
-	//\x95ǎ\x86 or \x94w\x8Ci\x82\xF0\x83v\x83\x8A\x83\x8D\x81[\x83h
-	BGPreloadSrc(&BGDest);
-	BGPreloadSrc(&BGSrc1);
-	BGPreloadSrc(&BGSrc2);
-
-	// AlphaBlend \x82̃A\x83h\x83\x8C\x83X\x82\xF0\x93ǂݍ\x9E\x82\xDD
-	if (ts.EtermLookfeel.BGUseAlphaBlendAPI) {
-		if (pAlphaBlend != NULL)
-			BGAlphaBlend = pAlphaBlend;
-		else
-			BGAlphaBlend = AlphaBlendWithoutAPI;
-	}
-	else {
-		BGAlphaBlend = AlphaBlendWithoutAPI;
-	}
 }
 
 void BGExchangeColor() {
@@ -4066,7 +4071,7 @@
 	SetDlgItemTextA(hWnd, IDC_BGIMG_EDIT, BGDest.file);
 	SetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS4, BGDest.color);
 	{
-		int count = SendDlgItemMessageA(hWnd, IDC_COMBO1, CB_GETCOUNT, 0, 0);
+		LRESULT count = SendDlgItemMessageA(hWnd, IDC_COMBO1, CB_GETCOUNT, 0, 0);
 		int sel = 0;
 		int i;
 		for (i = 0; i < count; i++) {
@@ -4088,6 +4093,33 @@
 	SetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS, BGSrc2.color);
 }
 
+static void ReadFromDialog(HWND hWnd)
+{
+	LRESULT checked;
+	LRESULT index;
+	checked = SendDlgItemMessageA(hWnd, IDC_BGIMG_CHECK, BM_GETCHECK, 0, 0);
+	BGDest.type = checked & BST_CHECKED ? BG_PICTURE : BG_COLOR;
+	GetDlgItemTextA(hWnd, IDC_BGIMG_EDIT, BGDest.file, sizeof(BGDest.file));
+	BGDest.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS4);
+	index = SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETCURSEL, 0, 0);
+	BGDest.pattern = (BG_PATTERN)SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETITEMDATA, index, 0);
+
+	checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE, BM_GETCHECK, 0, 0);
+	if (checked & BST_CHECKED) {
+		BGSrc1.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS3, NULL, FALSE);
+	} else {
+		BGSrc1.alpha = 0;
+	}
+
+	checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE2, BM_GETCHECK, 0, 0);
+	if (checked & BST_CHECKED) {
+		BGSrc2.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS, NULL, FALSE);
+	} else {
+		BGSrc2.alpha = 0;
+	}
+	BGSrc2.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS);
+}
+
 static INT_PTR CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 {
 	static const DlgTextInfo TextInfos[] = {
@@ -4129,7 +4161,7 @@
 				);
 
 			for (i = 0;; i++) {
-				int index;
+				LRESULT index;
 				const BG_PATTERN_ST *st = GetBGPatternList(i);
 				if (st == NULL) {
 					break;
@@ -4161,7 +4193,7 @@
 		case WM_COMMAND: {
 			switch (wp) {
 			case IDC_BUTTON1 | (BN_CLICKED << 16): {
-				// \x8Dēǂݍ\x9E\x82\xDD
+				// \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x93ǂݍ\x9E\x82\xDD
 				wchar_t *theme_file;
 				hGetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, &theme_file);
 				free(ts->EtermLookfeel.BGThemeFileW);
@@ -4199,36 +4231,16 @@
 				break;
 			}
 			case IDC_BUTTON3 | (BN_CLICKED << 16): {
-				// \x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x82\xA9\x82\xE7\x93ǂݏo\x82\xB5
+				// \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x8F\x91\x82\xAB\x8Fo\x82\xB5
 				wchar_t *theme_file_in;
 				wchar_t theme_file[MAX_PATH];
 				OPENFILENAMEW ofn = {0};
-				{
-					LRESULT checked;
-					int index;
-					checked = SendDlgItemMessageA(hWnd, IDC_BGIMG_CHECK, BM_GETCHECK, 0, 0);
-					BGDest.type = checked & BST_CHECKED ? BG_PICTURE : BG_COLOR;
-					GetDlgItemTextA(hWnd, IDC_BGIMG_EDIT, BGDest.file, sizeof(BGDest.file));
-					BGDest.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS4);
-					index = SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETCURSEL, 0, 0);
-					BGDest.pattern = (BG_PATTERN)SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETITEMDATA, index, 0);
 
-					checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE, BM_GETCHECK, 0, 0);
-					if (checked & BST_CHECKED) {
-						BGSrc1.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS3, NULL, FALSE);
-					} else {
-						BGSrc1.alpha = 0;
-					}
+				// \x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x82\xA9\x82\xE7\x93ǂݏo\x82\xB5
+				ReadFromDialog(hWnd);
+				BGSetupPrimary(TRUE);
+				InvalidateRect(HVTWin, NULL, FALSE);
 
-					checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE2, BM_GETCHECK, 0, 0);
-					if (checked & BST_CHECKED) {
-						BGSrc2.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS2, NULL, FALSE);
-					} else {
-						BGSrc2.alpha = 0;
-					}
-					BGSrc2.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS);
-				}
-
 				hGetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, &theme_file_in);
 				wcscpy_s(theme_file, _countof(theme_file), theme_file_in);
 				free(theme_file_in);
@@ -4246,9 +4258,26 @@
 
 				if (GetSaveFileNameW(&ofn)) {
 					BGWriteIniFile(theme_file);
+					SetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, theme_file);
+					free(ts->EtermLookfeel.BGThemeFileW);
+					ts->EtermLookfeel.BGThemeFileW = _wcsdup(theme_file);
+				} else {
+					// \x8F\x91\x82\xAB\x8Fo\x82\xB5\x83L\x83\x83\x83\x93\x83Z\x83\x8B/\x8E\xB8\x94s
+					SetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, NULL);
 				}
 				break;
 			}
+			case IDC_BUTTON4 | (BN_CLICKED << 16): {
+				// \x90ݒ\xE8
+				ReadFromDialog(hWnd);
+//				BGLoadThemeFile(ts);
+				BGSetupPrimary(TRUE);
+				InvalidateRect(HVTWin, NULL, FALSE);
+				SetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, NULL);
+				free(ts->EtermLookfeel.BGThemeFileW);
+				ts->EtermLookfeel.BGThemeFileW = NULL;
+				break;
+			}
 			default:
 				break;
 			}

Modified: branches/theme/teraterm/teraterm/vtdisp.h
===================================================================
--- branches/theme/teraterm/teraterm/vtdisp.h	2022-06-26 16:14:19 UTC (rev 10027)
+++ branches/theme/teraterm/teraterm/vtdisp.h	2022-06-26 16:14:29 UTC (rev 10028)
@@ -38,7 +38,8 @@
 /* prototypes */
 //<!--by AKASI
 void BGInitialize(BOOL initialize_once);
-void BGSetupPrimary(BOOL);
+void BGLoadThemeFile(TTTSet *pts);
+void BGSetupPrimary(BOOL forceSetup);
 void BGWriteThemeFile(const wchar_t *theme_file);
 
 void BGExchangeColor(void);

Modified: branches/theme/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/theme/teraterm/teraterm/vtwin.cpp	2022-06-26 16:14:19 UTC (rev 10027)
+++ branches/theme/teraterm/teraterm/vtwin.cpp	2022-06-26 16:14:29 UTC (rev 10028)
@@ -4222,7 +4222,10 @@
 	INT_PTR ret = CAddSetting.DoModal();
 	if (ret == IDOK) {
 #ifdef ALPHABLEND_TYPE2
-		BGInitialize(FALSE);
+		if (ts.EtermLookfeel.BGThemeFileW != NULL && ts.EtermLookfeel.BGThemeFileW[0] != 0) {
+			// \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82\xF0\x93ǂݍ\x9E\x82\xDE
+			BGLoadThemeFile(&ts);
+		}
 		BGSetupPrimary(TRUE);
 #else
 		DispApplyANSIColor();


ttssh2-commit メーリングリストの案内
Back to archive index