AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
00001 // 00002 // 00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine 00004 // 00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk 00006 // 00007 // For updates, tutorials and more details check out www.appeasymobile.com 00008 // 00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin. 00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support 00011 // 00012 // 00013 00014 #if !defined(_CCZ_UI_IMAGE_VIEW_H_) 00015 #define _CCZ_UI_IMAGE_VIEW_H_ 00016 00017 #include "CzUIBase.h" 00018 #include "CzUIIcon.h" 00019 #include "CzScene.h" 00020 #include "CzBrush.h" 00021 #include "CzInput.h" 00022 00023 // 00024 // 00025 // 00026 // 00027 // CzUIImageView - UI class that allows the user to navugate a large image 00028 // 00029 // 00030 // 00031 // 00032 class CzUIImageView : public CzUIBase 00033 { 00034 public: 00035 // Properties 00036 protected: 00037 CzUIIcon* Icon; ///< The ico0n that is used to display the image 00038 CzIVec2 Area; ///< The area that the image should fit into 00039 float Zoom; ///< Current zoom 00040 float MinZoom; ///< The minimum zoom point 00041 float MaxZoom; ///< The maximum zoom point 00042 public: 00043 CzUIIcon* getIcon() { return Icon; } 00044 void setArea(CzIVec2& size); 00045 CzIVec2 getArea() const { return Area; } 00046 void setZoom(float scale); 00047 float getZoom() const { return Zoom; } 00048 void setMinZoom(float scale) { MinZoom = scale; } 00049 float getMinZoom() const { return MinZoom; } 00050 void setMaxZoom(float scale) { MaxZoom = scale; } 00051 float getMaxZoom() const { return MaxZoom; } 00052 00053 // Properties end 00054 protected: 00055 float PrevZoom; 00056 CzVec2 Midpoint; 00057 bool ZoomValid; 00058 float PreviousDist; 00059 float CompoundScale; 00060 CzVec2 CompoundPosition; 00061 float SavedCompoundScale; 00062 CzVec2 SavedCompoundPosition; 00063 CzVec2 PanVelocity; 00064 int TouchIndices[2]; 00065 int NumTouches; 00066 bool setProperty(unsigned int property_name, const CzXomlProperty& data, bool delta); 00067 bool setProperty(unsigned int property_name, const CzString& data, bool delta); 00068 bool getProperty(unsigned int property_name, CzXomlProperty& prop); 00069 bool UpdateBinding(unsigned int property_name, CzXomlVariable* var); 00070 public: 00071 CzUIImageView(); 00072 00073 virtual bool InitView(IzBrush* brush, int width, int height, bool native_res, float min_scale, float max_scale); 00074 00075 bool Update(float dt); 00076 bool UpdateVisual(); 00077 00078 // Event handlers 00079 void NotifyBeginTouch(int index, int x, int y, bool allow_bubble); 00080 void NotifyEndTouch(int index, int x, int y, bool allow_bubble); 00081 00082 // Implementation of IzXomlClass interface 00083 int LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node); 00084 00085 // Implementation of IzAnimTarget interface 00086 bool UpdateFromAnimation(CzAnimInstance *animation); 00087 00088 // Internal (used by XOML system to setup and cleanup the XOML class properties system 00089 protected: 00090 static CzXomlClassDef* ImageViewClassDef; // XOML class definition 00091 public: 00092 static void InitClass(); 00093 static void ReleaseClass(); 00094 00095 static bool _setMinZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add); 00096 static CzXomlProperty _getMinZoom(IzXomlResource* target); 00097 static bool _setMaxZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add); 00098 static CzXomlProperty _getMaxZoom(IzXomlResource* target); 00099 static bool _setZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add); 00100 static CzXomlProperty _getZoom(IzXomlResource* target); 00101 static bool _setImageBrush(IzXomlResource* target, const CzXomlProperty& prop, bool add); 00102 static CzXomlProperty _getImageBrush(IzXomlResource* target); 00103 static bool _setArea(IzXomlResource* target, const CzXomlProperty& prop, bool add); 00104 static CzXomlProperty _getArea(IzXomlResource* target); 00105 }; 00106 00107 // 00108 // CzUIImageViewCreator - Creates an instance of a ImageView actor object 00109 // 00110 class CzUIImageViewCreator : public IzXomlClassCreator 00111 { 00112 public: 00113 CzUIImageViewCreator() 00114 { 00115 setClassName("imageview"); 00116 } 00117 IzXomlResource* CreateInstance(IzXomlResource* parent) { return new CzUIImageView(); } 00118 }; 00119 00120 #endif // _CCZ_UI_IMAGE_VIEW_H_