Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » CalendarCtrl » Clock small scale
Clock small scale [message #15141] Wed, 02 April 2008 17:12 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I've noticed that Clock does not scale too well with small sizes. Clock probably wasn't designed with this in mind so it is probably Ok to leave it like this. Still, at small sizes the clock needles are drawn on top of the header with the 4 buttons. This looks very ugly. I would propose to change the order of the drawing so at least the header will be drawn on top of everything when the size is too small, like this:

void Clock::Paint(Draw& w)
{
	const Style &st = style ? *style : StyleDefault();

	CalcSizes();

	w.DrawRect(sz, st.bgmain);
	
	if(colon)
		PaintCenteredText(w, sz.cx / 2, hs / 2 - 1, " : ", StdFont().Bold(), SColorHighlightText());

	//w.DrawEllipse(cm.x - r / 2, cm.y - r / 2, cf.x, cf.x, Blend(st.header, White, 250), PEN_NULL, Black);

	Font fnt = st.font;

	if (sz.cy < hs * 4)
		fnt.Height(8);
	else if (sz.cy < hs * 5)
		fnt.Height(10);
	else if (sz.cy < hs * 6)
		fnt.Height(11);
	
	for(int i = 1; i <= 12; i++) {
		PaintCenteredText(w,
		                  cm.x + int(0.8 * sin(i * M_PI / 6.0) * cf.x),
		                  cm.y - int(0.8 * cos(i * M_PI / 6.0) * cf.y),
		                  AsString(i), fnt.Bold(i % 3 == 0), SBlack());
	}

	int cp = cur_point;
	for(int i = 1; i <= 60; i++) {
		int x = cm.x + int(0.95 * sin(i * M_PI / 30.0) * cf.x);
		int y = cm.y - int(0.95 * cos(i * M_PI / 30.0) * cf.y);
		PaintCenteredImage(w, x, y,
		                   cur_point == i ? CtrlImg::BigDotH()
		                                  : i % 5 == 0 ? CtrlImg::BigDot() : CtrlImg::SmallDot());
	}

	PaintPtr(0, w, cm, cur_time / 3600.0 / 12, 0.5, 5, cur_line == 0 ? st.arrowhl : st.arrowhour, cf);
	PaintPtr(1, w, cm, cur_time / 3600.0, 0.6, 3, cur_line == 1 ? st.arrowhl : st.arrowminute, cf);
	if(seconds)
		PaintPtr(2, w, cm, cur_time / 60.0, 0.75, 2, cur_line == 2 ? st.arrowhl : st.arrowsecond, cf);
	
	DrawBg(w, 0, 0, sz.cx, hs, st.header);
}


And another strange behavior: you have the buttons to adjust minutes and hour, but you can also drag the needles. Dragging needles results in a smooth progression, but using buttons, especially the decrease buttons gives strange results when decreasing under zero, even increasing the time. Would you like me to fix this?
Re: Clock small scale [message #20348 is a reply to message #15141] Fri, 13 March 2009 05:25 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Also fixed the issue with decreasing minutes under zero by button push. The problem occurred because of the use of increment/decrement operators on byte values and passing those values to functions that expected int values. Mixing signed/unsigned is yet again not a great idea, and by using binary operators we get implicit int conversion:
void Clock::SetHourLeft()
{
	sel.hour = SetMinMax(sel.hour - 1, 0, 23).value;
	UpdateTime();
}

void Clock::SetHourRight()
{
	sel.hour = SetMinMax(sel.hour + 1, 0, 23).value;
	UpdateTime();
}

void Clock::SetMinuteLeft()
{
	MinMax mm = SetMinMax(sel.minute - 1, 0, 59);
	sel.minute = mm.value;
	sel.hour = SetMinMax(sel.hour + mm.diff, 0, 23).value;
	UpdateTime();
}

void Clock::SetMinuteRight()
{
	MinMax mm = SetMinMax(sel.minute + 1, 0, 59);
	sel.minute = mm.value;
	sel.hour = SetMinMax(sel.hour + mm.diff, 0, 23).value;
	UpdateTime();
}
Re: Clock small scale [message #20350 is a reply to message #20348] Fri, 13 March 2009 09:09 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thanks -> in svn Smile I always wondered why time values are not ints? Just to save memory?
I think also that datetime picker must have ok and cancel button. I found unintuitive for users cliking in the center of clock to accept time change only.
Re: Clock small scale [message #20353 is a reply to message #20350] Fri, 13 March 2009 10:15 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
unodgs wrote on Fri, 13 March 2009 10:09

Thanks -> in svn Smile

Thanks!

cbpporter issue #016: Clock minute buttons bug
Fixed.

Could you apply the patch from first post (Paint) too?

Quote:


I always wondered why time values are not ints? Just to save memory?


Wasn't there when that happened, but my guess: yes!

Quote:


I think also that datetime picker must have ok and cancel button. I found unintuitive for users cliking in the center of clock to accept time change only.


Never tried datetime picker. I'll look over it and tell you what I think.

[Updated on: Fri, 20 March 2009 16:43]

Report message to a moderator

Re: Clock small scale [message #20354 is a reply to message #20353] Fri, 13 March 2009 10:50 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Quote:

Could you apply the patch from first post (Paint) too?

Somehow I missed this post. I'll take a look at this.
Re: Clock small scale [message #20355 is a reply to message #20350] Fri, 13 March 2009 13:14 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Ok, I commited some changes for better clock scaling. Please see if it works for you.
Re: Clock small scale [message #20358 is a reply to message #20355] Fri, 13 March 2009 18:05 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
unodgs wrote on Fri, 13 March 2009 14:14

Ok, I commited some changes for better clock scaling. Please see if it works for you.

Thanks! You went farther than I did, since is just wanted it to not look incredibly ugly with small sizes.

cbpporter Issue #015: Clock small scale
Fixed.
Previous Topic: DropTime problem
Next Topic: Events to spin buttons, add mousewheel too.
Goto Forum:
  


Current Time: Fri Mar 29 00:29:36 CET 2024

Total time taken to generate the page: 0.01666 seconds