Browse Source

TextActor and Sprite have same parent with VisualStyle now
updated cmake
improved examples
added Actor::removeTweensByName
added default colors collection to Color.h
fixed FileSystem
improved and reworked SlidingActor

Denis Muratshin 12 years ago
parent
commit
8ddd12c2d7
64 changed files with 1200 additions and 498 deletions
  1. 2 2
      .hg_archival.txt
  2. 11 5
      CMakeLists.txt
  3. BIN
      doc.zip
  4. 1 1
      examples/Demo/CMakeLists.txt
  5. 2 2
      examples/Demo/ios/OxygineDemo/OxygineDemo.xcodeproj/project.pbxproj
  6. 4 4
      examples/Demo/src/TestClipRect.h
  7. 3 3
      examples/Demo/src/TestDrag.h
  8. 10 11
      examples/Demo/src/TestManageRes.h
  9. 34 30
      examples/Demo/src/TestMask.h
  10. 9 14
      examples/Demo/src/TestPerf.h
  11. 3 1
      examples/Demo/src/TestProgressBar.h
  12. 3 2
      examples/Demo/src/TestRender2Texture.h
  13. 113 0
      examples/Demo/src/TestSliding.h
  14. 1 1
      examples/Demo/src/TestTexel2Pixel.h
  15. 2 2
      examples/Demo/src/TestText.h
  16. 2 2
      examples/Demo/src/TestTextureFormat.h
  17. 7 7
      examples/Demo/src/TestTweens.h
  18. 4 4
      examples/Demo/src/example.cpp
  19. 87 24
      examples/Demo/src/test.cpp
  20. 20 4
      examples/Demo/src/test.h
  21. 12 12
      examples/Demo/win32/HelloWorld_vs2010.vcxproj
  22. 6 6
      examples/Demo/win32/HelloWorld_vs2010.vcxproj.filters
  23. 1 1
      examples/DemoBox2D/src/Box2DDebugDraw.cpp
  24. 1 1
      examples/DemoBox2D/src/example.cpp
  25. 2 2
      examples/GameTemplate/src/GameActor.cpp
  26. 1 1
      examples/GameTemplate/src/MainMenu.cpp
  27. 18 1
      oxygine/src/Actor.cpp
  28. 18 14
      oxygine/src/Actor.h
  29. 8 9
      oxygine/src/DebugActor.cpp
  30. 1 0
      oxygine/src/Draggable.h
  31. 4 4
      oxygine/src/ProgressBar.cpp
  32. 1 1
      oxygine/src/ProgressBar.h
  33. 159 87
      oxygine/src/SlidingActor.cpp
  34. 33 26
      oxygine/src/SlidingActor.h
  35. 12 11
      oxygine/src/Sprite.cpp
  36. 12 16
      oxygine/src/Sprite.h
  37. 11 15
      oxygine/src/TextActor.cpp
  38. 10 13
      oxygine/src/TextActor.h
  39. 2 4
      oxygine/src/Tweener.h
  40. 6 0
      oxygine/src/VisualStyle.cpp
  41. 20 0
      oxygine/src/VisualStyle.h
  42. 59 10
      oxygine/src/core/FileSystem.cpp
  43. 6 1
      oxygine/src/core/FileSystem.h
  44. 9 10
      oxygine/src/core/Renderer.cpp
  45. 0 12
      oxygine/src/core/Renderer.h
  46. 85 36
      oxygine/src/core/STDFileSystem.cpp
  47. 8 3
      oxygine/src/core/STDFileSystem.h
  48. 6 0
      oxygine/src/core/VideoDriver.cpp
  49. 17 0
      oxygine/src/core/VideoDriver.h
  50. 10 0
      oxygine/src/core/ZipFileSystem.cpp
  51. 4 1
      oxygine/src/core/ZipFileSystem.h
  52. 42 14
      oxygine/src/core/file.cpp
  53. 5 2
      oxygine/src/core/file.h
  54. 4 5
      oxygine/src/core/gl/ShaderProgramGL.cpp
  55. 28 3
      oxygine/src/core/gl/VideoDriverGL.cpp
  56. 8 0
      oxygine/src/core/gl/VideoDriverGL.h
  57. 12 1
      oxygine/src/core/gl/VideoDriverGLES20.cpp
  58. 55 41
      oxygine/src/core/gl/oxgl.h
  59. 16 5
      oxygine/src/core/oxygine.cpp
  60. 3 3
      oxygine/src/dev_tools/TexturesInspector.cpp
  61. 1 1
      oxygine/src/dev_tools/TreeInspectorLine.cpp
  62. 5 4
      oxygine/src/initActor.h
  63. 160 3
      oxygine/src/math/Color.h
  64. 1 0
      oxygine/src/oxygine_include.h

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: 94bbf38496f29d1b9202455df28b1dc3a2d02df9
+node: 98dd1ddf4012c28e1a3fb3d7d9196a444ee56680
 branch: default
 branch: default
 latesttag: oldrender
 latesttag: oldrender
-latesttagdistance: 15
+latesttagdistance: 39

+ 11 - 5
CMakeLists.txt

@@ -1,10 +1,6 @@
 cmake_minimum_required (VERSION 2.6)
 cmake_minimum_required (VERSION 2.6)
 project (OXYGINE)
 project (OXYGINE)
 
 
-
-message(STATUS ${SDL2_INCLUDE_DIRS})
-#set(SDL2_INCLUDE_DIRS SDL2)
-
 if (MSVC)
 if (MSVC)
 	set(OXYGINE_DEFINITIONS	
 	set(OXYGINE_DEFINITIONS	
 		-D_CRT_SECURE_NO_WARNINGS)
 		-D_CRT_SECURE_NO_WARNINGS)
@@ -13,7 +9,15 @@ else(MSVC)
 	#set(OXYGINE_DEFINITIONS	
 	#set(OXYGINE_DEFINITIONS	
 	#	-D_REENTRANT) #linux pthreads
 	#	-D_REENTRANT) #linux pthreads
 	find_path(SDL2_INCLUDE_DIRS NAMES SDL2/SDL.h)
 	find_path(SDL2_INCLUDE_DIRS NAMES SDL2/SDL.h)
-	set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}/SDL2)
+	message(STATUS ${SDL2_INCLUDE_DIRS_FOUND})
+
+	if (SDL2_INCLUDE_DIRS)		
+		set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}/SDL2)
+		message(STATUS "found")		
+	else()
+		message(STATUS "SDL notfound")
+		set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../SDL/include)					
+	endif()
 endif(MSVC)
 endif(MSVC)
 
 
 set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/greenlets/src/greenlet.c)
 set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/greenlets/src/greenlet.c)
@@ -22,6 +26,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/oxygine/greenlets/src/)
 
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/linux)
 	set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/linux)
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+	set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/ios)
 else()
 else()
 	set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/win32)
 	set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/win32)
 endif()
 endif()

BIN
doc.zip


+ 1 - 1
examples/Demo/CMakeLists.txt

@@ -9,7 +9,7 @@ add_executable(Demo
 	src/test.h
 	src/test.h
 	src/TestBox9Sprite.h
 	src/TestBox9Sprite.h
 	src/TestClipRect.h
 	src/TestClipRect.h
-	src/TestComplexDrag.h
+	src/TestSliding.h
 	src/TestDrag.h
 	src/TestDrag.h
 	src/TestManageRes.h
 	src/TestManageRes.h
 	src/TestMask.h
 	src/TestMask.h

+ 2 - 2
examples/Demo/ios/OxygineDemo/OxygineDemo.xcodeproj/project.pbxproj

@@ -86,7 +86,6 @@
 		04998D4917F8A9FC003441C3 /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = test.h; path = ../../../src/test.h; sourceTree = "<group>"; };
 		04998D4917F8A9FC003441C3 /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = test.h; path = ../../../src/test.h; sourceTree = "<group>"; };
 		04998D4A17F8A9FC003441C3 /* TestBox9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestBox9Sprite.h; path = ../../../src/TestBox9Sprite.h; sourceTree = "<group>"; };
 		04998D4A17F8A9FC003441C3 /* TestBox9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestBox9Sprite.h; path = ../../../src/TestBox9Sprite.h; sourceTree = "<group>"; };
 		04998D4B17F8A9FC003441C3 /* TestClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestClipRect.h; path = ../../../src/TestClipRect.h; sourceTree = "<group>"; };
 		04998D4B17F8A9FC003441C3 /* TestClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestClipRect.h; path = ../../../src/TestClipRect.h; sourceTree = "<group>"; };
-		04998D4C17F8A9FC003441C3 /* TestComplexDrag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestComplexDrag.h; path = ../../../src/TestComplexDrag.h; sourceTree = "<group>"; };
 		04998D4D17F8A9FC003441C3 /* TestDrag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestDrag.h; path = ../../../src/TestDrag.h; sourceTree = "<group>"; };
 		04998D4D17F8A9FC003441C3 /* TestDrag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestDrag.h; path = ../../../src/TestDrag.h; sourceTree = "<group>"; };
 		04998D4E17F8A9FC003441C3 /* TestManageRes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestManageRes.h; path = ../../../src/TestManageRes.h; sourceTree = "<group>"; };
 		04998D4E17F8A9FC003441C3 /* TestManageRes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestManageRes.h; path = ../../../src/TestManageRes.h; sourceTree = "<group>"; };
 		04998D4F17F8A9FC003441C3 /* TestMask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestMask.h; path = ../../../src/TestMask.h; sourceTree = "<group>"; };
 		04998D4F17F8A9FC003441C3 /* TestMask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestMask.h; path = ../../../src/TestMask.h; sourceTree = "<group>"; };
@@ -108,6 +107,7 @@
 		04998EED17F8ADD4003441C3 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		04998EED17F8ADD4003441C3 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		04998EF517F8B6F3003441C3 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = ../../../../oxygine/third_party/ios/libraries/libpng.a; sourceTree = "<group>"; };
 		04998EF517F8B6F3003441C3 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = ../../../../oxygine/third_party/ios/libraries/libpng.a; sourceTree = "<group>"; };
 		04998EF617F8B6F3003441C3 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = ../../../../oxygine/third_party/ios/libraries/libjpeg.a; sourceTree = "<group>"; };
 		04998EF617F8B6F3003441C3 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = ../../../../oxygine/third_party/ios/libraries/libjpeg.a; sourceTree = "<group>"; };
+		049EA8B5184741AF0050853E /* TestSliding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestSliding.h; path = ../../../src/TestSliding.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 /* End PBXFileReference section */
 
 
 /* Begin PBXFrameworksBuildPhase section */
 /* Begin PBXFrameworksBuildPhase section */
@@ -227,6 +227,7 @@
 		04998D4417F8A9ED003441C3 /* src */ = {
 		04998D4417F8A9ED003441C3 /* src */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				049EA8B5184741AF0050853E /* TestSliding.h */,
 				04998D4517F8A9FC003441C3 /* entry_point.cpp */,
 				04998D4517F8A9FC003441C3 /* entry_point.cpp */,
 				04998D4617F8A9FC003441C3 /* example.cpp */,
 				04998D4617F8A9FC003441C3 /* example.cpp */,
 				04998D4717F8A9FC003441C3 /* example.h */,
 				04998D4717F8A9FC003441C3 /* example.h */,
@@ -234,7 +235,6 @@
 				04998D4917F8A9FC003441C3 /* test.h */,
 				04998D4917F8A9FC003441C3 /* test.h */,
 				04998D4A17F8A9FC003441C3 /* TestBox9Sprite.h */,
 				04998D4A17F8A9FC003441C3 /* TestBox9Sprite.h */,
 				04998D4B17F8A9FC003441C3 /* TestClipRect.h */,
 				04998D4B17F8A9FC003441C3 /* TestClipRect.h */,
-				04998D4C17F8A9FC003441C3 /* TestComplexDrag.h */,
 				04998D4D17F8A9FC003441C3 /* TestDrag.h */,
 				04998D4D17F8A9FC003441C3 /* TestDrag.h */,
 				04998D4E17F8A9FC003441C3 /* TestManageRes.h */,
 				04998D4E17F8A9FC003441C3 /* TestManageRes.h */,
 				04998D4F17F8A9FC003441C3 /* TestMask.h */,
 				04998D4F17F8A9FC003441C3 /* TestMask.h */,

+ 4 - 4
examples/Demo/src/TestClipRect.h

@@ -15,7 +15,7 @@ public:
 		childClp->attachTo(clp);
 		childClp->attachTo(clp);
 
 
 		spSprite spr = new Sprite;
 		spSprite spr = new Sprite;
-		spr->setAnimFrame(resources.getResAnim("batterfly"));
+		spr->setResAnim(resources.getResAnim("batterfly"));
 		spr->setX(200.0f);
 		spr->setX(200.0f);
 		spr->attachTo(clp);
 		spr->attachTo(clp);
 	}
 	}
@@ -28,7 +28,7 @@ public:
 
 
 		spSprite spr = new Sprite;
 		spSprite spr = new Sprite;
 		spr->setPosition(w/2.0f, h/2.0f);
 		spr->setPosition(w/2.0f, h/2.0f);
-		spr->setAnimFrame(resources.getResAnim("batterfly"));
+		spr->setResAnim(resources.getResAnim("batterfly"));
 		spr->attachTo(clp);
 		spr->attachTo(clp);
 		spr->setAnchor(0.5f, 0.5f);
 		spr->setAnchor(0.5f, 0.5f);
 		spr->setScale(sc);
 		spr->setScale(sc);
@@ -44,13 +44,13 @@ public:
 		int new_priority = actor->getParent()->getLastChild()->getPriority() + 1;
 		int new_priority = actor->getParent()->getLastChild()->getPriority() + 1;
 		actor->setPriority(new_priority);
 		actor->setPriority(new_priority);
 
 
-		actor->addTween(Sprite::TweenColor(Color(255,0,0,255)), 300, -1, true);
+		actor->addTween(Sprite::TweenColor(Color(Color::Red, 255)), 300, -1, true);
 	}
 	}
 
 
 	void onMouseUp(Event *event)
 	void onMouseUp(Event *event)
 	{
 	{
 		spSprite actor = safeSpCast<Sprite>(event->currentTarget);
 		spSprite actor = safeSpCast<Sprite>(event->currentTarget);
 		actor->removeTweens();		
 		actor->removeTweens();		
-		actor->setColor(Color(255,255,255,255));
+		actor->setColor(Color::White);
 	}
 	}
 };
 };

+ 3 - 3
examples/Demo/src/TestDrag.h

@@ -22,7 +22,7 @@ public:
 			spSprite sprite = new DraggableSprite;			
 			spSprite sprite = new DraggableSprite;			
 			Vector2 pos(100.0f * (i + 1), 150.0f);
 			Vector2 pos(100.0f * (i + 1), 150.0f);
 			sprite->setPosition(pos);
 			sprite->setPosition(pos);
-			sprite->setAnimFrame(resources.getResAnim("batterfly"));
+			sprite->setResAnim(resources.getResAnim("batterfly"));
 			sprite->attachTo(content);
 			sprite->attachTo(content);
 
 
 			sprite->setRotation(scalar::randFloat(0, (float)MATH_PI * 2));
 			sprite->setRotation(scalar::randFloat(0, (float)MATH_PI * 2));
@@ -57,7 +57,7 @@ public:
 	{
 	{
 		spSprite actor = safeSpCast<Sprite>(event->currentTarget);
 		spSprite actor = safeSpCast<Sprite>(event->currentTarget);
 		actor->removeTweens();		
 		actor->removeTweens();		
-		actor->setColor(Color(255,255,255,255));
+		actor->setColor(Color::White);
 	}
 	}
 };
 };
 
 
@@ -107,7 +107,7 @@ public:
 		if (event->currentTarget.get() != content)
 		if (event->currentTarget.get() != content)
 			return;
 			return;
 
 
-		dragging->setColor(Color(0xffffffff));
+		dragging->setColor(Color::White);
 		spTween t;
 		spTween t;
 		if (event->target == basket)
 		if (event->target == basket)
 			t = dragging->addTween(Actor::TweenPosition(basket->getPosition()), 500);
 			t = dragging->addTween(Actor::TweenPosition(basket->getPosition()), 500);

+ 10 - 11
examples/Demo/src/TestManageRes.h

