diff UI code/targetSymbol.h @ 0:a223551fdc1f

First commit - copy from tweakathlon.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 10 Oct 2014 11:46:42 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/targetSymbol.h	Fri Oct 10 11:46:42 2014 +0100
@@ -0,0 +1,84 @@
+//
+//  targetSymbol.h
+//  tweakathlon
+//
+//  Created by Robert Tubb on 11/02/2014.
+//
+//
+
+#ifndef __tweakathlon__targetSymbol__
+#define __tweakathlon__targetSymbol__
+
+#include <iostream>
+#include "UIElement.h"
+#include "timeController.h"
+extern TimeController timeController;
+class TargetSymbol : public UIElement {
+public:
+    
+    TargetSymbol(int ax, int ay,int aw, const UIProps& props):
+    UIElement(ax,ay,aw,aw, props)
+    {
+        foregroundHi = props.buttonHi;
+        backgroundHi = props.generalBackground;
+        foregroundLo = props.inactiveGreyedOut; // can't be touched
+        backgroundLo = props.generalBackground;
+        flashing = false;
+        on = false;
+    };
+    
+    void draw(){
+        if(hidden)return;
+        //UIElement::draw(); // don't do background
+        ofColor fg,bg;
+        
+        if(on){
+            fg = foregroundHi;
+            bg = backgroundHi;
+        }else{
+            fg = foregroundLo;
+            bg = backgroundLo;
+        }
+        ofSetColor(fg);
+
+        ofEllipse(x,y,width,height);
+        
+        ofSetColor(bg);
+        ofEllipse(x,y,width*0.66,height*0.66);
+        
+        ofSetColor(fg);
+        ofEllipse(x,y,width*0.33,height*0.33);
+        
+    };
+    
+    void flash(){
+        // turn hilight on and off
+        if (!flashing){
+            setHighlight(true);
+            
+            // set up timer
+            TimerCallbackFunction tcb;
+            tcb = boost::bind(&TargetSymbol::flash, this);
+            timeController.scheduleEvent(tcb, int(ALTERNATION_SPEED/4));
+            flashing = true;
+        }else{
+            setHighlight(false);
+            
+            flashing = false;
+        }
+        
+    }
+    
+    bool handleMyTouch(int x, int y, touchType ttype, int touchID){
+        return false; // or?
+    }
+    
+private:
+    ofColor foregroundHi;
+    ofColor backgroundHi;
+    ofColor foregroundLo;
+    ofColor backgroundLo;
+    ofColor fgInactive;
+    bool flashing;
+};
+#endif /* defined(__tweakathlon__targetSymbol__) */