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 » Look and Chameleon Technology » A little theming
Re: A little theming [message #18618 is a reply to message #18607] Sun, 12 October 2008 11:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sat, 11 October 2008 13:46

luzr wrote on Sat, 11 October 2008 09:29

cbpporter wrote on Mon, 06 October 2008 12:31

So here is the next preview. It is starting to really shape up.

Disabled scrollbars are a little bit ugly because I can't get the desired effect with hotspots yet. Also, it would be nice if the Style could specify if a disabled scrollbar shows it's thumb or not.

DropList skin is not complete.

EditFields have some problem with their border, because I can't figure out yet how to resize it. I need to define border sizes through chameleon.



I cannot help without seeing the code Smile


Hmmm, I thought that I posted a test case with source.



BTW, maybe we should add some "more relaxed" nest to svn so that others can easily participate in projects like this?

Or maybe you should have just uploaded into bazaar?

Mirek
Re: A little theming [message #18638 is a reply to message #18618] Mon, 13 October 2008 20:34 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Ok. I've started the refactoring of my bloated Theme class to get ready for sharing, but I have encountered a strange issue.

I can no longer change the default Style. Even when doing something like:
s.look[0] = Blue();

in Them.cpp the style remains unchanged.

See testcase.
Re: A little theming [message #18645 is a reply to message #18638] Tue, 14 October 2008 13:14 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I think the problem is with your serialization. If you apply the Theme straight away after creating it (before saving and loading it) it works. My guess is that Upp somehow detects that the style is corrupt/invalid and falls back to the default theme. Which would be incredibly clever if true Smile

I don't think you can just serialize Values the way you are attempting to, not for Images and the other Chameloen LookWith* types anyway.

[Updated on: Tue, 14 October 2008 13:15]

Report message to a moderator

Re: A little theming [message #18647 is a reply to message #18645] Tue, 14 October 2008 13:32 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
mrjt wrote on Tue, 14 October 2008 14:14

I think the problem is with your serialization. If you apply the Theme straight away after creating it (before saving and loading it) it works. My guess is that Upp somehow detects that the style is corrupt/invalid and falls back to the default theme. Which would be incredibly clever if true Smile

I don't think you can just serialize Values the way you are attempting to, not for Images and the other Chameloen LookWith* types anyway.


Yes, I noticed that. I am just not able to figure out why this is happening, but I don't think it is something as clever as that. Maybe it has something to do with the fact that ImageLists can be reset to their initial content. Maybe that is what is serialized.

Anyway, I need to figure this out because I want to serialize themes. I already have a big Theme class which overwrites all the Style*().Write() instances, similar to how current theming is done or with BlueBar. But I don't like this hard-coded approach and want to load my themes from disk and not have them embedded in the exe.
Re: A little theming [message #18649 is a reply to message #18647] Tue, 14 October 2008 14:39 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Well, I've bodged it. The problems:
1- As above, you have to add code to serialize the look based on it's type.
2- The reason the style was being ignored was that you can't just create a ChStyle and expect it to work, it needs to registered properly with Upp. This is normally done by the CH_STYLE macro, but you can also do it by copying an existing ChStyle before altering it. It may also be possible to use ChRegisterStyle__ directly.

Below is the code I used. There is a bit more bodging with StringStreams because for some reason PNGRaster and PNGEncoder are slightly incompatible.

Personally I would avoid supporting saving themes, and just create a sensible file format than can be edited externally.

enum {
	ImageLookType = 0,
	ColorLookType	
};

void SerializeLook(Stream &s, Value &v) {
	int type;
	if (s.IsStoring()) {
		if(IsType<Color>(v)) {
			Color c = v;
			type = ColorLookType;
			s % type % c;
		}
		else if(IsType<Image>(v)) {
			type = ImageLookType;
			s % type;
			StringStream png;
			Image img = v;
			PNGEncoder().Save(png, img);
			s % (String)png;
			Point p1 = img.GetHotSpot();
			Point p2 = img.Get2ndSpot();
			s % p1 % p2;
		}
	}
	else {
		s % type; 
		if (type == ImageLookType) {
			String png;
			s % png;
			StringStream str(png);
			Image img = PNGRaster().Load(str);
			ASSERT(!IsNull(img));
			Point p1;
			Point p2;
			s % p1 % p2;
			ImageBuffer ib(img);
			ib.SetHotSpot(p1);
			ib.Set2ndSpot(p2);
			v = (Image)ib;
		}
		else if (type == ColorLookType) {
			Color c;
			s % c;
			ASSERT(!IsNull(c));
			v = c;
		}			
	}
};

void Theme::ButtonStyle::Serialize(Stream& s)
{
	if (s.IsLoading())
		d = Button::StyleNormal(); // Make sure style is initialised
	s % d.cancel % d.exit % d.focusmargin;
	for (int i = 0; i < 4; i++)	{	
		SerializeLook(s, d.look[i]);
	}
}

[Updated on: Tue, 14 October 2008 14:43]

Report message to a moderator

Re: A little theming [message #18667 is a reply to message #18649] Wed, 15 October 2008 17:07 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
mrjt wrote on Tue, 14 October 2008 15:39

Well, I've bodged it. The problems:
2- The reason the style was being ignored was that you can't just create a ChStyle and expect it to work, it needs to registered properly with Upp. This is normally done by the CH_STYLE macro, but you can also do it by copying an existing ChStyle before altering it. It may also be possible to use ChRegisterStyle__ directly.

	if (s.IsLoading())
		d = Button::StyleNormal(); // Make sure style is initialised
}


Thanks, that solved it! Not I can edit the styles again. I had no idea about the need to register styles. Just when I thought that Chameleon is done with it's surprises.

Quote:


Personally I would avoid supporting saving themes, and just create a sensible file format than can be edited externally.


A more sensible format would be better than raw serializing, but I don't really know what to use. A ZIP with PNGs and a XML comes to mind, but that is a little too much work for my current needs. Maybe if some day we'll want official explicit theme support, I'll rewrite the thing to be a much nicer solution. Right now I'll focus on theming Toolbar and then get a preview out with code, which I'll show to the author of the original theme also, so he can warn me if I've completely butchered the look Razz.

Quote:


There is a bit more bodging with StringStreams because for some reason PNGRaster and PNGEncoder are slightly incompatible.


What do you mean by that?
Re: A little theming [message #18669 is a reply to message #18667] Wed, 15 October 2008 17:41 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
cbpporter wrote on Wed, 15 October 2008 16:07

Quote:


There is a bit more bodging with StringStreams because for some reason PNGRaster and PNGEncoder are slightly incompatible.

What do you mean by that?

PNGRaster doesn't seem to read quite all of the data that's written by PNGEncoder:
	int beefin = 0xDEADBEEF;
	int beefout;
	StringStream s;

	PNGEncoder().Save(s, CtrlImg::HelpCursor1());
	s % beefin;

	s.SetLoading();
	s.Seek(0);
	Image img = PNGRaster().Load(s);
	s % beefout;

	ASSERT(!IsNull(img));	
	ASSERT(beefin == beefout);	

In this example the Image is read correctly but 'beefin == beefout' asserts because beefout is read from the incorrect point in the stream.

I avoided this in the code above by encoding the png into a String first so that you can guarantee the correct number of bytes are read, but really it should be fixed.

Edit: Tested on 2008.1

[Updated on: Wed, 15 October 2008 17:47]

Report message to a moderator

Re: A little theming [message #18670 is a reply to message #18669] Wed, 15 October 2008 20:14 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
If I remember correctly, I saw in a Delphi PNG implementation that PNGs can not be easily streamed because they use the size of the file to compute some information that is not directly saved in the header. But that was a long time ago, so maybe I'm wrong.
Re: A little theming [message #18685 is a reply to message #18670] Thu, 16 October 2008 22:45 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Is there a way to control the height difference between an active tab of a TabCtrl and an inactive tab? Under Windows it seems to be hardcoded. I need this to fully reproduce the skin. Also, I need to be able to draw the background area that is behind the tab headers with a single look Value.

I leave you with this final screenshot before release. I removed the old ones and the exe.

I promise, this is going to be the final teaser before the release Smile.

index.php?t=getfile&id=1443&private=0
  • Attachment: untitled.PNG
    (Size: 21.85KB, Downloaded 1453 times)
Re: A little theming [message #18687 is a reply to message #18685] Fri, 17 October 2008 00:04 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
That's looking really good! I might have to use it myself.

For setting the inactive height you can change sel.top. Setting it to 0 for instance makes all tabs the same height. With the current code I don't think it's possible to set the background, since it's drawn as part of the tabs.
Re: A little theming [message #18707 is a reply to message #18687] Fri, 17 October 2008 18:56 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
So here is a first version of the theme. It is currently alpha quality only, so don't except too much from it. The format under which themes are stored will definitely change to something more robust and hopefully more editable. The interface will also surely change. Ignore all those nested classes. They are simple wrappers around the normal Styles, because normal Styles don't support any form of streaming and I can't change change their implementation to allow streaming.

The attachment contains two packages. The first one, Skulpture, creates the theme and exports it. You will need to run it once to create the theme. Just change the output path to something better than "C:\".

The second package is the Theme itself. This is the one you need. Add it to your project, and do something like:
Theme m;
LoadFromFile(m, "c:\\test.utheme");
m.Apply(); 


The theme covers buttons, default buttons, options, switches, tabs, edit fields, drop lists, menus and toolbars. Rest to come in future revisions.

TabCtrl is not perfect yet. A small change to it's paint is needed to allow background look for tab area.

And I still couldn't figure out how to change EditField border sizes.
  • Attachment: Skulpture.rar
    (Size: 20.98KB, Downloaded 460 times)
Re: A little theming [message #18712 is a reply to message #18707] Sat, 18 October 2008 09:10 Go to previous messageGo to next message
chickenk is currently offline  chickenk
Messages: 169
Registered: May 2007
Location: Grenoble, France
Experienced Member
Hello,

thanks for this theme. I tried to compile and test it on Linux. 2 remarks :

1. The tabs seems to go down a few pixels more than they should, see the picture below:
index.php?t=getfile&id=1445&private=0

2. The Stream operator% overloading seems to make gcc unhappy. The prototype is:
Stream& Stream::operator%(String& s);

Since it is passed a reference, the parameter must be a real allocated variable (at least it seems to be what gcc wants). In file Theme.cpp, line 27, the code
s % (String)png;
raises an error from gcc.
I could correct it by first creating a string variable from the 'png' StringStream, then passing its reference to the operator, like this :
String s_png = (String)png;
s % s_png;

Is there a better way to achieve this? Or a GCC option allowing the original contruction ? Can you confirm you compiled this code with MSVC and not mingw ?

Thanks,
Lionel
Re: A little theming [message #18713 is a reply to message #18712] Sat, 18 October 2008 09:51 Go to previous messageGo to next message
chickenk is currently offline  chickenk
Messages: 169
Registered: May 2007
Location: Grenoble, France
Experienced Member
please ignore this one-liner post. I wrote stupid things in it but could not delete it so I replaced the content.

[Updated on: Sat, 18 October 2008 09:59]

Report message to a moderator

Re: A little theming [message #18742 is a reply to message #18712] Sun, 19 October 2008 13:08 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
chickenk wrote on Sat, 18 October 2008 10:10


1. The tabs seems to go down a few pixels more than they should, see the picture below:


Yes, the theme was developed under Windows and some minor look discrepancies are bound to appear. These will be fixed soon as the them matures. Please be patient.

Quote:


2. The Stream operator% overloading seems to make gcc unhappy. The prototype is:
Stream& Stream::operator%(String& s);



I don't normally use GCC, especially because of the way it handles such issues. I once tried to show somebody how to write a very simple boost::format and it worked fine on my compiler, but MINGW failed miserably to compile that. I don't know which of the too compilers is right here. Maybe I can dig up that sample.

But back to the problem: I'll investigate these and try to deliver a version which works on all platforms. But this will have to wait a little, because I'm having problems even building CtrlCOre and CtrlLib with latest SVN under MINGW.
Re: A little theming [message #18762 is a reply to message #18712] Mon, 20 October 2008 10:51 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
chickenk wrote on Sat, 18 October 2008 08:10

2. The Stream operator% overloading seems to make gcc unhappy. The prototype is:
Stream& Stream::operator%(String& s);

Since it is passed a reference, the parameter must be a real allocated variable (at least it seems to be what gcc wants). In file Theme.cpp, line 27, the code
s % (String)png;
raises an error from gcc.
I could correct it by first creating a string variable from the 'png' StringStream, then passing its reference to the operator, like this :
String s_png = (String)png;
s % s_png;

Is there a better way to achieve this? Or a GCC option allowing the original contruction ? Can you confirm you compiled this code with MSVC and not mingw ?

Sorry, this one is my error. It was tested of MSVC and I always forget the stricter GCC requirements.

I don't know of any better way that adding a variable. It's a real pain IMO.
Re: A little theming [message #18812 is a reply to message #18762] Thu, 23 October 2008 19:57 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
The them is really approaching production status. There are still a bunch of controls that need skinning, but most common ones are done.

Under Linux the style still varies depending on Gnome theme. I'll try to fix that soon a repost the theme with a few nice additions.
I had to do some compromises, and I hope to be able to eliminate some of them to preserve the original look.

PS: I will point Christoph Feck, the author of this theme directly to this forum, so that he can see the progress.

Here is UWord:
index.php?t=getfile&id=1458&private=0
  • Attachment: sample.png
    (Size: 68.45KB, Downloaded 1367 times)
Re: A little theming [message #18814 is a reply to message #18812] Thu, 23 October 2008 21:06 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Beautiful. I use it in my own applications. I see you styled arrayctrl and multibutton. That's great. The only strange place is for example dropdown button of font height combo on the toolbar. It's too big. But maybe it's not a fault of the theme. Must check this out.
IMO the default button soft border could be blue. I think it would add some "light" to the theme. I hope you will experiment with it Smile

[Updated on: Thu, 23 October 2008 21:07]

Report message to a moderator

Re: A little theming [message #18816 is a reply to message #18812] Fri, 24 October 2008 07:59 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

What about to create a visual theme editor mechanism?
I thing that will be greater!
Re: A little theming [message #18818 is a reply to message #18816] Fri, 24 October 2008 11:01 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
unodgs wrote on Thu, 23 October 2008 22:06

Beautiful. I use it in my own applications. I see you styled arrayctrl and multibutton. That's great. The only strange place is for example dropdown button of font height combo on the toolbar. It's too big. But maybe it's not a fault of the theme. Must check this out.
IMO the default button soft border could be blue. I think it would add some "light" to the theme. I hope you will experiment with it Smile

I'm glad you like it!

Yes, I skinned MultiButton. I had to make a huge compromise with it, because MultiButton style and rules are quite complex, and my patience with endless trial & error is limited. But surprisingly, it turned out quite close to the original.

Array control is far from done, it is lacking the smooth shadows that are typical for this theme. But I will get there.

I know about DropChoice being too big. It stands out really bad, but I couldn't figure out a way to make it behave the way I want. Again, a lot of trial & error.

And there is still the huge problem with EditField border. Depending on Linux theme, it adds an extra border. Also under Windows. I've spent about six hours in the last two days trying to figure out the code, and each time I found something that looked like it would be responsible for the extra border, I hit a dead end. For this screen shot I choose a theme that has no such issues. Should I have chosen a different theme, you could have seen the extra border.

I'll work hard to get it to a beta level this weekend.

PS: How's your Oxygen style progressing? With two high quality custom themes, and one reproducing the “modern” Windows look (like in ToolKit Pro), we will have great eye-candy possibilities.

tojocky wrote on Fri, 24 October 2008 08:59

What about to create a visual theme editor mechanism?
I thing that will be greater!

That would be great, but I don't know how it could be possible. When I started doing this theme, I thought that all that working with the images and fiddling to get shadows perfect would be horrible. But instead, that was the easies part. Figuring out how to set thing inn Chameleon so that it looks the same under all platforms was/is the hard part. It would be even harder to incorporate that into a visual editor. But it is something to think about. If you have any ideas, please share.

OTOH, I've been thinking a lot about the previous idea with an achieve with and XML and a bunch of pictures. It would make the theme more editable by the non technical people. Sure, TheIDE's image editor is quite excellent after you get used tot it (but I did manage to crash it once), but you have to write code to apply those images and extra information to a theme and export it as a shareable binary. With and XML, people could edit it easily and use their favorite image editing program. Yet, U++ theming engine is not really targeted by anybody else than us, and I think we can handle a little code Smile.

Re: A little theming [message #18820 is a reply to message #18818] Fri, 24 October 2008 14:53 Go to previous messageGo to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

cbpporter wrote on Fri, 24 October 2008 05:01


Array control is far from done, it is lacking the smooth shadows that are typical for this theme. But I will get there.


I used skulpture button image to draw grid ctrl. I think it looks very good:
index.php?t=getfile&id=1459&private=0
Quote:


And there is still the huge problem with EditField border. Depending on Linux theme, it adds an extra border. Also under Windows. I've spent about six hours in the last two days trying to figure out the code, and each time I found something that looked like it would be responsible for the extra border, I hit a dead end. For this screen shot I choose a theme that has no such issues. Should I have chosen a different theme, you could have seen the extra border.


yes, edit field frame it's a complicated piece of code. Mirek worked on it quite long.
Quote:


I'll work hard to get it to a beta level this weekend.


Great! But maybe could you start using our svn?
Quote:


PS: How's your Oxygen style progressing? With two high quality custom themes, and one reproducing the “modern” Windows look (like in ToolKit Pro), we will have great eye-candy possibilities.


The problem is I have no time right now, as always (one commercial project is almost finished the next is coming..), but I'll try to get back to it ASAP.
  • Attachment: grid.png
    (Size: 1.72KB, Downloaded 1301 times)
Previous Topic: The problem with the operation of the buffer.
Next Topic: Set fields side to other fields and fields width to text width
Goto Forum:
  


Current Time: Thu Mar 28 21:02:21 CET 2024

Total time taken to generate the page: 0.01622 seconds