@@ -4,12 +4,10 @@
 class ManageResTest: public Test
 class ManageResTest: public Test
 {
 {
 public:
 public:
-	bool loaded;
-
 	ManageResTest()
 	ManageResTest()
 	{
 	{
-		loaded = true;
-		addButton("switch", "Load/Unload resources");
+		toggle sw[] = {toggle("unload resources", 1), toggle("load resources", 0)};
+		addToggle("switch", sw, 2);
 		addButton("mt", "Multithreading loading");
 		addButton("mt", "Multithreading loading");
 		addButton("mt_slow", "MT loading (slow demo)");
 		addButton("mt_slow", "MT loading (slow demo)");
 
 
@@ -22,7 +20,7 @@ public:
 			if (ra->getName().find("_") != string::npos)
 			if (ra->getName().find("_") != string::npos)
 				continue;
 				continue;
 			spSprite sprite = new Sprite;
 			spSprite sprite = new Sprite;
-			sprite->setAnimFrame(ra);
+			sprite->setResAnim(ra);
 			sprite->addTween(TweenAnim(ra), 500, -1);
 			sprite->addTween(TweenAnim(ra), 500, -1);
 			sprite->setPosition(scalar::randFloat(50.0f, getWidth() - 100.0f), scalar::randFloat(50.0f, getHeight() - 100.0f));
 			sprite->setPosition(scalar::randFloat(50.0f, getWidth() - 100.0f), scalar::randFloat(50.0f, getHeight() - 100.0f));
 			sprite->attachTo(content);	
 			sprite->attachTo(content);	
@@ -57,29 +55,30 @@ public:
 
 
 	void _loaded(Event *event)
 	void _loaded(Event *event)
 	{
 	{
-		showPopup("Loaded!");
+		notify("Loaded!");
 		ui->getChild("loading")->addTween(Sprite::TweenAlpha(0), 400)->setDetachActor(true);
 		ui->getChild("loading")->addTween(Sprite::TweenAlpha(0), 400)->setDetachActor(true);
 	}
 	}
 
 
-	void clicked(string id)
+	void toggleClicked(string id, const toggle *data)
 	{
 	{
 		if (id == "switch")
 		if (id == "switch")
 		{
 		{
-			if (loaded)
+			if (data->value)
 				resources.unload();
 				resources.unload();
 			else
 			else
 				resources.load();
 				resources.load();
-
-			loaded = !loaded;
 		}
 		}
+	}
 
 
+	void clicked(string id)
+	{
 		if (id == "mt" || id == "mt_slow")
 		if (id == "mt" || id == "mt_slow")
 		{
 		{
 			resources.unload();
 			resources.unload();
 
 
 			spSprite sp = new Sprite;
 			spSprite sp = new Sprite;
 			sp->setName("loading");
 			sp->setName("loading");
-			sp->setAnimFrame(resourcesUI.getResAnim("loading"));
+			sp->setResAnim(resourcesUI.getResAnim("loading"));
 			sp->attachTo(ui);
 			sp->attachTo(ui);
 			sp->setAnchor(Vector2(0.5f, 0.5f));
 			sp->setAnchor(Vector2(0.5f, 0.5f));
 			sp->setPosition(getSize() - sp->getSize()/4);
 			sp->setPosition(getSize() - sp->getSize()/4);

+ 34 - 30
examples/Demo/src/TestMask.h

@@ -46,53 +46,57 @@ public:
 			arg_style = style);		
 			arg_style = style);		
 
 
 
 
+		const Test::toggle sm[] = {Test::toggle("hide mask", 0), Test::toggle("show mask", 1), };
+		addToggle("show_mask", sm, 2);
 
 
-		addButton("show_mask", "hide mask");
-		addButton("change_mask1", "change mask");
-		addButton("disable_mask", "disable mask");
-		addButton("pause", "pause");
+		const Test::toggle cm[] = {Test::toggle("change mask1", 0), Test::toggle("change mask2", 1), };
+		addToggle("change_mask", cm, 2);
+
+		const Test::toggle dm[] = {Test::toggle("disable mask", 0), Test::toggle("enable mask", 1), };
+		addToggle("disable_mask", dm, 2);
+
+		const Test::toggle pause[] = {Test::toggle("pause", 0), Test::toggle("resume", 1), };
+		addToggle("pause", pause, 2);
 	}
 	}
 
 
-	void clicked(string id)
+	void toggleClicked(string id, const toggle *t)
 	{
 	{
+		if (id == "show_mask")
+			_mask->setVisible(t->value != 0);
+
+		if (id == "disable_mask") 
+		{
+			if (t->value == 0)
+				_masked->setMask(0);
+			else
+				_masked->setMask(_mask);
+		}
+
 		if (id == "pause")
 		if (id == "pause")
 		{
 		{
 			spClock clock = getRoot()->getClock();
 			spClock clock = getRoot()->getClock();
-			if (!clock->getPauseCounter())
+			if (t->value == 0)
 				clock->pause();
 				clock->pause();
 			else
 			else
 				clock->resume();
 				clock->resume();
 		}
 		}
-		if (id == "show_mask")
-		{
-			_mask->setVisible(!_mask->getVisible());
-			if (_mask->getVisible())
-				updateText("show_mask", "hide mask");
-			else
-				updateText("show_mask", "show mask");
-		}
 
 
-		if (id == "change_mask1") 
+		if (id == "change_mask") 
 		{			
 		{			
-			_mask->addTween(TweenAnim(resources.getResAnim("anim")), 600, -1, false);
-		}
-
-
-		if (id == "disable_mask") 
-		{
-			if (_masked->getMask())
-			{
-				updateText("disable_mask", "enable mask");
-				_masked->setMask(0);
-			}
-			else
+			_mask->removeTweensByName("tweenanim");
+			switch(t->value)
 			{
 			{
-				updateText("disable_mask", "disable mask");
-				_masked->setMask(_mask);
-			}
+			case 1:
+				_mask->setResAnim(resources.getResAnim("logo2"));
+				break;
+			case 0:
+				_mask->addTween(TweenAnim(resources.getResAnim("anim")), 600, -1, false)->setName("tweenanim");
+				break;
+			}			
 		}
 		}
 	}
 	}
 
 
+
 	void doUpdate(const UpdateState &us)
 	void doUpdate(const UpdateState &us)
 	{
 	{
 		if (_lastSnow  + 40 < us.time)
 		if (_lastSnow  + 40 < us.time)

+ 9 - 14
examples/Demo/src/TestPerf.h

@@ -21,27 +21,22 @@ public:
 		addButton("scale0.01", "scale=0.01");
 		addButton("scale0.01", "scale=0.01");
 		addButton("scale0.2", "scale=0.2");
 		addButton("scale0.2", "scale=0.2");
 		addButton("scale0.5", "scale=0.5");
 		addButton("scale0.5", "scale=0.5");
-		addButton("driver", "driver=null");
+
+		toggle dr[]={toggle("driver=null", 0, new VideoDriverNull), toggle("driver=default", 0, 0)};
+		addToggle("driver", dr, 2);
 
 
 		content->setInputEnabled(false);
 		content->setInputEnabled(false);
 		content->setInputChildrenEnabled(false);
 		content->setInputChildrenEnabled(false);
 	}
 	}
 
 
-	void clicked(string id)
+	void toggleClicked(string id, const toggle *data)
 	{
 	{
 		if (id == "driver")
 		if (id == "driver")
-		{
-			if (content->driver)
-			{
-				delete content->driver;
-				content->driver = 0;
-			}
-			else
-				content->driver = new VideoDriverNull;
-
-			updateText(id, !content->driver ? "driver=null" : "driver=default");
-		}
+			content->driver = (IVideoDriver*)(data->data);
+	}
 
 
+	void clicked(string id)
+	{
 		if (id == "add")
 		if (id == "add")
 		{
 		{
 			int a = 500;
 			int a = 500;
@@ -49,7 +44,7 @@ public:
 			for (int i = 0; i < a; ++i)
 			for (int i = 0; i < a; ++i)
 			{
 			{
 				spSprite sprite = new Sprite;
 				spSprite sprite = new Sprite;
-				sprite->setAnimFrame(resources.getResAnim("anim"));
+				sprite->setResAnim(resources.getResAnim("anim"));
 				sprite->setAnchor(Vector2(0.5f, 0.5f));
 				sprite->setAnchor(Vector2(0.5f, 0.5f));
 				sprite->setScale(0.05f);
 				sprite->setScale(0.05f);
 				sprite->setPosition(scalar::randFloat(0, (float)getWidth()), scalar::randFloat(0, (float)getHeight()));
 				sprite->setPosition(scalar::randFloat(0, (float)getWidth()), scalar::randFloat(0, (float)getHeight()));

+ 3 - 1
examples/Demo/src/TestProgressBar.h

@@ -16,7 +16,7 @@ public:
 		//addButton("radial_ccw", "dir: radial_ccw");
 		//addButton("radial_ccw", "dir: radial_ccw");
 
 
 		bar = new ProgressBar(); 
 		bar = new ProgressBar(); 
-		bar->setAnimFrame(resources.getResAnim("logo2"));
+		bar->setResAnim(resources.getResAnim("logo2"));
 		//bar->setAnchor(Vector2(0.5f, 0.5f));
 		//bar->setAnchor(Vector2(0.5f, 0.5f));
 		bar->setPosition(getSize()/2);
 		bar->setPosition(getSize()/2);
 		//bar->setScale(2);
 		//bar->setScale(2);
@@ -42,10 +42,12 @@ public:
 		{			
 		{			
 			bar->setDirection(ProgressBar::dir_270);
 			bar->setDirection(ProgressBar::dir_270);
 		}
 		}
+		/*
 		if (id == "radial_ccw")
 		if (id == "radial_ccw")
 		{			
 		{			
 			bar->setDirection(ProgressBar::dir_radial_ccw);
 			bar->setDirection(ProgressBar::dir_radial_ccw);
 		}
 		}
+		*/
 		if (id == "radial_cw")
 		if (id == "radial_cw")
 		{			
 		{			
 			bar->setDirection(ProgressBar::dir_radial_cw);
 			bar->setDirection(ProgressBar::dir_radial_cw);

+ 3 - 2
examples/Demo/src/TestRender2Texture.h

@@ -10,7 +10,7 @@ public:
 
 
 	TestRender2Texture()
 	TestRender2Texture()
 	{
 	{
-		showPopup("touch to draw", 100000);
+		notify("touch to draw", 100000);
 
 
 		color = Color(255,255,255,32);
 		color = Color(255,255,255,32);
 
 
@@ -55,7 +55,7 @@ public:
 		Point size = content->getSize().cast<Point>();
 		Point size = content->getSize().cast<Point>();
 
 
 		r.initCoordinateSystem(size.x, size.y, true);
 		r.initCoordinateSystem(size.x, size.y, true);
-
+		
 		Rect vp(Point(0, 0), size);
 		Rect vp(Point(0, 0), size);
 
 
 		r.begin(texture, vp, 0);
 		r.begin(texture, vp, 0);
@@ -64,6 +64,7 @@ public:
 		const Diffuse &df = frame.getDiffuse();
 		const Diffuse &df = frame.getDiffuse();
 		r.setDiffuse(df);
 		r.setDiffuse(df);
 		r.setPrimaryColor(color);
 		r.setPrimaryColor(color);
+		r.setBlendMode(blend_premultiplied_alpha);
 		float pressure =  te->pressure;
 		float pressure =  te->pressure;
 		//log::messageln("pressure %.2f", pressure);
 		//log::messageln("pressure %.2f", pressure);
 		//pressure = pressure * pressure;
 		//pressure = pressure * pressure;

+ 113 - 0
examples/Demo/src/TestSliding.h

@@ -0,0 +1,113 @@
+#pragma once
+#include "test.h"
+#include "ClipRectActor.h"
+#include "PointerState.h"
+#include "SlidingActor.h"
+
+class TestSliding: public Test
+{
+public:
+	spSlidingActor _sliding;
+	bool _snapEnabled;
+	TestSliding()
+	{	
+		_snapEnabled = false;
+
+		spSlidingActor sliding = new SlidingActor();
+		sliding->addEventListener(SlidingActor::SlidingEvent::BEGIN, CLOSURE(this,  &TestSliding::slideBegin));
+		sliding->addEventListener(SlidingActor::SlidingEvent::SLIDING, CLOSURE(this,  &TestSliding::sliding));
+		sliding->addEventListener(SlidingActor::SlidingEvent::END, CLOSURE(this,  &TestSliding::slideEnd));
+		
+
+		sliding->setSize(getWidth()/3 * 2, getHeight()/3 * 2);
+
+
+		spColorRectSprite content = new ColorRectSprite();
+		content->setSize(sliding->getWidth(), 2000);
+		content->setColor(Color(200,200,200,255));
+		for (int i = 0; i < 20; i+=2)
+		{
+			spColorRectSprite c = initActor(new ColorRectSprite,
+				arg_size = Vector2(content->getWidth(), 100),
+				arg_color = Color(164,164,164,255),
+				arg_y = i * 100.0f,
+				arg_attachTo = content);
+
+			spButton button = initActor(new Button, 
+				arg_resAnim = resourcesUI.getResAnim("button"),
+				arg_attachTo = c);
+			button->addEventListener(TouchEvent::CLICK, CLOSURE(this, &TestSliding::testClick));
+		}
+
+		spTextActor title = initActor(new TextActor, 
+			arg_text = "Sliding demo", 
+			arg_w = content->getWidth(),
+			arg_vAlign = TextStyle::VALIGN_TOP,
+			arg_hAlign = TextStyle::HALIGN_CENTER,
+			arg_font = resourcesUI.getResFont("big")->getFont(),
+			arg_color = Color(0xFF0000ff),
+			arg_attachTo = content);
+		
+		sliding->setContent(content);
+		sliding->setPosition(getSize()/2 - sliding->getSize()/2);
+		sliding->attachTo(this->content);
+
+		_sliding = sliding;
+
+		toggle tl[] = {toggle("lock", 0), toggle("unlock", 1)};
+		addToggle("lock", tl, 2);
+
+		toggle ts[] = {toggle("enable snap", 0), toggle("disable snap", 1)};
+		addToggle("snap", ts, 2);
+	}
+
+
+	void toggleClicked(string id, const toggle *data)
+	{
+		if (id == "lock")
+			_sliding->setLocked(data->value == 0);
+		if (id == "snap")
+		{
+			_snapEnabled = data->value == 0;
+		}
+	}
+
+	void slideBegin(Event *event)
+	{
+		notify("slideBegin");
+		SlidingActor::SlidingEvent *sd = safeCast<SlidingActor::SlidingEvent *>(event);
+	}
+
+	void slideEnd(Event *event)
+	{
+		notify("slideEnd");
+
+		if (!_snapEnabled)
+			return;
+
+		//snap to  grid
+		SlidingActor::SlidingEvent *sd = safeCast<SlidingActor::SlidingEvent *>(event);
+		spActor content = _sliding->getContent();
+		float y = content->getY();
+		y = int(y / 100) * 100.0f;
+		Vector2 dest(content->getX(), y);
+		content->addTween(Actor::TweenPosition(dest), 100);
+	}
+
+	void sliding(Event *event)
+	{
+		/*
+		//snap
+		SlidingActor::SlidingEvent* sd = safeCast<SlidingActor::SlidingEvent *>(event);
+		if (sd->speed.sqlength() < 2500)
+		{
+			sd->speed = Vector2(0,0);
+		}
+		*/
+	}
+
+	void testClick(Event *event)
+	{
+		notify("clicked");
+	}
+};

+ 1 - 1
examples/Demo/src/TestTexel2Pixel.h

@@ -8,7 +8,7 @@ public:
 		spSprite sprite = new Sprite;			
 		spSprite sprite = new Sprite;			
 		Vector2 pos(0, 0);
 		Vector2 pos(0, 0);
 		sprite->setPosition(pos);
 		sprite->setPosition(pos);
-		sprite->setAnimFrame(resources.getResAnim("t2p"));
+		sprite->setResAnim(resources.getResAnim("t2p"));
 		sprite->attachTo(content);
 		sprite->attachTo(content);
 		float scale = 1.0f/getRoot()->getScaleX();
 		float scale = 1.0f/getRoot()->getScaleX();
 		sprite->setScale(scale);
 		sprite->setScale(scale);

+ 2 - 2
examples/Demo/src/TestText.h

@@ -66,7 +66,7 @@ public:
 
 
 		spriteTextRect = new ColorRectSprite();
 		spriteTextRect = new ColorRectSprite();
 		spriteTextRect->attachTo(bg);
 		spriteTextRect->attachTo(bg);
-		spriteTextRect->setColor(Color(255, 0, 0, 80));
+		spriteTextRect->setColor(Color(Color::Red, 80));
 
 
 		text = new TextActor;
 		text = new TextActor;
 		text->attachTo(bg);
 		text->attachTo(bg);
@@ -79,7 +79,7 @@ public:
 
 
 		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		{
 		{
-			tests.push_back(text_test( "<div c='00ff00'>Scaled Font test<br/></div> The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. ", TextStyle::HALIGN_CENTER, TextStyle::VALIGN_MIDDLE, size, true, 10 * h  + 20));
+			tests.push_back(text_test( "<div c='00ff00'>Scaled Font test<br/></div> The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. ", TextStyle::HALIGN_CENTER, TextStyle::VALIGN_MIDDLE, size, true, 5 * h  + 20));
 		}
 		}
 
 
 
 

+ 2 - 2
examples/Demo/src/TestTextureFormat.h

@@ -33,12 +33,12 @@ public:
 		spSprite sp = new Sprite;
 		spSprite sp = new Sprite;
 		sp->attachTo(content);
 		sp->attachTo(content);
 
 
-		sp->setAnimFrame(res);
+		sp->setResAnim(res);
 		sp->setScale(getWidth()/(float)sp->getWidth());
 		sp->setScale(getWidth()/(float)sp->getWidth());
 
 
 		sp = new Sprite;
 		sp = new Sprite;
 		sp->attachTo(content);
 		sp->attachTo(content);
-		sp->setAnimFrame(resources.getResAnim("logo2" + prefix));
+		sp->setResAnim(resources.getResAnim("logo2" + prefix));
 		sp->setPosition(getSize()/2);
 		sp->setPosition(getSize()/2);
 	}
 	}
 
 

+ 7 - 7
examples/Demo/src/TestTweens.h

@@ -29,8 +29,8 @@ public:
 
 
 		_sprite = new Sprite();
 		_sprite = new Sprite();
 		_sprite->attachTo(content);
 		_sprite->attachTo(content);
-		_sprite->setAnchor(Vector2(0.5f, 0.5f));
-		_sprite->setAnimFrame(resources.getResAnim("anim"));
+		_sprite->setAnchor(0.5f, 0.5f);
+		_sprite->setResAnim(resources.getResAnim("anim"));
 		_sprite->setPosition(getWidth()/2.0f, getHeight()/2);		
 		_sprite->setPosition(getWidth()/2.0f, getHeight()/2);		
 
 
 		updateEase();
 		updateEase();
@@ -40,7 +40,7 @@ public:
 	{
 	{
 		spColorRectSprite bg = new ColorRectSprite();
 		spColorRectSprite bg = new ColorRectSprite();
 		bg->setSize(230, 230);
 		bg->setSize(230, 230);
-		bg->setColor(Color(128, 128, 128, 255));
+		bg->setColor(Color::Gray);
 
 
 		spColorRectSprite parent = new ColorRectSprite();
 		spColorRectSprite parent = new ColorRectSprite();
 		parent->setSize(200, 200);
 		parent->setSize(200, 200);
@@ -50,14 +50,14 @@ public:
 		while (f <= 1.001f)
 		while (f <= 1.001f)
 		{
 		{
 			spColorRectSprite cr = new ColorRectSprite();
 			spColorRectSprite cr = new ColorRectSprite();
-			cr->setSize(Point(2, 2));
-			cr->setColor(Color(255, 0, 0, 255));
+			cr->setSize(2, 2);
+			cr->setColor(Color::Red);
 			parent->addChild(cr);
 			parent->addChild(cr);
 
 
 			float x = f * parent->getWidth();
 			float x = f * parent->getWidth();
 			float y = (1.0f - Tween::calcEase(ease, f)) * parent->getHeight();
 			float y = (1.0f - Tween::calcEase(ease, f)) * parent->getHeight();
 
 
-			cr->setPosition(Vector2(x - 1, y - 1));
+			cr->setPosition(x - 1, y - 1);
 
 
 			f += 0.005f;
 			f += 0.005f;
 		}
 		}
@@ -83,7 +83,7 @@ public:
 
 
 	void tweenDone(Event *event)
 	void tweenDone(Event *event)
 	{
 	{
-		showPopup("TweenDone");
+		notify("TweenDone");
 	}
 	}
 
 
 	void _addTween(spTween tween)
 	void _addTween(spTween tween)

+ 4 - 4
examples/Demo/src/example.cpp

@@ -9,7 +9,7 @@
 #include "TestText.h"
 #include "TestText.h"
 #include "TestTextureFormat.h"
 #include "TestTextureFormat.h"
 #include "TestTexel2Pixel.h"
 #include "TestTexel2Pixel.h"
-#include "TestComplexDrag.h"
+#include "TestSliding.h"
 #include "TestProgressBar.h"
 #include "TestProgressBar.h"
 #include "TestBox9Sprite.h"
 #include "TestBox9Sprite.h"
 #include "TestClipRect.h"
 #include "TestClipRect.h"
@@ -50,7 +50,7 @@ public:
 		addButton("texture_format", "Textures Format");
 		addButton("texture_format", "Textures Format");
 		addButton("r2t", "Render to Texture");	
 		addButton("r2t", "Render to Texture");	
 		addButton("t2p", "Texel to Pixel");
 		addButton("t2p", "Texel to Pixel");
-		addButton("complex_drag", "Complex Drag");		
+		addButton("sliding", "Sliding Actor");		
 		addButton("box9sprite", "Box9 Sprite");		
 		addButton("box9sprite", "Box9 Sprite");		
 		addButton("cliprect", "ClipRect Actor");		
 		addButton("cliprect", "ClipRect Actor");		
 		addButton("usershader", "User Shader");		
 		addButton("usershader", "User Shader");		
@@ -100,9 +100,9 @@ public:
 			getRoot()->addChild(new TestTextureFormat);
 			getRoot()->addChild(new TestTextureFormat);
 		}
 		}
 
 
-		if (id == "complex_drag")
+		if (id == "sliding")
 		{
 		{
-			getRoot()->addChild(new TestComplexDrag);
+			getRoot()->addChild(new TestSliding);
 		}
 		}
 
 
 		if (id == "t2p")
 		if (id == "t2p")

+ 87 - 24
examples/Demo/src/test.cpp

@@ -1,6 +1,19 @@
 #include "test.h"
 #include "test.h"
 #include "oxygine-framework.h"
 #include "oxygine-framework.h"
 
 
+class Toggle: public Button
+{
+public:
+	Toggle(const Test::toggle *t, int num):_current(0)
+	{
+		_items.assign(t, t + num);
+	}
+
+	int _current;
+
+	vector<Test::toggle> _items;
+};
+
 spTextActor createText(string txt)
 spTextActor createText(string txt)
 {
 {
 	spTextActor text = new TextActor();
 	spTextActor text = new TextActor();
@@ -18,9 +31,8 @@ spTextActor createText(string txt)
 	return text;
 	return text;
 }
 }
 
 
-spButton createButtonHelper(string txt, EventCallback cb)
+spButton createButtonHelper(spButton button, string txt, EventCallback cb)
 {
 {
-	spButton button = new Button();
 	button->setPriority(10);
 	button->setPriority(10);
 	//button->setName(id);
 	//button->setName(id);
 	button->setResAnim(resourcesUI.getResAnim("button"));
 	button->setResAnim(resourcesUI.getResAnim("button"));
@@ -51,10 +63,12 @@ Test::Test()
 
 
 	if (_tests)
 	if (_tests)
 	{
 	{
-		spButton button = createButtonHelper("back", CLOSURE(this, &Test::back));
+		spButton button = createButtonHelper(new Button, "back", CLOSURE(this, &Test::back));
 		button->setY(getHeight() - button->getHeight());
 		button->setY(getHeight() - button->getHeight());
 		ui->addChild(button);
 		ui->addChild(button);
 	}	
 	}	
+
+	memset(_notifies, 0, sizeof(_notifies));
 }
 }
 
 
 
 
@@ -63,21 +77,38 @@ Test::~Test()
 }
 }
 
 
 
 
-void Test::addButton(string id, string txt)
+spButton Test::addButton(string id, string txt)
 {
 {
-	EventCallback cb = CLOSURE(this, &Test::_clicked);
+	spButton button = createButtonHelper(new Button, txt, CLOSURE(this, &Test::_clicked));
+	initActor(button.get(), 
+		arg_name = id, 
+		arg_attachTo = ui,
+		arg_anchor = Vector2(0.5f, 0.0f),
+		arg_pos = Vector2(_x, _y));
+
+	_y += button->getHeight() + 2.0f;
+
+	if (_y + button->getHeight() >= getHeight())
+	{
+		_y = 0;
+		_x += button->getWidth() + 70;
+	}
+
+	return button;
+}
 
 
-	spButton button = createButtonHelper(txt, cb);
-	button->setName(id);
-	//add it as child to current actor
-	ui->addChild(button);
-	button->setAnchor(Vector2(0.5f, 0.0f));
+void Test::addToggle(string id, const toggle *t, int num)
+{
+	spButton button = createButtonHelper(new Toggle(t, num), t[0].text, CLOSURE(this, &Test::_toggleClicked));
+	initActor(button.get(), 
+		arg_name = id, 
+		arg_attachTo = ui,
+		arg_anchor = Vector2(0.5f, 0.0f),
+		arg_pos = Vector2(_x, _y));
 
 
-	//center button at screen		
-	button->setPosition(_x, _y);
 	_y += button->getHeight() + 2.0f;
 	_y += button->getHeight() + 2.0f;
 
 
-	if (_y  + button->getHeight() >= getHeight())
+	if (_y + button->getHeight() >= getHeight())
 	{
 	{
 		_y = 0;
 		_y = 0;
 		_x += button->getWidth() + 70;
 		_x += button->getWidth() + 70;
@@ -96,16 +127,24 @@ void Test::updateText(string id, string txt)
 	t->setText(txt);
 	t->setText(txt);
 }
 }
 
 
-void Test::clicked(string id)
-{
-
-}
 
 
 void Test::_clicked(Event *event)
 void Test::_clicked(Event *event)
 {
 {
 	clicked(event->currentTarget->getName());
 	clicked(event->currentTarget->getName());
 }
 }
 
 
+void Test::_toggleClicked(Event *event)
+{
+	Toggle *t = safeCast<Toggle*>(event->currentTarget.get());
+
+	toggleClicked(event->currentTarget->getName(), &t->_items[t->_current]);
+
+	t->_current = (t->_current + 1) % t->_items.size();
+	spTextActor ta = safeSpCast<TextActor>(t->getFirstChild());
+	const toggle *data = &t->_items[t->_current];
+	ta->setText(data->text);
+}
+
 
 
 void Test::back(Event *event)
 void Test::back(Event *event)
 {
 {
@@ -114,24 +153,48 @@ void Test::back(Event *event)
 }
 }
 
 
 
 
-void Test::showPopup(string txt, int time)
+void Test::notify(string txt, int time)
 {
 {
-	spSprite sprite = new Sprite();
+	int N = 0;
+	for (size_t i = 0; i < MAX_NOTIFIES; ++i)
+	{
+		if (_notifies[i])
+			continue;
+		N = i;
+		break;
+	}
+
+	_notifies[N] += 1;
+
+
+	spColorRectSprite sprite = new ColorRectSprite();
+	sprite->setUserData((void*)N);
 	sprite->setPriority(10);
 	sprite->setPriority(10);
-	sprite->setAnimFrame(resourcesUI.getResAnim("button"));
+	Color colors[] = {Color(0xD2691EFF), Color(0x7FFFD4FF), Color(0xDC143CFF), Color(0xADFF2FFF), };
+	Color c = colors[rand() % 4];
+	sprite->setColor(c);
+	sprite->setSize(100, 30);
+	//sprite->setAnimFrame(resourcesUI.getResAnim("button"));
 	sprite->setAlpha(0);
 	sprite->setAlpha(0);
 
 
 	spTweenQueue tq = new TweenQueue;
 	spTweenQueue tq = new TweenQueue;
-	tq->add(Actor::TweenAlpha(255), 300, 1, false, 0, Tween::ease_outExpo);
-	tq->add(Actor::TweenAlpha(200), 300, time / 300, true);
-	tq->add(Actor::TweenAlpha(0), 300);
+	tq->add(Actor::TweenAlpha(255), 300, 1, false, 0, Tween::ease_inExpo);
+	tq->add(Actor::TweenAlpha(0), 300, 1, false, 1200);
 	tq->setDetachActor(true);
 	tq->setDetachActor(true);
+	tq->setDoneCallback(CLOSURE(this, &Test::notifyDone));
 
 
 	sprite->addTween(tq);
 	sprite->addTween(tq);
 	sprite->attachTo(ui);
 	sprite->attachTo(ui);
-	sprite->setPosition(0.0f, getHeight() - 150.0f);
+	sprite->setPosition(2.0f, getHeight() - 100.0f - N * sprite->getHeight() * 1.1f);
 
 
 	spTextActor text = createText(txt);
 	spTextActor text = createText(txt);
 	text->attachTo(sprite);
 	text->attachTo(sprite);
+	text->setColor(Color::Black);
 	text->setPosition(sprite->getSize()/2);
 	text->setPosition(sprite->getSize()/2);
+}
+
+void Test::notifyDone(Event *ev)
+{
+	int N = (int)ev->currentTarget->getUserData();
+	_notifies[N] -= 1;
 }
 }

+ 20 - 4
examples/Demo/src/test.h

@@ -7,7 +7,7 @@ using namespace oxygine;
 
 
 
 
 
 
-spButton createButtonHelper(string txt, EventCallback cb);
+spButton createButtonHelper(spButton, string txt, EventCallback cb);
 
 
 class Content: public Actor
 class Content: public Actor
 {
 {
@@ -33,21 +33,37 @@ class Test: public Actor
 public:
 public:
 	Test();
 	Test();
 	~Test();
 	~Test();
+
+	struct toggle
+	{
+		string text;
+		int value;
+		const void *data;
+		toggle(){}
+		toggle(const char *text_, int v_ = 0, const void *data_ = 0):text(text_), value(v_), data(data_){}
+
+	};
 	
 	
-	void addButton(string id, string txt);
+	spButton addButton(string id, string txt);
+	void addToggle(string id, const toggle *t, int num);
 	void updateText(string id, string txt);
 	void updateText(string id, string txt);
-	virtual void clicked(string id);
+	virtual void clicked(string id){}
+	virtual void toggleClicked(string id, const toggle *data){}
 	void _clicked(Event *event);
 	void _clicked(Event *event);
+	void _toggleClicked(Event *event);
 	void back(Event *event);
 	void back(Event *event);
 
 
-	void showPopup(string text, int time = 400);
+	void notify(string text, int time = 400);
 
 
 protected:
 protected:
+	void notifyDone(Event *ev);
 	
 	
 	float _x;
 	float _x;
 	float _y;
 	float _y;
 	spActor ui;
 	spActor ui;
 	Content *content;
 	Content *content;
+	enum {MAX_NOTIFIES = 6};
+	int _notifies[MAX_NOTIFIES];
 };
 };
 
 
 extern spActor _tests;
 extern spActor _tests;

+ 12 - 12
examples/Demo/win32/HelloWorld_vs2010.vcxproj

@@ -80,6 +80,17 @@
       <AdditionalDependencies>glew32.lib;libjpeg.lib;libpng.lib;libzlib.lib;opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalDependencies>glew32.lib;libjpeg.lib;libpng.lib;libzlib.lib;opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\..\SDL\VisualC\SDLmain\SDLmain_VS2010.vcxproj">
+      <Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\SDL\VisualC\SDL\SDL_VS2010.vcxproj">
+      <Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\oxygine\SDL\win32\oxygine_vs2010.vcxproj">
+      <Project>{52411305-cfe1-4fa8-9885-5729bfc816cf}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\src\entry_point.cpp" />
     <ClCompile Include="..\src\entry_point.cpp" />
     <ClCompile Include="..\src\example.cpp" />
     <ClCompile Include="..\src\example.cpp" />
@@ -90,30 +101,19 @@
     <ClInclude Include="..\src\test.h" />
     <ClInclude Include="..\src\test.h" />
     <ClInclude Include="..\src\TestBox9Sprite.h" />
     <ClInclude Include="..\src\TestBox9Sprite.h" />
     <ClInclude Include="..\src\TestClipRect.h" />
     <ClInclude Include="..\src\TestClipRect.h" />
-    <ClInclude Include="..\src\TestComplexDrag.h" />
     <ClInclude Include="..\src\TestDrag.h" />
     <ClInclude Include="..\src\TestDrag.h" />
     <ClInclude Include="..\src\TestManageRes.h" />
     <ClInclude Include="..\src\TestManageRes.h" />
     <ClInclude Include="..\src\TestMask.h" />
     <ClInclude Include="..\src\TestMask.h" />
     <ClInclude Include="..\src\TestPerf.h" />
     <ClInclude Include="..\src\TestPerf.h" />
     <ClInclude Include="..\src\TestProgressBar.h" />
     <ClInclude Include="..\src\TestProgressBar.h" />
     <ClInclude Include="..\src\TestRender2Texture.h" />
     <ClInclude Include="..\src\TestRender2Texture.h" />
+    <ClInclude Include="..\src\TestSliding.h" />
     <ClInclude Include="..\src\TestTexel2Pixel.h" />
     <ClInclude Include="..\src\TestTexel2Pixel.h" />
     <ClInclude Include="..\src\TestText.h" />
     <ClInclude Include="..\src\TestText.h" />
     <ClInclude Include="..\src\TestTextureFormat.h" />
     <ClInclude Include="..\src\TestTextureFormat.h" />
     <ClInclude Include="..\src\TestTweens.h" />
     <ClInclude Include="..\src\TestTweens.h" />
     <ClInclude Include="..\src\TestUserShader.h" />
     <ClInclude Include="..\src\TestUserShader.h" />
   </ItemGroup>
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\..\..\SDL\VisualC\SDLmain\SDLmain_VS2010.vcxproj">
-      <Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
-    </ProjectReference>
-    <ProjectReference Include="..\..\..\..\SDL\VisualC\SDL\SDL_VS2010.vcxproj">
-      <Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
-    </ProjectReference>
-    <ProjectReference Include="..\..\..\oxygine\SDL\win32\oxygine_vs2010.vcxproj">
-      <Project>{52411305-cfe1-4fa8-9885-5729bfc816cf}</Project>
-    </ProjectReference>
-  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
   </ImportGroup>

+ 6 - 6
examples/Demo/win32/HelloWorld_vs2010.vcxproj.filters

@@ -38,15 +38,15 @@
     <ClInclude Include="..\src\TestClipRect.h">
     <ClInclude Include="..\src\TestClipRect.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="..\src\TestComplexDrag.h">
-      <Filter>Source Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\src\TestDrag.h">
     <ClInclude Include="..\src\TestDrag.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
     <ClInclude Include="..\src\TestManageRes.h">
     <ClInclude Include="..\src\TestManageRes.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="..\src\TestMask.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\TestPerf.h">
     <ClInclude Include="..\src\TestPerf.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
@@ -56,6 +56,9 @@
     <ClInclude Include="..\src\TestRender2Texture.h">
     <ClInclude Include="..\src\TestRender2Texture.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="..\src\TestSliding.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\TestTexel2Pixel.h">
     <ClInclude Include="..\src\TestTexel2Pixel.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
@@ -68,9 +71,6 @@
     <ClInclude Include="..\src\TestTweens.h">
     <ClInclude Include="..\src\TestTweens.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="..\src\TestMask.h">
-      <Filter>Source Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\src\TestUserShader.h">
     <ClInclude Include="..\src\TestUserShader.h">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClInclude>
     </ClInclude>

+ 1 - 1
examples/DemoBox2D/src/Box2DDebugDraw.cpp

@@ -54,7 +54,7 @@ void Box2DDraw::doRender(const RenderState &rs)
 	glBlendFunc  (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	glBlendFunc  (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	_world->DrawDebugData();
 	_world->DrawDebugData();
 	_world->SetDebugDraw(0);
 	_world->SetDebugDraw(0);
-	rs.renderer->getDriver()->setDefaultSettings();	
+	rs.renderer->resetSettings();
 }
 }
 
 
 void Box2DDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
 void Box2DDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)

+ 1 - 1
examples/DemoBox2D/src/example.cpp

@@ -118,7 +118,7 @@ public:
 
 
 		//show click pos
 		//show click pos
 		spSprite sprite = new Sprite();		
 		spSprite sprite = new Sprite();		
-		sprite->setAnimFrame(gameResources.getResAnim("circle"));
+		sprite->setResAnim(gameResources.getResAnim("circle"));
 		sprite->setColor(Color(0xff00ffff));
 		sprite->setColor(Color(0xff00ffff));
 		sprite->setScale(0.2f);
 		sprite->setScale(0.2f);
 		sprite->setPosition(te->localPosition);
 		sprite->setPosition(te->localPosition);

+ 2 - 2
examples/GameTemplate/src/GameActor.cpp

@@ -21,7 +21,7 @@ GameActor::GameActor()
 	instance = this;
 	instance = this;
 	_actor->setInputEnabled(false);
 	_actor->setInputEnabled(false);
 
 
-	_actor->setSize(Point(480, 320));
+	_actor->setSize(480, 320);
 
 
 
 
 	spClock clock = new Clock();
 	spClock clock = new Clock();
@@ -67,7 +67,7 @@ void GameActor::preShowing()
 void GameActor::postShowing()
 void GameActor::postShowing()
 {	
 {	
 	spSprite go = new Sprite();
 	spSprite go = new Sprite();
-	go->setAnimFrame(gameResources.getResAnim("go"));
+	go->setResAnim(gameResources.getResAnim("go"));
 	go->setAnchor(Vector2(0.5f, 0.5f));
 	go->setAnchor(Vector2(0.5f, 0.5f));
 	go->setScale(Vector2(2.0f, 2.0f));	
 	go->setScale(Vector2(2.0f, 2.0f));	
 	go->setPosition(virtualSize/2);
 	go->setPosition(virtualSize/2);

+ 1 - 1
examples/GameTemplate/src/MainMenu.cpp

@@ -54,7 +54,7 @@ MainMenu::MainMenu()
 
 
 
 
 	spSprite bg = new Sprite();
 	spSprite bg = new Sprite();
-	bg->setAnimFrame(gameResources.getResAnim("bg"));
+	bg->setResAnim(gameResources.getResAnim("bg"));
 	_actor->addChild(bg);
 	_actor->addChild(bg);
 	
 	
 
 

+ 18 - 1
oxygine/src/Actor.cpp

@@ -102,7 +102,7 @@ namespace oxygine
 		
 		
 		if (__name && __name->size())
 		if (__name && __name->size())
 		{
 		{
-			stream << " name='" << div(*__name, Color(0xff0000ff)) << "'";			
+			stream << " name='" << div(*__name, Color::Red) << "'";			
 		}
 		}
 
 
 		stream << " id='" << getObjectID()<< "'";
 		stream << " id='" << getObjectID()<< "'";
@@ -736,11 +736,13 @@ namespace oxygine
 
 
 	void Actor::attachTo(spActor parent)
 	void Actor::attachTo(spActor parent)
 	{
 	{
+		OX_ASSERT(parent != this);
 		attachTo(parent.get());
 		attachTo(parent.get());
 	}
 	}
 
 
 	void Actor::attachTo(Actor *parent)
 	void Actor::attachTo(Actor *parent)
 	{
 	{
+		OX_ASSERT(parent != this);
 		OX_ASSERT(parent);
 		OX_ASSERT(parent);
 		if (!parent)
 		if (!parent)
 			return;
 			return;
@@ -1050,6 +1052,21 @@ namespace oxygine
 		}
 		}
 	}
 	}
 
 
+	void Actor::removeTweensByName(const string &name)
+	{
+		spTween t = _tweens._first;
+		while (t)
+		{			
+			spTween c = t;
+			t = t->getNextSibling();
+
+			if (c->isName(name))
+			{
+				removeTween(c);
+			}
+		}
+	}
+
 	Vector2 convert_global2local_(Actor *child, Actor *parent, Vector2 pos)
 	Vector2 convert_global2local_(Actor *child, Actor *parent, Vector2 pos)
 	{
 	{
 		if (child->getParent() && child->getParent() != parent)
 		if (child->getParent() && child->getParent() != parent)

+ 18 - 14
oxygine/src/Actor.h

@@ -208,6 +208,7 @@ namespace oxygine
 		{return addTween(createTween(gs, duration, loops, twoSides, delay, ease));}
 		{return addTween(createTween(gs, duration, loops, twoSides, delay, ease));}
 
 
 		void removeTween(spTween);
 		void removeTween(spTween);
+		void removeTweensByName(const string &name);
 		/**remove all tweens and call completes them if callComplete == true*/
 		/**remove all tweens and call completes them if callComplete == true*/
 		void removeTweens(bool callComplete = false);
 		void removeTweens(bool callComplete = false);
 		
 		
@@ -273,24 +274,27 @@ namespace oxygine
 		Vector2 _size;
 		Vector2 _size;
 		float	_rotation;
 		float	_rotation;
 
 
-		enum flags
-		{
-			flag_anchorInPixels = 0x01,
-			flag_visible = 0x02,
-			flag_inputEnabled = 0x04,
-			flag_childrenRelative = 0x08,
-			flag_transformDirty = 0x10,
-			flag_transformInvertDirty = 0x20,
-			flag_inputChildrenEnabled = 0x40,
-			flag_cull = 0x80,
-			flag_fastTransform = 0x100,
-		};
 
 
+	protected:	
 		mutable unsigned short _flags;
 		mutable unsigned short _flags;
 		mutable Renderer::transform	_transform;
 		mutable Renderer::transform	_transform;
 		mutable Renderer::transform	_transformInvert;
 		mutable Renderer::transform	_transformInvert;
 
 
-	protected:		
+		enum flags
+		{
+			flag_anchorInPixels			= 1,
+			flag_visible				= 1 << 1,
+			flag_inputEnabled			= 1 << 2,
+			flag_childrenRelative		= 1 << 3,
+			flag_transformDirty			= 1 << 4,
+			flag_transformInvertDirty	= 1 << 5,
+			flag_inputChildrenEnabled	= 1 << 6,
+			flag_cull					= 1 << 7,
+			flag_fastTransform			= 1 << 8,
+			flag_last					= flag_fastTransform
+		};
+
+
 		unsigned char	_alpha;
 		unsigned char	_alpha;
 		char	_extendedIsOn;
 		char	_extendedIsOn;
 
 
@@ -334,7 +338,7 @@ namespace oxygine
 	public:
 	public:
 		typedef Actor type;
 		typedef Actor type;
 
 
-		void init(Actor &, bool rel){}
+		void init(Actor &){}
 		void update(Actor &, float p, const UpdateState &us){}
 		void update(Actor &, float p, const UpdateState &us){}
 	};
 	};
 }
 }

+ 8 - 9
oxygine/src/DebugActor.cpp

@@ -101,13 +101,13 @@ namespace oxygine
 		st.font = resSystem->getResFont("system")->getFont();
 		st.font = resSystem->getResFont("system")->getFont();
 		st.vAlign = TextStyle::VALIGN_TOP;
 		st.vAlign = TextStyle::VALIGN_TOP;
 		//st.color = Color(rand()%255, rand()%255, rand()%255, 255);
 		//st.color = Color(rand()%255, rand()%255, rand()%255, 255);
-		st.color = Color(0,0,0,255);
+		st.color = Color(Color::Black, 255);
 		st.multiline = true;
 		st.multiline = true;
 		setWidth(230);
 		setWidth(230);
 		setHeight(45);
 		setHeight(45);
 
 
 		_bg = new ColorRectSprite;
 		_bg = new ColorRectSprite;
-		_bg->setColor(Color(255, 255, 255, 64));
+		_bg->setColor(Color(Color::White, 64));
 		_bg->setSize(getSize());
 		_bg->setSize(getSize());
 		_bg->setInputEnabled(false);
 		_bg->setInputEnabled(false);
 		addChild(_bg);
 		addChild(_bg);
@@ -211,11 +211,10 @@ namespace oxygine
 			getRoot()->removeEventListeners(this);
 			getRoot()->removeEventListeners(this);
 	}
 	}
 
 
+	extern IVideoDriver::Stats _videoStats;
+
 	void DebugActor::doUpdate(const UpdateState &us)
 	void DebugActor::doUpdate(const UpdateState &us)
 	{
 	{
-		int batches = Renderer::statsPrev.batches;
-		int triangles = Renderer::statsPrev.triangles;
-
 		static int fps = 0;
 		static int fps = 0;
 		++_frames;
 		++_frames;
 		if (_frames > 50)
 		if (_frames > 50)
@@ -244,7 +243,7 @@ namespace oxygine
 #ifdef OXYGINE_DEBUG_OBJECTS
 #ifdef OXYGINE_DEBUG_OBJECTS
 		s << "objects=" << (int)__objects.size() << endl;
 		s << "objects=" << (int)__objects.size() << endl;
 #endif
 #endif
-		s << "batches="<< batches << " triangles=" << triangles << endl;
+		s << "batches="<< _videoStats.batches << " triangles=" << _videoStats.triangles << endl;
 		s << "update=" << getRoot()->_statUpdate << "ms ";
 		s << "update=" << getRoot()->_statUpdate << "ms ";
 		s << "render=" << getRoot()->_statRender << "ms ";
 		s << "render=" << getRoot()->_statRender << "ms ";
 		s << "textures=" << NativeTexture::created << " ";
 		s << "textures=" << NativeTexture::created << " ";
@@ -287,10 +286,10 @@ namespace oxygine
 	void DebugActor::render( RenderState const& parentRenderState )
 	void DebugActor::render( RenderState const& parentRenderState )
 	{
 	{
 		parentRenderState.renderer->drawBatch();
 		parentRenderState.renderer->drawBatch();
-		Renderer::Stats copy = Renderer::statsCurrent;
+		parentRenderState.renderer->getDriver()->setDebugStats(false);
 		Actor::render(parentRenderState);
 		Actor::render(parentRenderState);
 		parentRenderState.renderer->drawBatch();
 		parentRenderState.renderer->drawBatch();
-		Renderer::statsCurrent = copy;
+		parentRenderState.renderer->getDriver()->setDebugStats(true);
 	}
 	}
 
 
 	void DebugActor::showTexel2PixelErrors(bool show)
 	void DebugActor::showTexel2PixelErrors(bool show)
@@ -333,7 +332,7 @@ namespace oxygine
 		//cr->setAlpha(100);
 		//cr->setAlpha(100);
 		cr->setColor(Color(rand()%255, rand()%255, rand()%255, 0));
 		cr->setColor(Color(rand()%255, rand()%255, rand()%255, 0));
 		cr->setSize(actor->getSize());
 		cr->setSize(actor->getSize());
-		cr->addTween(ColorRectSprite::TweenColor(Color(255,255,255,200)), 700, 1, true, 0, Tween::ease_inCubic)->setDetachActor(true);
+		cr->addTween(ColorRectSprite::TweenColor(Color(Color::White, 200)), 700, 1, true, 0, Tween::ease_inCubic)->setDetachActor(true);
 		actor->addChild(cr);
 		actor->addChild(cr);
 		string dmp = actor->dump(0);
 		string dmp = actor->dump(0);
 		log::messageln("touched actor:\n%s", dmp.c_str());
 		log::messageln("touched actor:\n%s", dmp.c_str());

+ 1 - 0
oxygine/src/Draggable.h

@@ -21,6 +21,7 @@ namespace oxygine
 
 
 		Actor*			getDragClient() const {return _dragClient;}
 		Actor*			getDragClient() const {return _dragClient;}
 		const RectF&	getDragBounds() const {return _bounds;}
 		const RectF&	getDragBounds() const {return _bounds;}
+		bool			isDragging() const {return _pressed;}
 
 
 		bool getDragEnabled() const {return _dragEnabled;}
 		bool getDragEnabled() const {return _dragEnabled;}
 		void setDragEnabled(bool en){_dragEnabled = en;}
 		void setDragEnabled(bool en){_dragEnabled = en;}

+ 4 - 4
oxygine/src/ProgressBar.cpp

@@ -96,7 +96,7 @@ namespace oxygine
 	{
 	{
 		if (_progress == 0)
 		if (_progress == 0)
 			return;
 			return;
-		if (((_direction != dir_radial_ccw) && (_direction != dir_radial_cw)) || (_progress == 1.0f))
+		if (((_direction != __dir_radial_ccw) && (_direction != dir_radial_cw)) || (_progress == 1.0f))
 		{
 		{
 			Sprite::doRender(rs);
 			Sprite::doRender(rs);
 			return;
 			return;
@@ -321,7 +321,7 @@ namespace oxygine
 		case dir_radial_cw:
 		case dir_radial_cw:
 			dir = "dir_radial_cw";
 			dir = "dir_radial_cw";
 			break;
 			break;
-		case dir_radial_ccw:
+		case __dir_radial_ccw:
 			dir = "dir_radial_ccw";
 			dir = "dir_radial_ccw";
 			break;
 			break;
 		}
 		}
@@ -340,7 +340,7 @@ namespace oxygine
 	void ProgressBar::setProgress(float f)
 	void ProgressBar::setProgress(float f)
 	{
 	{
 		_progress = scalar::clamp(f, 0.0f, 1.0f);
 		_progress = scalar::clamp(f, 0.0f, 1.0f);
-		if (_direction == dir_radial_ccw || _direction == dir_radial_cw)
+		if (_direction == __dir_radial_ccw || _direction == dir_radial_cw)
 			return;
 			return;
 		_update();
 		_update();
 	}
 	}
@@ -348,7 +348,7 @@ namespace oxygine
 	void ProgressBar::setDirection(direction dir)
 	void ProgressBar::setDirection(direction dir)
 	{
 	{
 		_direction = dir;
 		_direction = dir;
-		if (_direction == dir_radial_ccw || _direction == dir_radial_cw)
+		if (_direction == __dir_radial_ccw || _direction == dir_radial_cw)
 		{
 		{
 			_frame = _originalFrame;
 			_frame = _originalFrame;
 			return;
 			return;

+ 1 - 1
oxygine/src/ProgressBar.h

@@ -16,7 +16,7 @@ namespace oxygine
 			dir_180,//moveable left edge
 			dir_180,//moveable left edge
 			dir_270,//moveable bottom edge
 			dir_270,//moveable bottom edge
 			dir_radial_cw,
 			dir_radial_cw,
-			dir_radial_ccw//not implemented!!
+			__dir_radial_ccw//not implemented!!
 		};
 		};
 
 
 		DECLARE_COPYCLONE(ProgressBar);
 		DECLARE_COPYCLONE(ProgressBar);

+ 159 - 87
oxygine/src/SlidingActor.cpp

@@ -14,8 +14,14 @@ namespace oxygine
 		_defaultTouchThreshold = val;
 		_defaultTouchThreshold = val;
 	}
 	}
 
 
-	SlidingActor::SlidingActor():_prevPos(0, 0), _speed(0, 0), _sliding(false), _downPos(0, 0), _rad(_defaultTouchThreshold), _downTime(0), _down(false), _maxSpeed(250), _snapSize(0, 0), 
-		_movingX(false), _movingY(false), _snapSpeed(1.0f)
+	SlidingActor::SlidingActor():
+		_sliding(false),
+		_rad(_defaultTouchThreshold), 
+		_maxSpeed(250),
+		_downTime(0),  
+		_downPos(0, 0),
+		_speed(0, 0),  
+		_lastTime(0), _current(0), _lastIterTime(0)
 	{
 	{
 		_clip = initActor(new ClipRectActor, 
 		_clip = initActor(new ClipRectActor, 
 			arg_attachTo = this);
 			arg_attachTo = this);
@@ -23,6 +29,9 @@ namespace oxygine
 		_clip->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &SlidingActor::_newEvent));
 		_clip->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &SlidingActor::_newEvent));
 		_clip->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &SlidingActor::_newEvent));
 		_clip->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &SlidingActor::_newEvent));
 		_clip->addEventListener(TouchEvent::MOVE, CLOSURE(this, &SlidingActor::_newEvent));
 		_clip->addEventListener(TouchEvent::MOVE, CLOSURE(this, &SlidingActor::_newEvent));
+
+		//for (int i = 0; i < NUM; ++i)
+		//	_prev[i] = Vector2(0,0);
 	}
 	}
 	
 	
 	void SlidingActor::destroy()
 	void SlidingActor::destroy()
@@ -57,11 +66,6 @@ namespace oxygine
 		_drag.snapClient2Bounds();
 		_drag.snapClient2Bounds();
 	}
 	}
 
 
-	void SlidingActor::setSnapPageSize(const Vector2 &size)
-	{
-		_snapSize = size;
-	}
-
 	void SlidingActor::setContent(spActor content)
 	void SlidingActor::setContent(spActor content)
 	{
 	{
 		if (_content)
 		if (_content)
@@ -78,12 +82,17 @@ namespace oxygine
 		updateDragBounds();
 		updateDragBounds();
 	}
 	}
 
 
+	void SlidingActor::setLocked(bool locked)
+	{
+		_drag.setDragEnabled(!locked);
+	}
+
 	void SlidingActor::updateDragBounds()
 	void SlidingActor::updateDragBounds()
 	{
 	{
 		if (!_content)
 		if (!_content)
 			return;
 			return;
-		float w = _content->getWidth() - _clip->getWidth();
-		float h = _content->getHeight() - _clip->getHeight();
+		float w = std::max(0.0f, _content->getWidth() - _clip->getWidth());
+		float h = std::max(0.0f, _content->getHeight() - _clip->getHeight());
 		RectF bounds(-w, -h, w, h);		
 		RectF bounds(-w, -h, w, h);		
 
 
 		_drag.setDragBounds(bounds);
 		_drag.setDragBounds(bounds);
@@ -103,124 +112,187 @@ namespace oxygine
 		return d;
 		return d;
 	}
 	}
 
 
+	const timeMS fdt = 1000/60;
+	//const float fdt = 20;
+
+	//int lastPosStep = 20;
 	void SlidingActor::doUpdate(const UpdateState &us)
 	void SlidingActor::doUpdate(const UpdateState &us)
 	{
 	{
 		if (!_content)
 		if (!_content)
 			return;
 			return;
 
 
-		float  dt = us.dt/1000.0f;
-		Vector2 contentPos = _content->getPosition();
-		
-		if (_holded && (getTimeMS() > _downTime + 100))
+		//static float ml = 0;
+		//ml = max(_speed.length(), ml);
+		//log::messageln("sp: %.2f", ml);
+
+		int ct = getTimeMS();
+		if (_lastIterTime + NUM * fdt < ct)
+			_lastIterTime = ct;
+
+		if (_drag.isDragging())
 		{
 		{
-			Vector2 dist = contentPos - _prevPos;
-			if (dist.sqlength() < 1)
-				_speed = Vector2(0, 0);
+			Vector2 pos = _content->getPosition();
+			//log::messageln("%d) pos %.2f %.2f", _current, pos.x, pos.y);
+			_prev[_current].pos = pos;
+			_prev[_current].tm = ct;
+			_current = (_current + 1) % NUM;
+
+			return;
 		}
 		}
 
 
-		if (!_down)
+		if (_sliding)
 		{
 		{
-			dt *= 20 * _snapSpeed;
-			bool callSnap = false;
-
-			if (_snapSize.x >= 0.999 && _movingX)
+			const RectF &bounds = _drag.getDragBounds();
+			while (_lastIterTime + fdt <= ct)
 			{
 			{
-				float d = getOffset(_content->getX(), (float)_snapSize.x) * dt;
-				_content->setX(_content->getX() - d);
-
-				if (d == 0)
+				Vector2 pos = _content->getPosition();
+				Vector2 newpos = pos + _speed * (fdt / 1000.0f);
+				if (newpos.x < bounds.getLeft())
 				{
 				{
-					_movingX = false;					
-					callSnap = true;
+					newpos.x = bounds.getLeft();
+					_speed.x = 0;
+				}else
+				if (newpos.x > bounds.getRight())
+				{
+					newpos.x = bounds.getRight();
+					_speed.x = 0;
 				}
 				}
-			}
 
 
-
-			if (_snapSize.y && _movingY)
-			{
-				float d = getOffset(_content->getY(), (float)_snapSize.y) * dt;
-				_content->setY(_content->getY() - d);
-				if (d == 0)
+				if (newpos.y < bounds.getTop())
 				{
 				{
-					_movingY = false;
-					callSnap = true;
+					newpos.y = bounds.getTop();
+					_speed.y = 0;
+				}else
+				if (newpos.y > bounds.getBottom())
+				{
+					newpos.y = bounds.getBottom();
+					_speed.y = 0;
 				}
 				}
-			}
-			
 
 
-			if (callSnap && _cbSlideDone)
-				_cbSlideDone(0);
-		}
-			
-		if (!_sliding)
-			return;
 
 
-		if (_speed.length() < 0.001)
-		{
-			_sliding = false;
-			
-			return;
-		}
+				_speed *= 0.97f;
+				_content->setPosition(newpos);
 
 
-		
-		
-		Vector2 newPos = contentPos + _speed * dt;
-		_content->setPosition(newPos);
-		//_slideOnTopDH->snapClient2Bounds();
+				_lastIterTime += fdt;
+			}
 
 
-		if (!(newPos == _content->getPosition()))
-		{
-			_sliding = false;
-		}
 
 
-		Vector2 s = -_speed;
-		s.normalizeTo(200);
-		_speed = _speed + s * dt;
+			SlidingEvent sl(SlidingEvent::SLIDING);
+			sl.speed = _speed;
+			dispatchEvent(&sl);
+			_speed = sl.speed;
 
 
-		if (_speed.dot(s) > 0.9)
-		{
-			_sliding = false;			
+			if (_speed.sqlength() < 8)
+			{
+				_sliding = false;
+				SlidingEvent ev(SlidingEvent::END);
+				dispatchEvent(&ev);
+			}
 		}
 		}
 
 
-		if (!_sliding)
-		{
-			//slideDone();
-		}
 	}
 	}
 
 
 	void SlidingActor::handleEvent(Event *event)
 	void SlidingActor::handleEvent(Event *event)
-	{
-		bool touchEvent = event->type > _et_TouchFirst && event->type < _et_TouchLast;
-		if (touchEvent && _holded)
-		{
-
-		//	return;
-		}
-		
+	{		
 		Actor::handleEvent(event);
 		Actor::handleEvent(event);
 	}
 	}
 
 
 	void SlidingActor::_newEvent(Event *event)
 	void SlidingActor::_newEvent(Event *event)
 	{
 	{
 		TouchEvent *te = safeCast<TouchEvent*>(event);
 		TouchEvent *te = safeCast<TouchEvent*>(event);
+		timeMS tm = getTimeMS();
 		switch(te->type)
 		switch(te->type)
 		{
 		{
 		case TouchEvent::TOUCH_DOWN:
 		case TouchEvent::TOUCH_DOWN:
-			_holded = event->target;
-			_downPos = te->localPosition;
-			_down = true;
+			{
+				_current = 0;
+				_lastIterTime = tm;
+				
+				_prev[0].pos = _content->getPosition();
+				_prev[0].tm = tm;
+
+				for (int i = 1; i < NUM; ++i)
+					_prev[i].tm = 0;
+
+				_holded = event->target;
+				_downPos = te->localPosition;
+				_downTime = tm;
+			}
 			break;
 			break;
 
 
 		case TouchEvent::TOUCH_UP:
 		case TouchEvent::TOUCH_UP:
 			{		
 			{		
-				_movingY = _movingX = true;
+				if (_drag.getDragEnabled())
+				{
+					_downTime = 0;
+					Vector2 pos = _content->getPosition();
+	
+					_holded = 0;
 
 
-				_holded = 0;
-				_down = false;
+					const iter *old = 0;
+					const iter *mid = 0;
+					const iter *last = _prev + _current;
 
 
-				if (_snapSize.sqlength() < 0.000001 && _cbSlideDone)
-					_cbSlideDone(0);
-			}			
+					for (int i = 1; i < NUM; ++i)
+					{
+						int n = (_current + NUM - i) % NUM;
+						if (_prev[n].tm)					
+							last = _prev + n;
+						else
+							break;
+						if (!mid && (last->tm + 50 <= tm))
+							mid = last;
+						if (last->tm + 150 <= tm)
+						{
+							old = last;
+							break;
+						}
+					}
+					if (!old)
+						old = last;
+					if (!mid)
+						mid = last;
+								
+					Vector2 midpos = mid->pos;
+					Vector2 dir = pos - midpos;
+					if (dir.sqlength() < 10 * 10)				
+						_speed = Vector2(0,0);
+					else
+					{
+						Vector2 dr = pos - old->pos;
+						Vector2 ns = (dr * 1000.0f) / (tm - old->tm);
+					
+						/*
+						int d = tm - _downTime;
+						Vector2 dr2 = pos - _downPos;
+						Vector2 ts = dr2 / float(d) * 1000.0f;
+						ts.x = 0;
+
+						log::messageln("fs: %.2f %d ns: %.2f %d", ns.y, int(tm), ts.y, d);
+						*/
+						//ns = ts;
+
+
+						if (_speed.dot(ns) < 0)
+							_speed = ns;
+						else					
+							_speed += ns;
+					}
+
+				
+					if (!_sliding)
+					{
+						_sliding = true;
+					}
+
+					SlidingEvent sd(SlidingEvent::BEGIN);
+					sd.speed = _speed;
+					dispatchEvent(&sd);
+					_speed = sd.speed;
+
+					_lastIterTime = tm;
+				}				
+			}
 			break;
 			break;
 
 
 		case TouchEvent::MOVE:
 		case TouchEvent::MOVE:
@@ -240,7 +312,7 @@ namespace oxygine
 
 
 					_content->setPressed(te->index);
 					_content->setPressed(te->index);
 					_holded = 0;
 					_holded = 0;
-				}			
+				}
 			}			
 			}			
 			break;
 			break;
 		}
 		}

