Changeset 48
- Timestamp:
- 07/13/07 17:30:32 (1 year ago)
- Files:
-
- trunk/res/test/clearInactive.png (added)
- trunk/res/test/clearInactive2.png (added)
- trunk/src/demo2/main.d (modified) (3 diffs)
- trunk/src/yage/gui/surface.d (modified) (3 diffs)
- trunk/src/yage/node/camera.d (modified) (1 diff)
- trunk/src/yage/system/input.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/demo2/main.d
r46 r48 59 59 60 60 Surface bg = new Surface(null); 61 bg.topLeft = Vec2f(.05,.05); 62 bg.bottomRight = Vec2f(.95, .95); 63 bg.setTexture(new GPUTexture("test2.png")); 64 bg.fill = stretched; 61 bg.setTexture(camera.getTexture()); 62 bg.topLeft = Vec2f(0,0); 63 bg.bottomRight = Vec2f(1, 1); 65 64 bg.setVisibility(true); 66 67 Surface disp = new Surface(bg); 68 disp.topLeft = Vec2f(.1,.1); 69 disp.bottomRight = Vec2f(.9, .9); 70 disp.setTexture(new GPUTexture("test/bc-dark.png")); 71 //disp.fill = stretched; 72 disp.setVisibility(true); 73 74 Surface first = new Surface(disp); 75 first.setTexture(new GPUTexture("test.png")); 76 first.fill = stretched; 77 first.topLeft = Vec2f(.8, .8); 78 first.bottomRight = Vec2f(.95, .95); 79 first.setVisibility(true); 80 81 Surface third = new Surface(disp); 82 third.setTexture(new GPUTexture("box.png")); 83 third.fill = stretched; 84 third.topLeft = Vec2f(.8, .05); 85 third.bottomRight = Vec2f(.95, .2); 86 third.setVisibility(true); 87 88 Surface fourth = new Surface(disp); 89 fourth.setTexture(new GPUTexture("test/button2.png")); 90 fourth.fill = stretched; 91 fourth.topLeft = Vec2f(.05, .8); 92 fourth.bottomRight = Vec2f(.2, .95); 93 fourth.setVisibility(true); 94 95 Surface fifth = new Surface(disp); 96 fifth.setTexture(new GPUTexture("test/radio1.png")); 97 fifth.fill = stretched; 98 fifth.topLeft = Vec2f(.05, .05); 99 fifth.bottomRight = Vec2f(.2, .2); 100 fifth.setVisibility(true); 101 102 Surface second = new Surface(disp); 103 second.setTexture(camera.getTexture()); 104 second.topLeft = Vec2f(.2,.2); 105 second.bottomRight = Vec2f(.8, .8); 106 second.setVisibility(true); 107 108 Surface clear = new Surface(second); 109 clear.setTexture(new GPUTexture("test/clear.png")); 110 clear.topLeft = Vec2f(.1,.1); 111 clear.bottomRight = Vec2f(.9, .9); 112 clear.fill = stretched; 113 clear.setVisibility(true); 114 65 115 66 void onMousedown(Surface self, byte buttons, Vec2i coordinates){ 116 67 self.raise(); … … 126 77 } 127 78 79 bg.onMousedown = &onMousedown; 80 bg.onResize = &onResize; 81 82 GPUTexture active = new GPUTexture("test/clear.png"); 83 GPUTexture inactive = new GPUTexture("test/clearInactive.png"); 84 GPUTexture inactive2 = new GPUTexture("test/clearInactive2.png"); 85 128 86 void onMousedown2(Surface self, byte buttons, Vec2i coordinates){ 129 87 self.raise(); … … 136 94 if(buttons == 1) self.drag(coordinates); 137 95 } 138 139 second.onMousedown = &onMousedown; 140 second.onResize = &onResize; 96 void onMouseenter(Surface self, byte buttons, Vec2i coordinates){ 97 self.setTexture(active); 98 } 99 void onMouseleave(Surface self, byte buttons, Vec2i coordinates){ 100 self.setTexture(inactive2); 101 } 102 103 Surface clear = new Surface(bg); 104 clear.setTexture(inactive); 105 clear.topLeft = Vec2f(.65,0); 106 clear.bottomRight = Vec2f(1, .25); 107 clear.fill = stretched; 108 clear.setVisibility(true); 141 109 clear.onMousedown = &onMousedown2; 142 110 clear.onMousemove = &onMousemove; 143 111 clear.onMouseup = &onMouseup2; 144 first.onMousedown = &onMousedown2; 145 first.onMousemove = &onMousemove; 146 first.onMouseup = &onMouseup2; 147 148 bg.onMousedown = &onMousedown2; 149 bg.onMousemove = &onMousemove; 150 bg.onMouseup = &onMouseup2; 112 clear.onMouseenter = &onMouseenter; 113 clear.onMouseleave = &onMouseleave; 114 115 Surface clear2 = new Surface(clear); 116 clear2.setTexture(inactive); 117 clear2.topLeft = Vec2f(.65,0); 118 clear2.bottomRight = Vec2f(1, .25); 119 clear2.fill = stretched; 120 clear2.setVisibility(true); 121 clear2.onMousedown = &onMousedown2; 122 clear2.onMousemove = &onMousemove; 123 clear2.onMouseup = &onMouseup2; 124 clear2.onMouseenter = &onMouseenter; 125 clear2.onMouseleave = &onMouseleave; 126 127 Surface clear3 = new Surface(bg); 128 clear3.setTexture(inactive); 129 clear3.topLeft = Vec2f(.65,0); 130 clear3.bottomRight = Vec2f(1, .25); 131 clear3.fill = stretched; 132 clear3.setVisibility(true); 133 clear3.onMousedown = &onMousedown2; 134 clear3.onMousemove = &onMousemove; 135 clear3.onMouseup = &onMouseup2; 136 clear3.onMouseenter = &onMouseenter; 137 clear3.onMouseleave = &onMouseleave; 151 138 152 139 // Music trunk/src/yage/gui/surface.d
r46 r48 59 59 60 60 bool visible; 61 bool mouseIn; 61 62 62 63 byte fill = traditional; … … 93 94 } 94 95 95 void delegate(typeof(this) self, byte buttons, Vec2i coordinates) onMouseout; 96 97 void delegate(typeof(this) self, byte buttons, Vec2i coordinates) onMouseover; 98 96 void delegate(typeof(this) self, byte buttons, Vec2i coordinates) onMouseleave; 97 void mouseleave(Surface next, byte buttons, Vec2i coordinates){ 98 if(mouseIn == true){ 99 if(isSub(next)) 100 return; 101 else{ 102 mouseIn = false; 103 if(onMouseleave) 104 onMouseleave(this, buttons, coordinates); 105 106 if(next !is parent && parent !is null) 107 parent.mouseleave(next, buttons, coordinates); 108 } 109 } 110 } 111 112 void delegate(typeof(this) self, byte buttons, Vec2i coordinates) onMouseenter; 113 void mouseenter(byte buttons, Vec2i coordinates){ 114 if(mouseIn == false){ 115 if(parent !is null) parent.mouseenter(buttons, coordinates); 116 117 mouseIn = true; 118 if(onMouseenter) onMouseenter(this, buttons, coordinates); 119 } 120 } 121 99 122 void delegate(typeof(this) self, byte buttons, Vec2i coordinates) onMouseup; //Done 100 123 void mouseup(byte buttons, Vec2i coordinates){ … … 473 496 } 474 497 if(onFocus) onFocus(this); 475 } 498 } 499 500 bool isSub(Surface surf){ 501 foreach(sub; subs){ 502 if (sub == surf) return true; 503 } 504 return false; 505 } 476 506 } 477 507 trunk/src/yage/node/camera.d
r36 r48 171 171 if (xres > max) xres = max; 172 172 if (yres > max) yres = max; 173 174 aspect = cast(float)width / cast(float)height; 173 175 } 174 176 trunk/src/yage/system/input.d
r46 r48 45 45 46 46 static Surface surfaceLock; 47 static Surface currentSurface; 47 48 48 49 /** This function fills the above fields with the current intput data. … … 81 82 button[event.button.button].ydown = mousey; 82 83 83 auto surface = currentSurface();84 auto surface = getSurface(); 84 85 85 86 if(surface !is null) surface.mousedown(event.button.button, Vec2i(mousex,mousey)); … … 92 93 button[event.button.button].yup = mousey; 93 94 94 auto surface = currentSurface();95 auto surface = getSurface(); 95 96 96 97 if(surface !is null) surface.mouseup(event.button.button, Vec2i(mousex,mousey)); … … 111 112 mousey = event.motion.y; 112 113 113 auto surface = currentSurface();114 auto surface = getSurface(); 114 115 115 if(surface !is null) surface.mousemove(event.button.button, Vec2i(xdiff,ydiff)); 116 //if the surface that the mouse is in has changed 117 if(currentSurface !is surface){ 118 //If the old surface is not device 119 if(currentSurface !is null) 120 //Tell it that the mouse left 121 currentSurface.mouseleave(surface, event.button.button, Vec2i(mousex,mousey)); 122 //If the new surface is not device 123 if(surface !is null) 124 //Tell it that the mosue entered 125 surface.mouseenter(event.button.button, Vec2i(mousex,mousey)); 126 127 //The new current surface 128 currentSurface = surface; 129 } 130 //Needs to be changed so that check is run once 131 if(surface !is null) 132 surface.mousemove(event.button.button, Vec2i(xdiff,ydiff)); 133 116 134 break; 117 135 … … 165 183 } 166 184 167 static Surface currentSurface(){185 static Surface getSurface(){ 168 186 if(surfaceLock) return surfaceLock; 169 187 return findSurface(mousex, mousey);
