mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Tweaks.
This commit is contained in:
		| @@ -25,6 +25,9 @@ | |||||||
|  |  | ||||||
| using namespace Gdiplus; | using namespace Gdiplus; | ||||||
|  |  | ||||||
|  | #define PI	(3.14159265358979323846) | ||||||
|  | #define CONVERT_TO_DEGREES(X)	((X) * (180.0 / PI)) | ||||||
|  |  | ||||||
| extern CRainmeter* Rainmeter; | extern CRainmeter* Rainmeter; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -134,9 +137,8 @@ bool CMeterRotator::Update() | |||||||
| 	{ | 	{ | ||||||
| 		if (m_ValueRemainder > 0) | 		if (m_ValueRemainder > 0) | ||||||
| 		{ | 		{ | ||||||
| 			LARGE_INTEGER time; | 			LONGLONG time = (LONGLONG)m_Measure->GetValue(); | ||||||
| 			time.QuadPart = (LONGLONG)m_Measure->GetValue(); | 			m_Value = (double)(time % m_ValueRemainder); | ||||||
| 			m_Value = (double)(time.QuadPart % m_ValueRemainder); |  | ||||||
| 			m_Value /= (double)m_ValueRemainder; | 			m_Value /= (double)m_ValueRemainder; | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| @@ -169,9 +171,7 @@ bool CMeterRotator::Draw(Graphics& graphics) | |||||||
| 		REAL cy = (REAL)(y + m_H / 2.0); | 		REAL cy = (REAL)(y + m_H / 2.0); | ||||||
|  |  | ||||||
| 		// Calculate the rotation | 		// Calculate the rotation | ||||||
| 		REAL angle = (REAL)(m_RotationAngle * m_Value + m_StartAngle); | 		REAL angle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value + m_StartAngle)); | ||||||
|  |  | ||||||
| 		angle = angle * 180.0f / 3.14159265f;		// Convert to degrees |  | ||||||
|  |  | ||||||
| 		graphics.TranslateTransform(cx, cy); | 		graphics.TranslateTransform(cx, cy); | ||||||
| 		graphics.RotateTransform(angle); | 		graphics.RotateTransform(angle); | ||||||
|   | |||||||
| @@ -127,16 +127,21 @@ bool CMeterRoundLine::Draw(Graphics& graphics) | |||||||
| 	// Calculate the center of for the line | 	// Calculate the center of for the line | ||||||
| 	int x = GetX(); | 	int x = GetX(); | ||||||
| 	int y = GetY(); | 	int y = GetY(); | ||||||
| 	REAL cx = (REAL)(x + m_W / 2.0); | 	double cx = x + m_W / 2.0; | ||||||
| 	REAL cy = (REAL)(y + m_H / 2.0); | 	double cy = y + m_H / 2.0; | ||||||
|  |  | ||||||
| 	double lineStart = ((m_CntrlLineStart) ? m_LineStartShift * m_Value : 0) + m_LineStart; | 	double lineStart = ((m_CntrlLineStart) ? m_LineStartShift * m_Value : 0) + m_LineStart; | ||||||
| 	double lineLength = ((m_CntrlLineLength) ? m_LineLengthShift * m_Value : 0) + m_LineLength; | 	double lineLength = ((m_CntrlLineLength) ? m_LineLengthShift * m_Value : 0) + m_LineLength; | ||||||
|  |  | ||||||
| 	// Calculate the end point of the line | 	// Calculate the end point of the line | ||||||
| 	double angle = ((m_CntrlAngle) ? m_RotationAngle * m_Value : m_RotationAngle) + m_StartAngle; | 	double angle = ((m_CntrlAngle) ? m_RotationAngle * m_Value : m_RotationAngle) + m_StartAngle; | ||||||
| 	REAL e_cos = (REAL)cos(angle); | 	double e_cos = cos(angle); | ||||||
| 	REAL e_sin = (REAL)sin(angle); | 	double e_sin = sin(angle); | ||||||
|  |  | ||||||
|  | 	REAL sx = (REAL)(e_cos * lineStart + cx); | ||||||
|  | 	REAL sy = (REAL)(e_sin * lineStart + cy); | ||||||
|  | 	REAL ex = (REAL)(e_cos * lineLength + cx); | ||||||
|  | 	REAL ey = (REAL)(e_sin * lineLength + cy); | ||||||
|  |  | ||||||
| 	if (m_Solid) | 	if (m_Solid) | ||||||
| 	{ | 	{ | ||||||
| @@ -144,33 +149,23 @@ bool CMeterRoundLine::Draw(Graphics& graphics) | |||||||
| 		REAL sweepAngle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value)); | 		REAL sweepAngle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value)); | ||||||
|  |  | ||||||
| 		// Calculate the start point of the line | 		// Calculate the start point of the line | ||||||
| 		REAL s_cos = (REAL)cos(m_StartAngle); | 		double s_cos = cos(m_StartAngle); | ||||||
| 		REAL s_sin = (REAL)sin(m_StartAngle); | 		double s_sin = sin(m_StartAngle); | ||||||
|  |  | ||||||
| 		//Create a path to surround the arc | 		//Create a path to surround the arc | ||||||
| 		GraphicsPath path; | 		GraphicsPath path; | ||||||
| 		path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle); | 		path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle); | ||||||
| 		path.AddLine((REAL)lineStart * s_cos + cx, (REAL)lineStart * s_sin + cy, (REAL)lineLength * s_cos + cx, (REAL)lineLength * s_sin + cy); | 		path.AddLine((REAL)(lineStart * s_cos + cx), (REAL)(lineStart * s_sin + cy), (REAL)(lineLength * s_cos + cx), (REAL)(lineLength * s_sin + cy)); | ||||||
| 		path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle); | 		path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle); | ||||||
| 		path.AddLine((REAL)lineLength * e_cos + cx, (REAL)lineLength * e_sin + cy, (REAL)lineStart * e_cos + cx, (REAL)lineStart * e_sin + cy); | 		path.AddLine(ex, ey, sx, sy); | ||||||
|  |  | ||||||
| 		SolidBrush solidBrush(m_LineColor); | 		SolidBrush solidBrush(m_LineColor); | ||||||
| 		graphics.FillPath(&solidBrush, &path); | 		graphics.FillPath(&solidBrush, &path); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		// Set the length |  | ||||||
| 		REAL x = e_cos * (REAL)lineLength + cx; |  | ||||||
| 		REAL y = e_sin * (REAL)lineLength + cy; |  | ||||||
|  |  | ||||||
| 		if (lineStart > 0.0) |  | ||||||
| 		{ |  | ||||||
| 			cx += e_cos * (REAL)lineStart; |  | ||||||
| 			cy += e_sin * (REAL)lineStart; |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		Pen pen(m_LineColor, (REAL)m_LineWidth); | 		Pen pen(m_LineColor, (REAL)m_LineWidth); | ||||||
| 		graphics.DrawLine(&pen, cx, cy, x, y); | 		graphics.DrawLine(&pen, sx, sy, ex, ey); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 spx
					spx