+ 33 - 26
oxygine/src/SlidingActor.h

@@ -14,22 +14,34 @@ namespace oxygine
 	{
 	{
 	public:
 	public:
 		static void setDefaultTouchThreshold(float val);
 		static void setDefaultTouchThreshold(float val);
+		
+		class SlidingEvent: public Event
+		{
+		public:
+			enum EV
+			{
+				BEGIN = makefourcc('S', 'A', 'B', 'G'),
+				SLIDING = makefourcc('S', 'A', 'S', 'L'),
+				END = makefourcc('S', 'A', 'E', 'D')
+			};
+
+			SlidingEvent(EV ev):Event(ev), speed(0, 0){}
+			Vector2 speed;
+		};
+
+
 		SlidingActor();
 		SlidingActor();
 		~SlidingActor();
 		~SlidingActor();
-			
+	
 		spActor			getContent() const {return _content;}
 		spActor			getContent() const {return _content;}
 		const RectF&	getDragBounds() const {return _drag.getDragBounds();}
 		const RectF&	getDragBounds() const {return _drag.getDragBounds();}
 
 
 		/**max allowed radius of touch move when content could be clicked*/
 		/**max allowed radius of touch move when content could be clicked*/
 		void setTouchThreshold(float rad);
 		void setTouchThreshold(float rad);
 		void setContent(spActor content);
 		void setContent(spActor content);
-		void setSnapPageSize(const Vector2 &size);
-		/**how fast page would be snapped, default value = 1.0f*/
-		void setSnapSpeed(float v){_snapSpeed = v;}
-
-		void snap();		
-
-		void setCallbackSlideDone(EventCallback cb){_cbSlideDone = cb;}
+		void setLocked(bool locked);
+		void snap();
+		
 
 
 	protected:
 	protected:
 		void destroy();
 		void destroy();
@@ -40,41 +52,36 @@ namespace oxygine
 		void doUpdate(const UpdateState &us);
 		void doUpdate(const UpdateState &us);
 		void updateDragBounds();
 		void updateDragBounds();
 		
 		
-		/*
-		bool onMouseDown(const EventState &es);
-		bool onMouseUp(const EventState &es);
-		bool onMotion(const EventState &es);
-		bool onDrag(const EventState &es);
-
-		void deactivate(const EventState &es);
-		*/
-		//void slideDone();
 
 
 		void _newEvent(Event *event);
 		void _newEvent(Event *event);
-		Vector2 _snapSize;
-
-		bool _movingX;
-		bool _movingY;
 
 
 		bool _sliding;
 		bool _sliding;
 		float _rad;
 		float _rad;
-		float _snapSpeed;
 		float _maxSpeed;
 		float _maxSpeed;
 		timeMS _downTime;
 		timeMS _downTime;
 
 
 		Vector2 _downPos;
 		Vector2 _downPos;
 		Vector2 _speed;
 		Vector2 _speed;
-		Vector2 _prevPos;
 
 
 		Draggable _drag;
 		Draggable _drag;
 
 
 		spActor _content;
 		spActor _content;
 		spClipRectActor _clip;
 		spClipRectActor _clip;
-		//spDragHandler _slideOnTopDH;
-		EventCallback _cbSlideDone;
 
 
 		spEventDispatcher _holded;
 		spEventDispatcher _holded;
-		bool	_down;
+
+		struct  iter
+		{
+			Vector2 pos;
+			timeMS tm;
+		};
+
+		timeMS _lastTime;
+		enum {NUM = 11};
+		iter _prev[NUM];
+		int _current;
+
+		timeMS _lastIterTime;
 	};
 	};
 
 
 }
 }

+ 12 - 11
oxygine/src/Sprite.cpp

@@ -8,7 +8,7 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-	Sprite::Sprite():_manageResAnim(false)
+	Sprite::Sprite()
 	{
 	{
 
 
 	}
 	}
@@ -18,12 +18,11 @@ namespace oxygine
 	
 	
 	}
 	}
 
 
-	Sprite::Sprite(const Sprite &src, cloneOptions opt):Actor(src, opt)
+	Sprite::Sprite(const Sprite &src, cloneOptions opt):VStyleActor(src, opt)
 	{
 	{
 		_frame = src._frame;
 		_frame = src._frame;
 		_vstyle= src._vstyle;
 		_vstyle= src._vstyle;
-		_manageResAnim = src._manageResAnim;
-		if (_manageResAnim)
+		if (getManageResAnim())
 		{
 		{
 			ResAnim *rs = _frame.getResAnim();
 			ResAnim *rs = _frame.getResAnim();
 			if (rs)
 			if (rs)
@@ -33,7 +32,9 @@ namespace oxygine
 
 
 	void Sprite::setManageResAnim(bool manage)
 	void Sprite::setManageResAnim(bool manage)
 	{
 	{
-		_manageResAnim = manage;
+		_flags &= ~flag_manageResAnim; 
+		if (manage) 
+			_flags |= flag_manageResAnim;
 	}
 	}
 
 
 	std::string Sprite::dump(const dumpOptions &options) const
 	std::string Sprite::dump(const dumpOptions &options) const
@@ -45,8 +46,8 @@ namespace oxygine
 		if (_frame.getDiffuse().base)
 		if (_frame.getDiffuse().base)
 			tname = _frame.getDiffuse().base->getName();
 			tname = _frame.getDiffuse().base->getName();
 		stream << "texture='" << tname << "' "; 
 		stream << "texture='" << tname << "' "; 
-		if (_manageResAnim)
-			stream << "manageResAnim='" << _manageResAnim << "' "; 
+		if (_flags & flag_manageResAnim)
+			stream << "manageResAnim=true"; 
 
 
 		stream << Actor::dump(options);
 		stream << Actor::dump(options);
 		return stream.str();
 		return stream.str();
@@ -90,7 +91,7 @@ namespace oxygine
 
 
 	void Sprite::changeAnimFrame(const AnimationFrame &frame)
 	void Sprite::changeAnimFrame(const AnimationFrame &frame)
 	{
 	{
-		if (_manageResAnim)
+		if (_flags & flag_manageResAnim)
 		{
 		{
 			ResAnim *rs = _frame.getResAnim();
 			ResAnim *rs = _frame.getResAnim();
 			if (rs)
 			if (rs)
@@ -141,9 +142,9 @@ namespace oxygine
 			_colEnd = _resAnim->getColumns();
 			_colEnd = _resAnim->getColumns();
 	}
 	}
 
 
-	void TweenAnim::init(Sprite &actor, bool rel)
+	void TweenAnim::init(Sprite &actor)
 	{
 	{
-		OX_ASSERT(rel == false);
+
 	}
 	}
 
 
 
 
@@ -154,7 +155,7 @@ namespace oxygine
 			_colEnd = _resAnim->getColumns();
 			_colEnd = _resAnim->getColumns();
 	}
 	}
 
 
-	/**play animation for interval [start, end)*/
+
 	void TweenAnim::setColumns(int start, int end)
 	void TweenAnim::setColumns(int start, int end)
 	{
 	{
 		_colStart = start; _colEnd = end;
 		_colStart = start; _colEnd = end;

+ 12 - 16
oxygine/src/Sprite.h

@@ -13,7 +13,9 @@ namespace oxygine
 
 
 	DECLARE_SMART(Sprite, spSprite);
 	DECLARE_SMART(Sprite, spSprite);
 		
 		
-	class Sprite : public Actor
+	
+
+	class Sprite : public VStyleActor
 	{
 	{
 	public:
 	public:
 		DECLARE_COPYCLONE(Sprite);
 		DECLARE_COPYCLONE(Sprite);
@@ -21,20 +23,15 @@ namespace oxygine
 		Sprite();
 		Sprite();
 		~Sprite();
 		~Sprite();
 		
 		
-		//spTexture				getTexture() const {return _frame.getBaseTexture();}
+		const AnimationFrame&	getAnimFrame() const {return _frame;}
+		virtual RectF			getDestRect() const;
 		const Diffuse&			getDiffuse() const {return _frame.getDiffuse();}
 		const Diffuse&			getDiffuse() const {return _frame.getDiffuse();}
+		bool					getManageResAnim() const {return (_flags & flag_manageResAnim) != 0;}
 		const RectF&			getSrcRect() const {return _frame.getSrcRect();}
 		const RectF&			getSrcRect() const {return _frame.getSrcRect();}
-		virtual RectF			getDestRect() const;
-		const AnimationFrame&	getAnimFrame() const {return _frame;}
 		const ResAnim*			getResAnim() const{return _frame.getResAnim();}
 		const ResAnim*			getResAnim() const{return _frame.getResAnim();}
-		const Color&			getColor() const {return _vstyle.getColor();}
-		blend_mode				getBlendMode() const {return _vstyle.getBlendMode();}
-		bool					getManageResAnim() const {return _manageResAnim;}
 
 
 		/**load/unload atlas automatically or not*/
 		/**load/unload atlas automatically or not*/
 		void					setManageResAnim(bool manage);
 		void					setManageResAnim(bool manage);
-		void					setColor(const Color &color){_vstyle.setColor(color);}
-		void					setBlendMode(blend_mode mode){_vstyle.setBlendMode(mode);}
 		/**Changes sprite image*/
 		/**Changes sprite image*/
 		void					setAnimFrame(const AnimationFrame &f);
 		void					setAnimFrame(const AnimationFrame &f);
 		/**Takes AnimationFrame from ResAnim and changes it. Shows assert is resanim is null. Using this method is more safe than 'setAnimFrame(const AnimationFrame &f)'*/
 		/**Takes AnimationFrame from ResAnim and changes it. Shows assert is resanim is null. Using this method is more safe than 'setAnimFrame(const AnimationFrame &f)'*/
@@ -43,17 +40,16 @@ namespace oxygine
 		
 		
 		
 		
 		std::string dump(const dumpOptions &) const;
 		std::string dump(const dumpOptions &) const;
-		
-		typedef GetSet<Color, const Color &, Sprite, &Sprite::getColor, &Sprite::setColor>	TweenColor;
-
 	protected:
 	protected:
+		enum 
+		{
+			flag_manageResAnim = flag_last << 1
+		};
 		virtual void changeAnimFrame(const AnimationFrame &f);
 		virtual void changeAnimFrame(const AnimationFrame &f);
 		virtual void animFrameChanged(const AnimationFrame &f);
 		virtual void animFrameChanged(const AnimationFrame &f);
 		void doRender(const RenderState &rs);
 		void doRender(const RenderState &rs);
 
 
 		AnimationFrame _frame;
 		AnimationFrame _frame;
-		VisualStyle _vstyle;
-		bool _manageResAnim;
 	};
 	};
 
 
 
 
@@ -72,7 +68,7 @@ namespace oxygine
 
 
 		TweenAnim(const ResAnim *resAnim, int row = 0);
 		TweenAnim(const ResAnim *resAnim, int row = 0);
 
 
-		void init(Sprite &actor, bool rel);
+		void init(Sprite &actor);
 
 
 		const ResAnim*	getResAnim() const {return _resAnim;}
 		const ResAnim*	getResAnim() const {return _resAnim;}
 		int				getRow() const {return _row;}
 		int				getRow() const {return _row;}
@@ -81,7 +77,7 @@ namespace oxygine
 
 
 		
 		
 		void setResAnim(const ResAnim *resAnim);
 		void setResAnim(const ResAnim *resAnim);
-		/**play animation for interval [start, end)*/
+		/**play animation in interval [start, end)*/
 		void setColumns(int start, int end);
 		void setColumns(int start, int end);
 		
 		
 		void update(Sprite &actor, float p, const UpdateState &us);
 		void update(Sprite &actor, float p, const UpdateState &us);

+ 11 - 15
oxygine/src/TextActor.cpp

@@ -17,9 +17,9 @@ namespace oxygine
 {
 {
 	TextActor::TextActor():
 	TextActor::TextActor():
 		_root(0),
 		_root(0),
-		_textRect(0,0,0,0),
-		_rebuild(true), _html(false)
+		_textRect(0,0,0,0)
 	{
 	{
+		_flags |= flag_rebuild;
 		if (DebugActor::resSystem)
 		if (DebugActor::resSystem)
 		{
 		{
 			_style.font = DebugActor::resSystem->getResFont("system")->getFont();
 			_style.font = DebugActor::resSystem->getResFont("system")->getFont();
@@ -32,16 +32,13 @@ namespace oxygine
 		_root = 0;
 		_root = 0;
 	}
 	}
 
 
-	TextActor::TextActor(const TextActor &src, cloneOptions opt):Actor(src, opt)
+	TextActor::TextActor(const TextActor &src, cloneOptions opt):VStyleActor(src, opt)
 	{
 	{
 		_text = src._text;
 		_text = src._text;
 		_style = src._style;
 		_style = src._style;
-		_vstyle = src._vstyle;
-		_html = src._html;
-
 		_root = 0;
 		_root = 0;
 
 
-		_rebuild = true;//src._rebuild;
+		_flags |= flag_rebuild;
 		_textRect = src._textRect;
 		_textRect = src._textRect;
 	}
 	}
 
 
@@ -54,7 +51,7 @@ namespace oxygine
 
 
 	void TextActor::needRebuild()
 	void TextActor::needRebuild()
 	{
 	{
-		_rebuild = true;
+		_flags |= flag_rebuild;
 	}
 	}
 
 
 	void TextActor::setVAlign(TextStyle::VerticalAlign align)
 	void TextActor::setVAlign(TextStyle::VerticalAlign align)
@@ -114,7 +111,7 @@ namespace oxygine
 
 
 	void TextActor::setText(const string &str)
 	void TextActor::setText(const string &str)
 	{
 	{
-		_html = false;
+		_flags &= ~flag_html;
 		if (_text != str)
 		if (_text != str)
 		{
 		{
 			_text = str;
 			_text = str;
@@ -129,7 +126,7 @@ namespace oxygine
 
 
 	void TextActor::setHtmlText(const string &str)
 	void TextActor::setHtmlText(const string &str)
 	{
 	{
-		_html = true;
+		_flags |= flag_html;
 		if (_text != str)
 		if (_text != str)
 		{
 		{
 			_text = str;
 			_text = str;
@@ -150,14 +147,13 @@ namespace oxygine
 
 
 	text::Node *TextActor::getRootNode()
 	text::Node *TextActor::getRootNode()
 	{
 	{
-		if (_rebuild && _style.font)
-		//if (_style.font)
+		if ((_flags & flag_rebuild) && _style.font)
 		{
 		{
 			delete _root;
 			delete _root;
 
 
-			_rebuild = false;
+			_flags &= ~flag_rebuild;
 
 
-			if (_html)
+			if (_flags & flag_html)
 			{
 			{
 				text::TextBuilder b;
 				text::TextBuilder b;
 				_root = b.parse(_text);
 				_root = b.parse(_text);
@@ -258,7 +254,7 @@ namespace oxygine
 		string st = dumpStyle(_style, true);
 		string st = dumpStyle(_style, true);
 		if (st.size())
 		if (st.size())
 			stream << " textStyle={" << st << "}"; 
 			stream << " textStyle={" << st << "}"; 
-		if (_html)
+		if (_flags & flag_html)
 		{
 		{
 			stream << " htmlMode";
 			stream << " htmlMode";
 		}
 		}

+ 10 - 13
oxygine/src/TextActor.h

@@ -14,20 +14,18 @@ namespace oxygine
 	}
 	}
 	
 	
 
 
-	class TextActor : public Actor
+	class TextActor : public VStyleActor
 	{
 	{
 	public:
 	public:
 		DECLARE_COPYCLONE(TextActor);
 		DECLARE_COPYCLONE(TextActor);
 		TextActor();
 		TextActor();
 		~TextActor();
 		~TextActor();
-		
+		/**Returns current text style*/
 		const TextStyle&	getStyle() const {return _style;}
 		const TextStyle&	getStyle() const {return _style;}
+		/**Returns text bounds*/
 		const Rect&			getTextRect();
 		const Rect&			getTextRect();
+		/**Returns current text*/
 		const string&		getText() const {return _text;}		
 		const string&		getText() const {return _text;}		
-		const Color&		getColor() const {return _vstyle.getColor();}
-
-		void setColor(const Color &color){_vstyle.setColor(color);}
-		void setBlendMode(blend_mode m){_vstyle.setBlendMode(m);}
 
 
 		/**Overwrites TextStyle Vertical align*/
 		/**Overwrites TextStyle Vertical align*/
 		void setVAlign(TextStyle::VerticalAlign align);
 		void setVAlign(TextStyle::VerticalAlign align);
@@ -59,19 +57,18 @@ namespace oxygine
 
 
 		
 		
 		std::string dump(const dumpOptions &options) const;
 		std::string dump(const dumpOptions &options) const;
-		void doRender( RenderState const& parentRenderState ); 
-
-		typedef GetSet<Color, const Color &, TextActor, &TextActor::getColor, &TextActor::setColor>	TweenColor;
+		void doRender(RenderState const& parentRenderState);
 
 
 	protected:
 	protected:
+		enum
+		{
+			flag_html = flag_last << 1,
+			flag_rebuild = flag_last << 2,
+		};
 		string  _text;
 		string  _text;
-		bool	_html;
-
 		TextStyle _style;
 		TextStyle _style;
-		VisualStyle _vstyle;
 
 
 		text::Node *_root;
 		text::Node *_root;
-		bool _rebuild;
 		Rect _textRect;
 		Rect _textRect;
 
 
 		text::Node *getRootNode();
 		text::Node *getRootNode();

+ 2 - 4
oxygine/src/Tweener.h

@@ -22,12 +22,10 @@ namespace oxygine
 
 
 		GetSet(valueRef dest):_dest(dest), _initialized(false){}
 		GetSet(valueRef dest):_dest(dest), _initialized(false){}
 
 
-		void init(type &t, bool relative)
+		void init(type &t)
 		{
 		{
 			_initialized = true;
 			_initialized = true;
 			_src = get(t);
 			_src = get(t);
-			if (relative)
-				_dest = _src + _dest;
 		}
 		}
 
 
 		void update(type &t, float p, const UpdateState &us)
 		void update(type &t, float p, const UpdateState &us)
@@ -208,7 +206,7 @@ namespace oxygine
 		void _start(Actor &actor)
 		void _start(Actor &actor)
 		{
 		{
 			type &t = *safeCast<type*>(&actor);
 			type &t = *safeCast<type*>(&actor);
-			_gs.init(t, false);
+			_gs.init(t);
 			UpdateState us;
 			UpdateState us;
 			us.iteration = -1;
 			us.iteration = -1;
 			_gs.update(t, _calcEase(0.0f), us);
 			_gs.update(t, _calcEase(0.0f), us);

+ 6 - 0
oxygine/src/VisualStyle.cpp

@@ -5,6 +5,12 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
+	VStyleActor::VStyleActor(const VStyleActor &src, cloneOptions opt):Actor(src, opt)
+	{
+		_vstyle = src._vstyle;
+	}
+
+
 	void VisualStyle::_apply(const RenderState &rs)
 	void VisualStyle::_apply(const RenderState &rs)
 	{
 	{
 		rs.renderer->setBlendMode(_blend);
 		rs.renderer->setBlendMode(_blend);

+ 20 - 0
oxygine/src/VisualStyle.h

@@ -1,5 +1,6 @@
 #pragma once
 #pragma once
 #include "oxygine_include.h"
 #include "oxygine_include.h"
+#include "Actor.h"
 #include "core/Renderer.h"
 #include "core/Renderer.h"
 #include "Tweener.h"
 #include "Tweener.h"
 
 
@@ -25,4 +26,23 @@ namespace oxygine
 		Color _color;
 		Color _color;
 		blend_mode _blend;
 		blend_mode _blend;
 	};
 	};
+
+	class VStyleActor: public Actor
+	{
+	public:
+		DECLARE_COPYCLONE(VStyleActor);
+		VStyleActor(){}
+
+		blend_mode				getBlendMode() const {return _vstyle.getBlendMode();}
+		const Color&			getColor() const {return _vstyle.getColor();}
+
+		void					setColor(const Color &color){_vstyle.setColor(color);}
+		void					setBlendMode(blend_mode mode){_vstyle.setBlendMode(mode);}
+
+
+		typedef GetSet<Color, const Color &, VStyleActor, &VStyleActor::getColor, &VStyleActor::setColor>	TweenColor;
+
+	protected:
+		VisualStyle _vstyle;
+	};
 }
 }

+ 59 - 10
oxygine/src/core/FileSystem.cpp

@@ -5,7 +5,7 @@ namespace oxygine
 {
 {
 	namespace file
 	namespace file
 	{
 	{
-		FileSystem::FileSystem()
+		FileSystem::FileSystem(bool readonly):_readonly(readonly)
 		{
 		{
 			_prefix[0] = 0;
 			_prefix[0] = 0;
 		}
 		}
@@ -20,6 +20,17 @@ namespace oxygine
 			strcpy(_prefix, str);
 			strcpy(_prefix, str);
 		}
 		}
 
 
+		bool starts_with(const char *string, const char *prefix)
+		{
+			while(*prefix)
+			{
+				if(*prefix++ != *string++)
+					return false;
+			}
+
+			return true;
+		}
+
 		bool FileSystem::isExists(const char *file)
 		bool FileSystem::isExists(const char *file)
 		{
 		{
 			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
 			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
@@ -29,29 +40,57 @@ namespace oxygine
 					return true;
 					return true;
 			}
 			}
 
 
+			if (!starts_with(file, _prefix))
+				return status_error;
+
 			return _isExists(file);
 			return _isExists(file);
 		}
 		}
 
 
-		bool FileSystem::isExistsHere(const char *file)
+		FileSystem::status FileSystem::deleteFile(const char* file)
 		{
 		{
-			return _isExists(file);
+			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
+			{
+				FileSystem *fs = *i;
+				if (fs->deleteFile(file) == status_ok)
+					return status_ok;
+			}
+			
+			if (_readonly)
+				return status_error;
+
+			if (!starts_with(file, _prefix))
+				return status_error;
+
+			return _deleteFile(file);
 		}
 		}
 
 
-		bool starts_with(const char *string, const char *prefix)
+		FileSystem::status FileSystem::renameFile(const char* src, const char *dest)
 		{
 		{
-			while(*prefix)
+			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
 			{
 			{
-				if(*prefix++ != *string++)
-					return false;
+				FileSystem *fs = *i;
+				if (fs->renameFile(src, dest) == status_ok)
+					return status_ok;
 			}
 			}
 
 
-			return true;
+			if (_readonly)
+				return status_error;
+
+			if (!starts_with(src, _prefix))
+				return status_error;
+
+			return _renameFile(src, dest);
+		}
+
+		bool FileSystem::isExistsHere(const char *file)
+		{
+			return _isExists(file);
 		}
 		}
 
 
+	
+
 		FileSystem::status FileSystem::open(const char *file, const char *mode, error_policy ep, fileHandle *&fh)
 		FileSystem::status FileSystem::open(const char *file, const char *mode, error_policy ep, fileHandle *&fh)
 		{
 		{
-			if (!starts_with(file, _prefix))
-				return status_error;
 			//file += strlen(_prefix);
 			//file += strlen(_prefix);
 			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
 			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
 			{
 			{
@@ -61,6 +100,16 @@ namespace oxygine
 					return st;
 					return st;
 			}
 			}
 
 
+			if (_readonly)
+			{
+				bool write = mode[0] == 'W' || mode[0] == 'w';
+				if (write)
+					return status_error;
+			}
+
+			if (!starts_with(file, _prefix))
+				return status_error;			
+
 			return _open(file, mode, ep, fh);
 			return _open(file, mode, ep, fh);
 		}
 		}
 
 

+ 6 - 1
oxygine/src/core/FileSystem.h

@@ -25,13 +25,15 @@ namespace oxygine
 				status_ok,
 				status_ok,
 			};
 			};
 
 
-			FileSystem();
+			FileSystem(bool readonly);
 			~FileSystem();
 			~FileSystem();
 
 
 			void setPrefix(const char *str);
 			void setPrefix(const char *str);
 
 
 			bool isExists(const char *file);
 			bool isExists(const char *file);
 			bool isExistsHere(const char *file);
 			bool isExistsHere(const char *file);
+			status deleteFile(const char* file);
+			status renameFile(const char* src, const char *dest);
 
 
 			status open(const char *file, const char *mode, error_policy ep, fileHandle *&fh);
 			status open(const char *file, const char *mode, error_policy ep, fileHandle *&fh);
 
 
@@ -41,8 +43,11 @@ namespace oxygine
 		protected:
 		protected:
 			virtual status _open(const char *file, const char *mode, error_policy ep, fileHandle*&) = 0;
 			virtual status _open(const char *file, const char *mode, error_policy ep, fileHandle*&) = 0;
 			virtual bool _isExists(const char *file);
 			virtual bool _isExists(const char *file);
+			virtual status _deleteFile(const char* file) = 0;
+			virtual status _renameFile(const char* src, const char *dest) = 0;
 
 
 			char _prefix[32];
 			char _prefix[32];
+			bool _readonly;
 
 
 			typedef vector<FileSystem*> filesystems;
 			typedef vector<FileSystem*> filesystems;
 			filesystems _filesystems;
 			filesystems _filesystems;

+ 9 - 10
oxygine/src/core/Renderer.cpp

@@ -13,13 +13,13 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-	Renderer::Stats Renderer::statsPrev;
-	Renderer::Stats Renderer::statsCurrent;
+	//Renderer::Stats Renderer::statsPrev;
+	//Renderer::Stats Renderer::statsCurrent;
 	bool _restored = false;
 	bool _restored = false;
 	spNativeTexture Renderer::white;
 	spNativeTexture Renderer::white;
 	std::vector<unsigned char> Renderer::indices8;
 	std::vector<unsigned char> Renderer::indices8;
 	std::vector<unsigned short> Renderer::indices16;
 	std::vector<unsigned short> Renderer::indices16;
-	int _maxVertices = 0;
+	size_t _maxVertices = 0;
 	UberShaderProgram Renderer::uberShader;
 	UberShaderProgram Renderer::uberShader;
 	std::vector<unsigned char> Renderer::uberShaderBody;
 	std::vector<unsigned char> Renderer::uberShaderBody;
 	
 	
@@ -325,17 +325,14 @@ namespace oxygine
 				cb(prog);
 				cb(prog);
 			}			
 			}			
 
 
-			int count = _vertices.size() / _vdecl->size;
-			int indices = (count * 3)/2;
+			size_t count = _vertices.size() / _vdecl->size;
+			size_t indices = (count * 3)/2;
 
 
-			if (indices <= (int)indices8.size())
+			if (indices <= indices8.size())
 				getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), count, &indices8.front(), indices, false);
 				getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), count, &indices8.front(), indices, false);
 			else
 			else
 				getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), count, &indices16.front(), indices, true);
 				getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), count, &indices16.front(), indices, true);
-			
-			++statsCurrent.batches;
-			statsCurrent.triangles += _vertices.size()/(_vdecl->size * 2);
-
+		
 			_vertices.resize(0);			
 			_vertices.resize(0);			
 			//b.shaderFlags = 0;
 			//b.shaderFlags = 0;
 		}
 		}
@@ -543,6 +540,8 @@ namespace oxygine
 	{
 	{
 		_blend = blend_disabled;
 		_blend = blend_disabled;
 		_driver->setState(IVideoDriver::STATE_BLEND, 0);
 		_driver->setState(IVideoDriver::STATE_BLEND, 0);
+		_uberShader = &uberShader;
+		_program = 0;
 	}
 	}
 
 
 	bool Renderer::begin(spNativeTexture rt, const Rect &viewport, const Color *clearColor)
 	bool Renderer::begin(spNativeTexture rt, const Rect &viewport, const Color *clearColor)

+ 0 - 12
oxygine/src/core/Renderer.h

@@ -133,14 +133,6 @@ namespace oxygine
 	public:
 	public:
 		typedef AffineTransform transform;
 		typedef AffineTransform transform;
 
 
-		class Stats
-		{
-		public:
-			Stats():batches(0), triangles(0){}
-			int batches;
-			int triangles;
-		};
-
 		/**Sets default rendering opengl options for 2D*/
 		/**Sets default rendering opengl options for 2D*/
 		static void setDefaultSettings();
 		static void setDefaultSettings();
 		/**Initializes internal classes. Called automatically from oxygine::init();*/
 		/**Initializes internal classes. Called automatically from oxygine::init();*/
@@ -158,10 +150,6 @@ namespace oxygine
 
 
 		static std::vector<unsigned char> indices8;
 		static std::vector<unsigned char> indices8;
 		static std::vector<unsigned short> indices16;
 		static std::vector<unsigned short> indices16;
-				
-		static Stats statsPrev;
-		static Stats statsCurrent;
-
 
 
 		Renderer(IVideoDriver *driver = 0);
 		Renderer(IVideoDriver *driver = 0);
 		virtual ~Renderer();
 		virtual ~Renderer();

+ 85 - 36
oxygine/src/core/STDFileSystem.cpp

@@ -155,48 +155,66 @@ namespace oxygine
 			oxHandle* _handle;
 			oxHandle* _handle;
 		};
 		};
 
 
-		STDFileSystem::STDFileSystem()
+		STDFileSystem::STDFileSystem(bool readonly):FileSystem(readonly)
 		{
 		{
 #ifdef WIN32
 #ifdef WIN32
-			mkdir("../data-ram");
+			if (!_readonly)
+				mkdir(getFullPath("").c_str());
 #endif
 #endif
 		}
 		}
 
 
-		void STDFileSystem::setExtendedFolder(const char *folder)
+		char* STDFileSystem::_getFullPath(const char *path, char buff[512])
 		{
 		{
-			_extended = folder;
-			_extended += "/";
-			char norm[512];
-			path::normalize(_extended.c_str(), norm);
-			_extended = norm;
-		}
+			buff[0] = 0;
 
 
-
-		FileSystem::status STDFileSystem::_open(const char *file, const char *mode, error_policy ep, fileHandle*& fh)
-		{
-			bool write = mode[0] == 'w' || mode[0] == 'W';
-			oxHandle* h = 0;
-			if (!_extended.empty() && !write)
+			if (_readonly)
 			{
 			{
-				string path = _extended + file;
-				if (oxExists(path.c_str()))
-					h = oxFileOpen(path.c_str(), mode);
+#if __S3E__
+				sprintf(buff, "rom://%s", path);
+#else
+				sprintf(buff, "%s%s", _path.c_str(), path);
+#endif
 			}
 			}
-
-			if (!h)
+			else
 			{
 			{
-#ifdef WIN32
-				char name[255];
-				safe_sprintf(name, "../data-ram/%s", file);
-				h = oxFileOpen(name, mode);
+#if __S3E__
+				sprintf(buff, "ram://%s", path);
+#else
+	#ifdef  WIN32
+				sprintf(buff, "../data-ram/%s%s", _path.c_str(), path);
+	#else
+				strcpy(buff, path);
+				log::warning("not implemented fs");
+	#endif
 #endif
 #endif
 			}
 			}
 
 
-			if (!h)
-			{
-				h = oxFileOpen(file, mode);
-			}
 
 
+			return buff;
+		}
+
+		string STDFileSystem::getFullPath(const char *path)
+		{
+			char buff[512];
+			return _getFullPath(path, buff);
+		}
+
+		void STDFileSystem::setPath(const char *folder)
+		{
+			_path = folder;
+			_path += "/";
+			char norm[512];
+			path::normalize(_path.c_str(), norm);
+			_path = norm;
+		}
+
+
+		FileSystem::status STDFileSystem::_open(const char *file, const char *mode, error_policy ep, fileHandle*& fh)
+		{
+			char buff[512];
+
+			oxHandle* h = oxFileOpen(_getFullPath(file, buff), mode);
+			
 			if (!h)
 			if (!h)
 				return status_error;
 				return status_error;
 			
 			
@@ -204,20 +222,51 @@ namespace oxygine
 			return status_ok;
 			return status_ok;
 		}
 		}
 
 
+		FileSystem::status STDFileSystem::_deleteFile(const char* file)
+		{
+			char buff[512];
+			_getFullPath(file, buff);
+
+#if __S3E__
+			s3eFileDelete(buff);
+#else
+			::remove(buff);
+#endif
+
+			return status_error;
+		}
+
+		FileSystem::status STDFileSystem::_renameFile(const char* src, const char *dest)		
+		{
+			char buffSrc[512];
+			_getFullPath(src, buffSrc);
+
+			char buffDest[512];
+			_getFullPath(dest, buffDest);
+
+#if __S3E__
+			s3eFileRename(buffSrc, buffDest);
+#else
+			::rename(buffSrc, buffDest);
+#endif
+
+			return status_error;
+		}
+
 		bool STDFileSystem::_isExists(const char *file)
 		bool STDFileSystem::_isExists(const char *file)
 		{
 		{
+			char buff[512];
+			_getFullPath(file, buff);
 #if __S3E__
 #if __S3E__
-			string path = _extended + file;
-			s3eBool res = s3eFileCheckExists(path.c_str());			
-			if (res == S3E_FALSE)
-				res = s3eFileCheckExists(file);
+			s3eBool res = s3eFileCheckExists(buff);
 			return res == S3E_TRUE;
 			return res == S3E_TRUE;
 #else
 #else
-			handle f = file::open(file, "r", ep_ignore_error);
-			autoClose h(f);
-			return f != 0;
+			//todo optimize
+			oxHandle *h = oxFileOpen(buff, "r");
+			if (h)
+				oxFileClose(h);
+			return h != 0;
 #endif
 #endif
-
 		}
 		}
 	}
 	}
 }
 }

+ 8 - 3
oxygine/src/core/STDFileSystem.h

@@ -8,13 +8,18 @@ namespace oxygine
 		class STDFileSystem: public FileSystem
 		class STDFileSystem: public FileSystem
 		{
 		{
 		public:
 		public:
-			STDFileSystem();
-			void setExtendedFolder(const char *folder);
+			STDFileSystem(bool readonly);
+
+			string getFullPath(const char *path);
+			void setPath(const char *folder);
 
 
 		protected:
 		protected:
-			string _extended;
+			string _path;			
+			char* _getFullPath(const char *path, char buff[512]);
 
 
 			status _open(const char *file_, const char *mode, error_policy ep, fileHandle*& fh);
 			status _open(const char *file_, const char *mode, error_policy ep, fileHandle*& fh);
+			status _deleteFile(const char* file);
+			status _renameFile(const char* src, const char *dest);
 			bool _isExists(const char *file);
 			bool _isExists(const char *file);
 		};
 		};
 	}	
 	}	

+ 6 - 0
oxygine/src/core/VideoDriver.cpp

@@ -19,6 +19,12 @@ namespace oxygine
 
 
 	}
 	}
 
 
+	void VideoDriverNull::getStats(Stats &s) const
+	{
+		s.batches = 0;
+		s.triangles = 0;
+	}
+
 	void VideoDriverNull::getViewport(Rect &r) const
 	void VideoDriverNull::getViewport(Rect &r) const
 	{
 	{
 		
 		

+ 17 - 0
oxygine/src/core/VideoDriver.h

@@ -16,6 +16,14 @@ namespace oxygine
 	class IVideoDriver
 	class IVideoDriver
 	{
 	{
 	public:
 	public:
+		class Stats
+		{
+		public:
+			Stats():batches(0), triangles(0){}
+			int batches;
+			int triangles;
+		};
+
 		enum PRIMITIVE_TYPE
 		enum PRIMITIVE_TYPE
 		{
 		{
 			PT_POINTS,
 			PT_POINTS,
@@ -58,6 +66,7 @@ namespace oxygine
 		virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration *decl, const void *verticesData, unsigned int numVertices) = 0;
 		virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration *decl, const void *verticesData, unsigned int numVertices) = 0;
 		virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration *decl, const void *verticesData, unsigned int numVertices, const void *indicesData, unsigned int numIndices, bool indicesShortType) = 0;
 		virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration *decl, const void *verticesData, unsigned int numVertices, const void *indicesData, unsigned int numIndices, bool indicesShortType) = 0;
 
 
+		virtual void	getStats(Stats &s) const = 0;
 		virtual void	getViewport(Rect &r) const = 0;
 		virtual void	getViewport(Rect &r) const = 0;
 		virtual bool	getScissorRect(Rect &) const = 0;
 		virtual bool	getScissorRect(Rect &) const = 0;
 		virtual const VertexDeclaration *getVertexDeclaration(bvertex_format) const = 0;
 		virtual const VertexDeclaration *getVertexDeclaration(bvertex_format) const = 0;
@@ -69,6 +78,10 @@ namespace oxygine
 		virtual void setTexture(int sampler, spNativeTexture) = 0;
 		virtual void setTexture(int sampler, spNativeTexture) = 0;
 		virtual void setState(STATE, unsigned int value) = 0;
 		virtual void setState(STATE, unsigned int value) = 0;
 		virtual void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest) = 0;
 		virtual void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest) = 0;
+
+		virtual void setDebugStats(bool enable) = 0;
+
+		virtual void swapped() = 0;
 	};		
 	};		
 
 
 	class VideoDriverNull: public IVideoDriver
 	class VideoDriverNull: public IVideoDriver
@@ -76,8 +89,10 @@ namespace oxygine
 	public:
 	public:
 		spNativeTexture createTexture();
 		spNativeTexture createTexture();
 
 
+
 		void begin(const Rect &viewport, const Color *clearColor);
 		void begin(const Rect &viewport, const Color *clearColor);
 		bool isReady() const {return true;}
 		bool isReady() const {return true;}
+		void getStats(Stats &s) const;
 		void getViewport(Rect &r) const;
 		void getViewport(Rect &r) const;
 		bool getScissorRect(Rect &) const;
 		bool getScissorRect(Rect &) const;
 		const VertexDeclaration*	getVertexDeclaration(bvertex_format) const;
 		const VertexDeclaration*	getVertexDeclaration(bvertex_format) const;
@@ -93,6 +108,8 @@ namespace oxygine
 		void setTexture(int sampler, spNativeTexture);
 		void setTexture(int sampler, spNativeTexture);
 		void setState(STATE, unsigned int value){}
 		void setState(STATE, unsigned int value){}
 		void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest){}
 		void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest){}
+		void swapped(){}
+		void setDebugStats(bool enable){}
 
 
 		void reset(){}
 		void reset(){}
 		void restore(){}
 		void restore(){}

+ 10 - 0
oxygine/src/core/ZipFileSystem.cpp

@@ -218,5 +218,15 @@ namespace file
 		handleErrorPolicy(ep, "can't find zip file entry: %s", file);
 		handleErrorPolicy(ep, "can't find zip file entry: %s", file);
 		return status_error;
 		return status_error;
 	}
 	}
+
+	FileSystem::status ZipFileSystem::_deleteFile(const char* file)
+	{
+		return status_error;
+	}
+
+	FileSystem::status ZipFileSystem::_renameFile(const char* src, const char *dest)
+	{
+		return status_error;
+	}
 }
 }
 }
 }

+ 4 - 1
oxygine/src/core/ZipFileSystem.h

@@ -53,7 +53,7 @@ namespace file
 	class ZipFileSystem: public FileSystem
 	class ZipFileSystem: public FileSystem
 	{
 	{
 	public:
 	public:
-		ZipFileSystem(){}
+		ZipFileSystem():FileSystem(true){}
 
 
 		void add(const char *zip);
 		void add(const char *zip);
 		void add(const unsigned char* data, unsigned int size);
 		void add(const unsigned char* data, unsigned int size);
@@ -64,6 +64,9 @@ namespace file
 		Zips _zips;
 		Zips _zips;
 
 
 		status _open(const char *file, const char *mode, error_policy ep, file::fileHandle *&fh);
 		status _open(const char *file, const char *mode, error_policy ep, file::fileHandle *&fh);
+		status _deleteFile(const char* file);
+		status _renameFile(const char* src, const char *dest);
+
 	};
 	};
 }
 }
 }
 }

+ 42 - 14
oxygine/src/core/file.cpp

@@ -33,7 +33,26 @@ namespace oxygine
 	namespace file
 	namespace file
 	{
 	{
 		string _additionalFolder;
 		string _additionalFolder;
-		STDFileSystem _nfs;
+		/*
+		FileSystem &getFS()
+		{
+			static bool initialized = false;
+			if (!initialized)
+			{
+
+			}
+			return ;
+		}
+		*/
+		STDFileSystem _nfs(true);
+		STDFileSystem _nfsWrite(false);
+		STDFileSystem _nfsExtended(true);
+
+		void init()
+		{
+			_nfs.mount(&_nfsWrite);
+			_nfs.mount(&_nfsExtended);
+		}
 
 
 		void mount(FileSystem *fs)
 		void mount(FileSystem *fs)
 		{
 		{
@@ -74,22 +93,26 @@ namespace oxygine
 			fh->release();
 			fh->release();
 		}
 		}
 
 
-		void deleteFile(const char *path)
+		bool deleteFile(const char *path, error_policy ep)
 		{
 		{
-#if __S3E__
-			s3eFileDelete(path);
-#else
-			log::warning("not implemented");
-#endif
+			bool ok = _nfs.deleteFile(path) == FileSystem::status_ok;
+			if (!ok)
+			{
+				handleErrorPolicy(ep, "can't delete file: %s", path);
+			}
+
+			return ok;
 		}
 		}
 
 
-		void rename(const char *src, const char *dest)
+		bool rename(const char *src, const char *dest, error_policy ep)
 		{
 		{
-#if __S3E__
-			s3eFileRename(src, dest);
-#else
-			log::warning("not implemented");
-#endif			
+			bool ok = _nfs.renameFile(src, dest) == FileSystem::status_ok;
+			if (!ok)
+			{
+				handleErrorPolicy(ep, "can't rename file: %s to %s", src, dest);
+			}
+
+			return ok;
 		}
 		}
 
 
 		unsigned int read(handle h, void *dest, unsigned int destSize)
 		unsigned int read(handle h, void *dest, unsigned int destSize)
@@ -166,12 +189,17 @@ namespace oxygine
 
 
 		void setExtendedFolder(const char *folder)
 		void setExtendedFolder(const char *folder)
 		{
 		{
-			_nfs.setExtendedFolder(folder);			
+			_nfsExtended.setPath(folder);			
 		}
 		}
 
 
 		file::FileSystem &fs()
 		file::FileSystem &fs()
 		{
 		{
 			return _nfs;
 			return _nfs;
 		}
 		}
+
+		file::FileSystem &wfs()
+		{
+			return _nfsWrite;
+		}
 	}
 	}
 }
 }

+ 5 - 2
oxygine/src/core/file.h

@@ -62,15 +62,18 @@ namespace oxygine
 		/**Is file exists?*/
 		/**Is file exists?*/
 		bool exists(const char *file);
 		bool exists(const char *file);
 
 
-		void deleteFile(const char *path);
-		void rename(const char *src, const char *dest);
+		bool deleteFile(const char *path, error_policy ep = ep_show_warning);
+		bool rename(const char *src, const char *dest, error_policy ep = ep_show_warning);
 		void makeDirectory(const char *path);
 		void makeDirectory(const char *path);
 		void deleteDirectory(const char *path);
 		void deleteDirectory(const char *path);
 
 
 		/**setExtendedFolder sets additional "hook" folder where files would be searched initially.*/
 		/**setExtendedFolder sets additional "hook" folder where files would be searched initially.*/
 		void setExtendedFolder(const char *folder);
 		void setExtendedFolder(const char *folder);
 
 
+		//returns main fs
 		file::FileSystem &fs();
 		file::FileSystem &fs();
+		//returns writable fs
+		file::FileSystem &wfs();
 
 
 		class autoClose
 		class autoClose
 		{
 		{

+ 4 - 5
oxygine/src/core/gl/ShaderProgramGL.cpp

@@ -24,11 +24,10 @@ namespace oxygine
 		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
 		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
 		if (length)
 		if (length)
 		{
 		{
-			char* buffer = (char*)malloc( sizeof(char) * length ) ;
-			glGetShaderInfoLog(shader, length, NULL, buffer);
-			if (buffer[0])
-				log::error("%s", buffer);
-			free(buffer);
+			vector<char> bf;
+			bf.resize(length);
+			glGetShaderInfoLog(shader, bf.size(), NULL, &bf.front());
+			log::message("shader compiled: %s", &bf.front());
 
 
 			GLint success;
 			GLint success;
 			glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
 			glGetShaderiv(shader, GL_COMPILE_STATUS, &success);

+ 28 - 3
oxygine/src/core/gl/VideoDriverGL.cpp

@@ -6,11 +6,18 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-	VideoDriverGL::VideoDriverGL():_prevFBO(0)
+	VideoDriverGL::VideoDriverGL():_prevFBO(0), _batches(0), _triangles(0),
+		_traceStats(true)
 	{
 	{
 
 
 	}
 	}
 
 
+	void	VideoDriverGL::getStats(Stats &s) const
+	{
+		s.batches = _batches;
+		s.triangles = _triangles;
+	}
+
 	unsigned int VideoDriverGL::getPT(IVideoDriver::PRIMITIVE_TYPE pt)
 	unsigned int VideoDriverGL::getPT(IVideoDriver::PRIMITIVE_TYPE pt)
 	{
 	{
 		switch (pt)
 		switch (pt)
@@ -30,7 +37,7 @@ namespace oxygine
 		case PT_TRIANGLE_FAN:
 		case PT_TRIANGLE_FAN:
 			return GL_TRIANGLE_FAN;
 			return GL_TRIANGLE_FAN;
 		}
 		}
-		OX_ASSERT(!"unknown primityve type");
+		OX_ASSERT(!"unknown primitive type");
 		return PT_POINTS;
 		return PT_POINTS;
 	}
 	}
 
 
@@ -58,6 +65,24 @@ namespace oxygine
 		OX_ASSERT(!"unknown blend");
 		OX_ASSERT(!"unknown blend");
 		return GL_ONE;
 		return GL_ONE;
 	}
 	}
+
+	void VideoDriverGL::_debugAddPrimitives(IVideoDriver::PRIMITIVE_TYPE pt, int num)
+	{
+		if (!_traceStats)
+			return;
+
+		switch(pt)
+		{
+		case PT_TRIANGLE_STRIP:
+			_triangles += num - 2;
+			break;
+		case PT_TRIANGLES:
+			_triangles += num / 3;
+			break;
+		}
+
+		_batches++;
+	}
 	
 	
 	bool VideoDriverGL::getScissorRect(Rect &r) const
 	bool VideoDriverGL::getScissorRect(Rect &r) const
 	{
 	{
@@ -127,7 +152,7 @@ namespace oxygine
 		else
 		else
 		{
 		{
 			glClear(GL_DEPTH_BUFFER_BIT);
 			glClear(GL_DEPTH_BUFFER_BIT);
-		}
+		}		
         CHECKGL();
         CHECKGL();
 	}
 	}
 
 

+ 8 - 0
oxygine/src/core/gl/VideoDriverGL.h

@@ -14,6 +14,7 @@ namespace oxygine
 	public:
 	public:
 		VideoDriverGL();
 		VideoDriverGL();
 
 
+		void	getStats(Stats &s) const;
 		void	getViewport(Rect &r) const;
 		void	getViewport(Rect &r) const;
 		bool	getScissorRect(Rect &) const;
 		bool	getScissorRect(Rect &) const;
 		const VertexDeclarationGL*	getVertexDeclaration(bvertex_format) const;
 		const VertexDeclarationGL*	getVertexDeclaration(bvertex_format) const;
@@ -24,13 +25,20 @@ namespace oxygine
 		void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest);
 		void setBlendFunc(BLEND_TYPE src, BLEND_TYPE dest);
 		void setState(STATE, unsigned int value);
 		void setState(STATE, unsigned int value);
 
 
+		void swapped(){_triangles = 0; _batches = 0;}
+
 	protected:
 	protected:
 		unsigned int getPT(IVideoDriver::PRIMITIVE_TYPE pt);
 		unsigned int getPT(IVideoDriver::PRIMITIVE_TYPE pt);
 		unsigned int getBT(IVideoDriver::BLEND_TYPE pt);
 		unsigned int getBT(IVideoDriver::BLEND_TYPE pt);
+		void _debugAddPrimitives(IVideoDriver::PRIMITIVE_TYPE pt, int num);
+		void setDebugStats(bool enable){_traceStats = enable;}
 
 
 		void _begin(const Rect &viewport, const Color *clearColor);
 		void _begin(const Rect &viewport, const Color *clearColor);
 		GLint _prevFBO;
 		GLint _prevFBO;
 
 
 		mutable VertexDeclarations<VertexDeclarationGL> _vdeclarations;
 		mutable VertexDeclarations<VertexDeclarationGL> _vdeclarations;
+		bool _traceStats;
+		int _batches;
+		int _triangles;
 	};
 	};
 }
 }

+ 12 - 1
oxygine/src/core/gl/VideoDriverGLES20.cpp

@@ -98,7 +98,8 @@ namespace oxygine
 			el++;
 			el++;
 		}
 		}
 
 
-		glDrawArrays(getPT(pt), 0, size / decl->size);
+		size_t primitives = size / decl->size;
+		glDrawArrays(getPT(pt), 0, primitives);
 
 
 		el = decl->elements;
 		el = decl->elements;
 		for (int i = 0; i < decl->numElements; ++i)		
 		for (int i = 0; i < decl->numElements; ++i)		
@@ -106,6 +107,11 @@ namespace oxygine
 			glDisableVertexAttribArray(el->index);
 			glDisableVertexAttribArray(el->index);
 			el++;
 			el++;
 		}
 		}
+
+
+#if OXYGINE_TRACE_VIDEO_STATS
+		_debugAddPrimitives(pt, primitives);
+#endif
         
         
         CHECKGL();
         CHECKGL();
 	}
 	}
@@ -132,6 +138,11 @@ namespace oxygine
 			glDisableVertexAttribArray(el->index);
 			glDisableVertexAttribArray(el->index);
 			el++;
 			el++;
 		}
 		}
+
+
+#if OXYGINE_TRACE_VIDEO_STATS
+		_debugAddPrimitives(pt, numIndices);
+#endif
         CHECKGL();
         CHECKGL();
 	}
 	}
 
 

+ 55 - 41
oxygine/src/core/gl/oxgl.h

@@ -12,54 +12,68 @@
 #else
 #else
 	#include "SDL_config.h"
 	#include "SDL_config.h"
 
 
-#if WIN32
-	#include "glew.h"
+	#if WIN32
+		#include "glew.h"
 
 
-	#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
-	#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
-	#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
-	#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
+		#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+		#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+		#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+		#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
 
 
-	#define GL_ETC1_RGB8_OES                                        0x8D64
+		#define GL_ETC1_RGB8_OES                                        0x8D64
 
 
-#elif __ANDROID__
-	#include "GLES2/gl2.h"
-	#define GL_GLEXT_PROTOTYPES 
-	#include "GLES2/gl2ext.h"
+	#elif __ANDROID__
+		#include "GLES2/gl2.h"
+		#define GL_GLEXT_PROTOTYPES 
+		#include "GLES2/gl2ext.h"
 
 
-	#define glGenFramebuffers			glGenFramebuffers
-	#define glBindFramebuffer			glBindFramebuffer
-	#define glFramebufferTexture2D		glFramebufferTexture2D
-	#define glDeleteFramebuffers		glDeleteFramebuffers
-	#define glCheckFramebufferStatus	glCheckFramebufferStatus
+		#define glGenFramebuffers			glGenFramebuffers
+		#define glBindFramebuffer			glBindFramebuffer
+		#define glFramebufferTexture2D		glFramebufferTexture2D
+		#define glDeleteFramebuffers		glDeleteFramebuffers
+		#define glCheckFramebufferStatus	glCheckFramebufferStatus
 
 
-	/*
-	#define GL_FRAMEBUFFER				GL_FRAMEBUFFER
-	#define GL_FRAMEBUFFER_BINDING		GL_FRAMEBUFFER_BINDING
-	#define GL_COLOR_ATTACHMENT0		GL_COLOR_ATTACHMENT0
-	#define GL_FRAMEBUFFER_COMPLETE		GL_FRAMEBUFFER_COMPLETE
-	*/
-#elif __APPLE__
-    #define GL_ETC1_RGB8_OES                                        0x8D64
-    #include <OpenGLES/ES2/gl.h>
-    #include <OpenGLES/ES2/glext.h>
-	#include <OpenGLES/ES1/gl.h>
-	#include <OpenGLES/ES1/glext.h>
-#elif __unix__
-	#define GL_GLEXT_PROTOTYPES
-	#include "SDL_opengl.h"
+		/*
+		#define GL_FRAMEBUFFER				GL_FRAMEBUFFER
+		#define GL_FRAMEBUFFER_BINDING		GL_FRAMEBUFFER_BINDING
+		#define GL_COLOR_ATTACHMENT0		GL_COLOR_ATTACHMENT0
+		#define GL_FRAMEBUFFER_COMPLETE		GL_FRAMEBUFFER_COMPLETE
+		*/
+	#elif __APPLE__
+	    #include <TargetConditionals.h>
+		#if TARGET_OS_IPHONE
+		    #define GL_ETC1_RGB8_OES                                        0x8D64
+		    #include <OpenGLES/ES2/gl.h>
+		    #include <OpenGLES/ES2/glext.h>
+		    #include <OpenGLES/ES1/gl.h>
+		    #include <OpenGLES/ES1/glext.h>
+		#else
+		    #define GL_GLEXT_PROTOTYPES
+		    #include "SDL_opengl.h"
 
 
-	#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
-	#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
-	#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
-	#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
+		    #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+		    #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+		    #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+		    #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
 
 
-	#define GL_ETC1_RGB8_OES                                        0x8D64
+		    #define GL_ETC1_RGB8_OES                                        0x8D64
+		#endif
 
 
+	#elif __unix__
+		#define GL_GLEXT_PROTOTYPES
+		#include "SDL_opengl.h"
+
+		#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+		#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+		#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+		#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
+
+		#define GL_ETC1_RGB8_OES                                        0x8D64
+	#endif
 #endif
 #endif
-#endif
-    namespace oxygine {void checkGLError();}
-	//#define CHECKGL() checkGLError()
-	#define CHECKGL() {}
 
 
-	void initGLExtensions();
+namespace oxygine {void checkGLError();}
+//#define CHECKGL() checkGLError()
+#define CHECKGL() {}
+
+void initGLExtensions();

+ 16 - 5
oxygine/src/core/oxygine.cpp

@@ -67,6 +67,15 @@ extern "C"
 
 
 namespace oxygine
 namespace oxygine
 {
 {
+	namespace file
+	{
+		void init();
+	}
+
+
+
+	IVideoDriver::Stats _videoStats;
+
     void checkGLError()
     void checkGLError()
     {
     {
         int gl_error = glGetError();
         int gl_error = glGetError();
@@ -425,6 +434,8 @@ namespace oxygine
 
 
             checkGLError();
             checkGLError();
 			log::messageln("oxygine initialized");
 			log::messageln("oxygine initialized");
+
+			file::init();
 		}
 		}
 
 
 #ifdef OXYGINE_SDL
 #ifdef OXYGINE_SDL
@@ -492,16 +503,16 @@ namespace oxygine
 			}
 			}
 #endif
 #endif
 
 
+			IVideoDriver::instance->getStats(_videoStats);
+			IVideoDriver::instance->swapped();
+
 			checkGLError();
 			checkGLError();
+
+			//sleep(1000/50);
 		}
 		}
 
 
 		bool update()
 		bool update()
 		{
 		{
-			Renderer::statsPrev = Renderer::statsCurrent;
-			Renderer::statsCurrent = Renderer::Stats();
-
-
-
 #ifdef __S3E__
 #ifdef __S3E__
 
 
 			s3eDeviceYield(0);
 			s3eDeviceYield(0);

+ 3 - 3
oxygine/src/dev_tools/TexturesInspector.cpp

@@ -39,7 +39,7 @@ namespace oxygine
 			addChild(image);
 			addChild(image);
 
 
 			spColorRectSprite rect = initActor(new ColorRectSprite,
 			spColorRectSprite rect = initActor(new ColorRectSprite,
-				arg_color = Color(255,255,255,128),
+				arg_color = Color(Color::White, 128),
 				arg_attachTo = this);
 				arg_attachTo = this);
 
 
 			char path[255];
 			char path[255];
@@ -52,7 +52,7 @@ namespace oxygine
 				t->getWidth(), t->getHeight(), t->getObjectID());
 				t->getWidth(), t->getHeight(), t->getObjectID());
 
 
 			spTextActor text = initActor(new TextActor,
 			spTextActor text = initActor(new TextActor,
-				arg_tcolor = Color(0,0,0,255),
+				arg_color = Color::Black,
 				arg_w = (float)itemSize.x,
 				arg_w = (float)itemSize.x,
 				arg_vAlign = TextStyle::VALIGN_TOP,
 				arg_vAlign = TextStyle::VALIGN_TOP,
 				arg_hAlign = TextStyle::HALIGN_LEFT,
 				arg_hAlign = TextStyle::HALIGN_LEFT,
@@ -83,7 +83,7 @@ namespace oxygine
 
 
 		
 		
 		spTextActor text = initActor(new TextActor,
 		spTextActor text = initActor(new TextActor,
-			arg_tcolor = Color(255, 255, 255, 255),
+			arg_color = Color::White,
 			arg_w = itemSize.x * 3.0f,
 			arg_w = itemSize.x * 3.0f,
 			arg_h = 30.0f,
 			arg_h = 30.0f,
 			arg_vAlign = TextStyle::VALIGN_TOP,
 			arg_vAlign = TextStyle::VALIGN_TOP,

+ 1 - 1
oxygine/src/dev_tools/TreeInspectorLine.cpp

@@ -32,7 +32,7 @@ namespace oxygine
 		
 		
 		spTextActor tb = new TextActor();
 		spTextActor tb = new TextActor();
 		tb->setInputEnabled(false);
 		tb->setInputEnabled(false);
-		tb->setColor(Color(0,0,0,255));
+		tb->setColor(Color::Black);
 	
 	
 		const float minWidth = 300.0f;
 		const float minWidth = 300.0f;
 
 

+ 5 - 4
oxygine/src/initActor.h

@@ -57,8 +57,8 @@ namespace oxygine
 		typedef argT<unsigned char, unsigned char, Actor, &Actor::setAlpha> alpha;	
 		typedef argT<unsigned char, unsigned char, Actor, &Actor::setAlpha> alpha;	
 		typedef argT<bool, bool, Actor, &Actor::setInputEnabled> input;
 		typedef argT<bool, bool, Actor, &Actor::setInputEnabled> input;
 		typedef argT<Actor*, Actor*, Actor, &Actor::attachTo> attachTo;
 		typedef argT<Actor*, Actor*, Actor, &Actor::attachTo> attachTo;
-		typedef argT<Color, const Color &, Sprite, &Sprite::setColor> color;
-		typedef argT<blend_mode, blend_mode, Sprite, &Sprite::setBlendMode> blend;
+		typedef argT<Color, const Color &, VStyleActor, &VStyleActor::setColor> color;
+		typedef argT<blend_mode, blend_mode, VStyleActor, &VStyleActor::setBlendMode> blend;
 		typedef argT<short, short, Actor, &Actor::setPriority> priority;
 		typedef argT<short, short, Actor, &Actor::setPriority> priority;
 		typedef argT<void*, void*, ObjectBase, &ObjectBase::setUserData> userData;
 		typedef argT<void*, void*, ObjectBase, &ObjectBase::setUserData> userData;
 		typedef argT<char, char, Actor, &Actor::setExtendedClickArea> extendedClickArea;
 		typedef argT<char, char, Actor, &Actor::setExtendedClickArea> extendedClickArea;
@@ -69,8 +69,8 @@ namespace oxygine
 		typedef argT<TextStyle::HorizontalAlign, TextStyle::HorizontalAlign, TextActor, &TextActor::setHAlign> hAlign;	
 		typedef argT<TextStyle::HorizontalAlign, TextStyle::HorizontalAlign, TextActor, &TextActor::setHAlign> hAlign;	
 		typedef argT<TextStyle::VerticalAlign, TextStyle::VerticalAlign, TextActor, &TextActor::setVAlign> vAlign;	
 		typedef argT<TextStyle::VerticalAlign, TextStyle::VerticalAlign, TextActor, &TextActor::setVAlign> vAlign;	
 		typedef argT<int, int, TextActor, &TextActor::setFontSize2Scale> fontSize2Scale;	
 		typedef argT<int, int, TextActor, &TextActor::setFontSize2Scale> fontSize2Scale;	
+		typedef argT<Font*, Font*, TextActor, &TextActor::setFont> font;	
 		typedef argT<bool, bool, TextActor, &TextActor::setMultiline> multiline;
 		typedef argT<bool, bool, TextActor, &TextActor::setMultiline> multiline;
-		typedef argT<Color, const Color &, TextActor, &TextActor::setColor> tcolor;
 
 
 
 
 		class animFrame
 		class animFrame
@@ -163,8 +163,9 @@ namespace oxygine
 #define arg_hAlign args::hAlign()
 #define arg_hAlign args::hAlign()
 #define arg_vAlign args::vAlign()
 #define arg_vAlign args::vAlign()
 #define arg_fontSize2Scale args::fontSize2Scale()
 #define arg_fontSize2Scale args::fontSize2Scale()
+#define arg_font args::font()
 #define arg_multiline args::multiline()
 #define arg_multiline args::multiline()
-#define arg_tcolor args::tcolor()//fix
+#define arg_tcolor args::color()
 //Button
 //Button
 #define arg_onClick args::onClick()
 #define arg_onClick args::onClick()
 
 

+ 160 - 3
oxygine/src/math/Color.h

@@ -7,15 +7,160 @@ namespace oxygine
 	class Color
 	class Color
 	{
 	{
 	public:
 	public:
+		enum
+		{
+			AliceBlue            = 0xF0F8FFFF,
+			AntiqueWhite         = 0xFAEBD7FF,
+			Aqua                 = 0x00FFFFFF,
+			Aquamarine           = 0x7FFFD4FF,
+			Azure                = 0xF0FFFFFF,
+			Beige                = 0xF5F5DCFF,
+			Bisque               = 0xFFE4C4FF,
+			Black                = 0x000000FF,
+			BlanchedAlmond       = 0xFFEBCDFF,
+			Blue                 = 0x0000FFFF,
+			BlueViolet           = 0x8A2BE2FF,
+			Brown                = 0xA52A2AFF,
+			BurlyWood            = 0xDEB887FF,
+			CadetBlue            = 0x5F9EA0FF,
+			Chartreuse           = 0x7FFF00FF,
+			Chocolate            = 0xD2691EFF,
+			Coral                = 0xFF7F50FF,
+			CornflowerBlue       = 0x6495EDFF,
+			Cornsilk             = 0xFFF8DCFF,
+			Crimson              = 0xDC143CFF,
+			Cyan                 = 0x00FFFFFF,
+			DarkBlue             = 0x00008BFF,
+			DarkCyan             = 0x008B8BFF,
+			DarkGoldenrod        = 0xB8860BFF,
+			DarkGray             = 0xA9A9A9FF,
+			DarkGreen            = 0x006400FF,
+			DarkKhaki            = 0xBDB76BFF,
+			DarkMagenta          = 0x8B008BFF,
+			DarkOliveGreen       = 0x556B2FFF,
+			DarkOrange           = 0xFF8C00FF,
+			DarkOrchid           = 0x9932CCFF,
+			DarkRed              = 0x8B0000FF,
+			DarkSalmon           = 0xE9967AFF,
+			DarkSeaGreen         = 0x8FBC8BFF,
+			DarkSlateBlue        = 0x483D8BFF,
+			DarkSlateGray        = 0x2F4F4FFF,
+			DarkTurquoise        = 0x00CED1FF,
+			DarkViolet           = 0x9400D3FF,
+			DeepPink             = 0xFF1493FF,
+			DeepSkyBlue          = 0x00BFFFFF,
+			DimGray              = 0x696969FF,
+			DodgerBlue           = 0x1E90FFFF,
+			Firebrick            = 0xB22222FF,
+			FloralWhite          = 0xFFFAF0FF,
+			ForestGreen          = 0x228B22FF,
+			Fuchsia              = 0xFF00FFFF,
+			Gainsboro            = 0xDCDCDCFF,
+			GhostWhite           = 0xF8F8FFFF,
+			Gold                 = 0xFFD700FF,
+			Goldenrod            = 0xDAA520FF,
+			Gray                 = 0x808080FF,
+			Green                = 0x008000FF,
+			GreenYellow          = 0xADFF2FFF,
+			Honeydew             = 0xF0FFF0FF,
+			HotPink              = 0xFF69B4FF,
+			IndianRed            = 0xCD5C5CFF,
+			Indigo               = 0x4B0082FF,
+			Ivory                = 0xFFFFF0FF,
+			Khaki                = 0xF0E68CFF,
+			Lavender             = 0xE6E6FAFF,
+			LavenderBlush        = 0xFFF0F5FF,
+			LawnGreen            = 0x7CFC00FF,
+			LemonChiffon         = 0xFFFACDFF,
+			LightBlue            = 0xADD8E6FF,
+			LightCoral           = 0xF08080FF,
+			LightCyan            = 0xE0FFFFFF,
+			LightGoldenrodYellow = 0xFAFAD2FF,
+			LightGray            = 0xD3D3D3FF,
+			LightGreen           = 0x90EE90FF,
+			LightPink            = 0xFFB6C1FF,
+			LightSalmon          = 0xFFA07AFF,
+			LightSeaGreen        = 0x20B2AAFF,
+			LightSkyBlue         = 0x87CEFAFF,
+			LightSlateGray       = 0x778899FF,
+			LightSteelBlue       = 0xB0C4DEFF,
+			LightYellow          = 0xFFFFE0FF,
+			Lime                 = 0x00FF00FF,
+			LimeGreen            = 0x32CD32FF,
+			Linen                = 0xFAF0E6FF,
+			Magenta              = 0xFF00FFFF,
+			Maroon               = 0x800000FF,
+			MediumAquamarine     = 0x66CDAAFF,
+			MediumBlue           = 0x0000CDFF,
+			MediumOrchid         = 0xBA55D3FF,
+			MediumPurple         = 0x9370DBFF,
+			MediumSeaGreen       = 0x3CB371FF,
+			MediumSlateBlue      = 0x7B68EEFF,
+			MediumSpringGreen    = 0x00FA9AFF,
+			MediumTurquoise      = 0x48D1CCFF,
+			MediumVioletRed      = 0xC71585FF,
+			MidnightBlue         = 0x191970FF,
+			MintCream            = 0xF5FFFAFF,
+			MistyRose            = 0xFFE4E1FF,
+			Moccasin             = 0xFFE4B5FF,
+			NavajoWhite          = 0xFFDEADFF,
+			Navy                 = 0x000080FF,
+			OldLace              = 0xFDF5E6FF,
+			Olive                = 0x808000FF,
+			OliveDrab            = 0x6B8E23FF,
+			Orange               = 0xFFA500FF,
+			OrangeRed            = 0xFF4500FF,
+			Orchid               = 0xDA70D6FF,
+			PaleGoldenrod        = 0xEEE8AAFF,
+			PaleGreen            = 0x98FB98FF,
+			PaleTurquoise        = 0xAFEEEEFF,
+			PaleVioletRed        = 0xDB7093FF,
+			PapayaWhip           = 0xFFEFD5FF,
+			PeachPuff            = 0xFFDAB9FF,
+			Peru                 = 0xCD853FFF,
+			Pink                 = 0xFFC0CBFF,
+			Plum                 = 0xDDA0DDFF,
+			PowderBlue           = 0xB0E0E6FF,
+			Purple               = 0x800080FF,
+			Red                  = 0xFF0000FF,
+			RosyBrown            = 0xBC8F8FFF,
+			RoyalBlue            = 0x4169E1FF,
+			SaddleBrown          = 0x8B4513FF,
+			Salmon               = 0xFA8072FF,
+			SandyBrown           = 0xF4A460FF,
+			SeaGreen             = 0x2E8B57FF,
+			SeaShell             = 0xFFF5EEFF,
+			Sienna               = 0xA0522DFF,
+			Silver               = 0xC0C0C0FF,
+			SkyBlue              = 0x87CEEBFF,
+			SlateBlue            = 0x6A5ACDFF,
+			SlateGray            = 0x708090FF,
+			Snow                 = 0xFFFAFAFF,
+			SpringGreen          = 0x00FF7FFF,
+			SteelBlue            = 0x4682B4FF,
+			Tan                  = 0xD2B48CFF,
+			Teal                 = 0x008080FF,
+			Thistle              = 0xD8BFD8FF,
+			Tomato               = 0xFF6347FF,
+			Turquoise            = 0x40E0D0FF,
+			Violet               = 0xEE82EEFF,
+			Wheat                = 0xF5DEB3FF,
+			White                = 0xFFFFFFFF,
+			WhiteSmoke           = 0xF5F5F5FF,
+			Yellow               = 0xFFFF00FF,
+			YellowGreen          = 0x9ACD32FF
+		};
+
 		Color():argb(0xffffffff){}
 		Color():argb(0xffffffff){}
-		explicit Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+		Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255)
 		{
 		{
 			this->a = a;
 			this->a = a;
 			this->r = r;
 			this->r = r;
 			this->g = g;
 			this->g = g;
 			this->b = b;
 			this->b = b;
 		}
 		}
-		explicit Color(unsigned int rgba)
+
+		Color(unsigned int rgba)
 		{
 		{
 			r = rgba >> 24;
 			r = rgba >> 24;
 			g = (rgba >> 16) & 0xFF;
 			g = (rgba >> 16) & 0xFF;
@@ -23,7 +168,14 @@ namespace oxygine
 			a = rgba & 0xFF;
 			a = rgba & 0xFF;
 		}
 		}
 
 
-
+		/**initializes color by RGBA and replaces alpha*/
+		Color(unsigned int rgba, unsigned char a)
+		{
+			r = rgba >> 24;
+			g = (rgba >> 16) & 0xFF;
+			b = (rgba >> 8) & 0xFF;
+			a = a;
+		}
 
 
 		unsigned char operator [](int i) const
 		unsigned char operator [](int i) const
 		{
 		{
@@ -42,6 +194,11 @@ namespace oxygine
 			return c;
 			return c;
 		}
 		}
 
 
+		static Color RGB(int rgb)
+		{
+			return Color(rgb >> 16 , (rgb >> 8) & 0xff, rgb & 0xff);
+		}
+
 		static Color interpolate(const Color &a, const Color &b, float v)
 		static Color interpolate(const Color &a, const Color &b, float v)
 		{
 		{
 			Color c;
 			Color c;

+ 1 - 0
oxygine/src/oxygine_include.h

@@ -33,6 +33,7 @@
 	#define OXYGINE_DEBUG_OBJECTS 1
 	#define OXYGINE_DEBUG_OBJECTS 1
 	#define OXYGINE_DEBUG_T2P 1
 	#define OXYGINE_DEBUG_T2P 1
 	#define OXYGINE_DEBUG_SAFECAST 1
 	#define OXYGINE_DEBUG_SAFECAST 1
+	#define OXYGINE_TRACE_VIDEO_STATS 1
 #endif
 #endif
 
 
 #define OXYGINE_ASSERT2LOG 1
 #define OXYGINE_ASSERT2LOG 1