r2855 - in trunk/data/qcsrc/menu-div0test: . item nexuiz oo

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Oct 27 05:43:31 EDT 2007


Author: div0
Date: 2007-10-27 05:43:30 -0400 (Sat, 27 Oct 2007)
New Revision: 2855

Added:
   trunk/data/qcsrc/menu-div0test/basecheckbox_c0.tga
   trunk/data/qcsrc/menu-div0test/basecheckbox_c1.tga
   trunk/data/qcsrc/menu-div0test/basecheckbox_f0.tga
   trunk/data/qcsrc/menu-div0test/basecheckbox_f1.tga
   trunk/data/qcsrc/menu-div0test/basecheckbox_n0.tga
   trunk/data/qcsrc/menu-div0test/basecheckbox_n1.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_c0.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_c1.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_f0.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_f1.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_n0.tga
   trunk/data/qcsrc/menu-div0test/baseradiobutton_n1.tga
   trunk/data/qcsrc/menu-div0test/item/checkbox.c
   trunk/data/qcsrc/menu-div0test/item/radiobutton.c
Modified:
   trunk/data/qcsrc/menu-div0test/classes.c
   trunk/data/qcsrc/menu-div0test/item/button.c
   trunk/data/qcsrc/menu-div0test/item/label.c
   trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
   trunk/data/qcsrc/menu-div0test/item/nexposee.c
   trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c
   trunk/data/qcsrc/menu-div0test/oo/constructors.h
Log:
added checkbox, radio button; removed unnecessary setFocus override in Nexposee and ModalController


Added: trunk/data/qcsrc/menu-div0test/basecheckbox_c0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_c0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basecheckbox_c1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_c1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basecheckbox_f0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_f0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basecheckbox_f1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_f1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basecheckbox_n0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_n0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basecheckbox_n1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basecheckbox_n1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_c0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_c0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_c1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_c1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_f0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_f0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_f1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_f1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_n0.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_n0.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/baseradiobutton_n1.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/baseradiobutton_n1.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/data/qcsrc/menu-div0test/classes.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/classes.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/classes.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -6,4 +6,6 @@
 #include "item/image.c"
 #include "item/label.c"
 #include "item/button.c"
+#include "item/checkbox.c"
+#include "item/radiobutton.c"
 #include "nexuiz/mainwindow.c"

Modified: trunk/data/qcsrc/menu-div0test/item/button.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/button.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/item/button.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -10,6 +10,7 @@
 	ATTRIB(Button, onClick, void(entity, entity), SUB_Null)
 	ATTRIB(Button, onClickEntity, entity, NULL)
 	ATTRIB(Button, src, string, "")
+	ATTRIB(Button, srcMulti, float, 1)
 	ATTRIB(Button, focusable, float, 1)
 	ATTRIB(Button, pressed, float, 0)
 	ATTRIB(Button, clickTime, float, 0)
@@ -68,28 +69,40 @@
 }
 void drawButton(entity me)
 {
-	float division;
-	division = min(0.5, 0.5 * me.size_y / me.size_x);
-	if(me.forcePressed || me.pressed || me.clickTime > 0)
+	if(me.srcMulti)
 	{
-		draw_Picture('0 0 0', strcat(me.src, "_cl"), eX * division + eY, '1 1 1', 1);
-		if(division < 0.5)
-			draw_Picture('0 0 0' + eX * division, strcat(me.src, "_cm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
-		draw_Picture(eX * (1 - division), strcat(me.src, "_cr"), eX * division + eY, '1 1 1', 1);
+		float division;
+		division = min(0.5, 0.5 * me.size_y / me.size_x);
+		if(me.forcePressed || me.pressed || me.clickTime > 0)
+		{
+			draw_Picture('0 0 0', strcat(me.src, "_cl"), eX * division + eY, '1 1 1', 1);
+			if(division < 0.5)
+				draw_Picture('0 0 0' + eX * division, strcat(me.src, "_cm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
+			draw_Picture(eX * (1 - division), strcat(me.src, "_cr"), eX * division + eY, '1 1 1', 1);
+		}
+		else if(me.focused)
+		{
+			draw_Picture('0 0 0', strcat(me.src, "_fl"), eX * division + eY, '1 1 1', 1);
+			if(division < 0.5)
+				draw_Picture('0 0 0' + eX * division, strcat(me.src, "_fm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
+			draw_Picture(eX * (1 - division), strcat(me.src, "_fr"), eX * division + eY, '1 1 1', 1);
+		}
+		else
+		{
+			draw_Picture('0 0 0', strcat(me.src, "_nl"), eX * division + eY, '1 1 1', 1);
+			if(division < 0.5)
+				draw_Picture('0 0 0' + eX * division, strcat(me.src, "_nm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
+			draw_Picture(eX * (1 - division), strcat(me.src, "_nr"), eX * division + eY, '1 1 1', 1);
+		}
 	}
-	else if(me.focused)
-	{
-		draw_Picture('0 0 0', strcat(me.src, "_fl"), eX * division + eY, '1 1 1', 1);
-		if(division < 0.5)
-			draw_Picture('0 0 0' + eX * division, strcat(me.src, "_fm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
-		draw_Picture(eX * (1 - division), strcat(me.src, "_fr"), eX * division + eY, '1 1 1', 1);
-	}
 	else
 	{
-		draw_Picture('0 0 0', strcat(me.src, "_nl"), eX * division + eY, '1 1 1', 1);
-		if(division < 0.5)
-			draw_Picture('0 0 0' + eX * division, strcat(me.src, "_nm"), eX * (1 - 2 * division) + eY, '1 1 1', 1);
-		draw_Picture(eX * (1 - division), strcat(me.src, "_nr"), eX * division + eY, '1 1 1', 1);
+		if(me.forcePressed || me.pressed || me.clickTime > 0)
+			draw_Picture('0 0 0', strcat(me.src, "_c"), '1 1 0', '1 1 1', 1);
+		else if(me.focused)
+			draw_Picture('0 0 0', strcat(me.src, "_f"), '1 1 0', '1 1 1', 1);
+		else
+			draw_Picture('0 0 0', strcat(me.src, "_n"), '1 1 0', '1 1 1', 1);
 	}
 	me.clickTime -= frametime;
 	drawLabel(me);

Added: trunk/data/qcsrc/menu-div0test/item/checkbox.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/checkbox.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/item/checkbox.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -0,0 +1,56 @@
+#ifdef INTERFACE
+void CheckBox_Click(entity me, entity other);
+CLASS(CheckBox) EXTENDS(Button)
+	METHOD(CheckBox, configureCheckBox, void(entity, string, float, string))
+	METHOD(CheckBox, resizeNotify, void(entity, vector, vector, vector, vector))
+	METHOD(CheckBox, draw, void(entity))
+	ATTRIB(CheckBox, checked, float, 0)
+	ATTRIB(CheckBox, onClick, void(entity, entity), CheckBox_Click)
+	ATTRIB(CheckBox, srcMulti, float, 0)
+ENDCLASS(CheckBox)
+#endif
+
+#ifdef IMPLEMENTATION
+void CheckBox_Click(entity me, entity other)
+{
+	me.checked = !me.checked;
+}
+void configureCheckBoxCheckBox(entity me, string txt, float sz, string gfx)
+{
+	me.configureButton(me, txt, sz, gfx);
+	me.align = 0;
+}
+void resizeNotifyCheckBox(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+	me.keepspaceLeft = min(0.8, absSize_y / absSize_x);
+	resizeNotifyButton(me, relOrigin, relSize, absOrigin, absSize);
+}
+void drawCheckBox(entity me)
+{
+	vector cbOrigin;
+	vector cbSize;
+
+	cbOrigin = eY * (0.5 * (1 - me.realFontSize_y)) + eX * (0.5 * (me.keepspaceLeft - me.realFontSize_x));
+	cbSize = me.realFontSize;
+	if(me.checked)
+	{
+		if(me.forcePressed || me.pressed || me.clickTime > 0)
+			draw_Picture(cbOrigin, strcat(me.src, "_c1"), cbSize, '1 1 1', 1);
+		else if(me.focused)
+			draw_Picture(cbOrigin, strcat(me.src, "_f1"), cbSize, '1 1 1', 1);
+		else
+			draw_Picture(cbOrigin, strcat(me.src, "_n1"), cbSize, '1 1 1', 1);
+	}
+	else
+	{
+		if(me.forcePressed || me.pressed || me.clickTime > 0)
+			draw_Picture(cbOrigin, strcat(me.src, "_c0"), cbSize, '1 1 1', 1);
+		else if(me.focused)
+			draw_Picture(cbOrigin, strcat(me.src, "_f0"), cbSize, '1 1 1', 1);
+		else
+			draw_Picture(cbOrigin, strcat(me.src, "_n0"), cbSize, '1 1 1', 1);
+	}
+	me.clickTime -= frametime;
+	drawLabel(me); // skip drawButton!
+}
+#endif

Modified: trunk/data/qcsrc/menu-div0test/item/label.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/label.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/item/label.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -7,6 +7,8 @@
 	ATTRIB(Label, text, string, "Big Red Button")
 	ATTRIB(Label, fontSize, float, 8)
 	ATTRIB(Label, align, float, 0.5)
+	ATTRIB(Label, keepspaceLeft, float, 0) // for use by subclasses (radiobuttons for example)
+	ATTRIB(Label, keepspaceRight, float, 0)
 	ATTRIB(Label, realFontSize, vector, '0 0 0')
 	ATTRIB(Label, realOrigin, vector, '0 0 0')
 ENDCLASS(Label)
@@ -23,7 +25,7 @@
 	// absSize_y is height of label
 	me.realFontSize_y = me.fontSize / absSize_y;
 	me.realFontSize_x = me.fontSize / absSize_x;
-	me.realOrigin_x = me.align * (1 - me.realFontSize_x * draw_TextWidth(me.text));
+	me.realOrigin_x = me.align * (1 - me.keepspaceLeft - me.keepspaceRight - me.realFontSize_x * draw_TextWidth(me.text)) + me.keepspaceLeft;
 	me.realOrigin_y = 0.5 * (1 - me.realFontSize_y);
 }
 void configureLabelLabel(entity me, string txt, float sz, float algn)

Modified: trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/modalcontroller.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/item/modalcontroller.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -3,7 +3,6 @@
 	METHOD(ModalController, resizeNotify, void(entity, vector, vector, vector, vector))
 	METHOD(ModalController, draw, void(entity))
 	METHOD(ModalController, addItem, void(entity, entity, vector, vector, float))
-	METHOD(ModalController, setFocus, void(entity, entity))
 	METHOD(ModalController, showChild, void(entity, entity, vector, vector, float))
 	METHOD(ModalController, hideChild, void(entity, entity, float))
 	METHOD(ModalController, hideAll, void(entity, float))
@@ -242,12 +241,6 @@
 		other.Container_alpha = 0;
 }
 
-void setFocusModalController(entity me, entity other)
-{
-	//print("focus to ", etos(other), "\n");
-	setFocusContainer(me, other);
-}
-
 void showChildModalController(entity me, entity other, vector theOrigin, vector theSize, float skipAnimation)
 {
 	if(other.ModalController_state == 0)

Modified: trunk/data/qcsrc/menu-div0test/item/nexposee.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/nexposee.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/item/nexposee.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -8,7 +8,6 @@
 	METHOD(Nexposee, mouseRelease, float(entity, vector))
 	METHOD(Nexposee, mouseDrag, float(entity, vector))
 	METHOD(Nexposee, resizeNotify, void(entity, vector, vector, vector, vector))
-	//METHOD(Nexposee, setFocus, void(entity, entity))
 	METHOD(Nexposee, focusEnter, void(entity))
 
 	ATTRIB(Nexposee, animationState, float, -1)
@@ -322,28 +321,4 @@
 	if(me.animationState == 2)
 		setFocusContainer(me, me.selectedChild);
 }
-
-void setFocusNexposee(entity me, entity other)
-{
-/*
-	if(me.animationState == 0)
-	{
-		if(other != NULL)
-		{
-			setFocusContainer(me, other);
-			me.selectedChild = other;
-			me.animationState = 1;
-		}
-	}
-	else if(me.animationState == 2)
-	{
-		if(other == NULL)
-		{
-			me.selectedChild = me.focusedChild;
-			setFocusContainer(me, NULL);
-			me.animationState = 3;
-		}
-	}
-*/
-}
 #endif

Added: trunk/data/qcsrc/menu-div0test/item/radiobutton.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/radiobutton.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/item/radiobutton.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -0,0 +1,37 @@
+#ifdef INTERFACE
+void RadioButton_Click(entity me, entity other);
+CLASS(RadioButton) EXTENDS(CheckBox)
+	METHOD(RadioButton, configureRadioButton, void(entity, string, float, string, float, float))
+	ATTRIB(RadioButton, checked, float, 0)
+	ATTRIB(RadioButton, group, float, 0)
+	ATTRIB(RadioButton, allowDeselect, float, 0)
+	ATTRIB(RadioButton, onClick, void(entity, entity), RadioButton_Click)
+ENDCLASS(RadioButton)
+#endif
+
+#ifdef IMPLEMENTATION
+void configureRadioButtonRadioButton(entity me, string txt, float sz, string gfx, float theGroup, float doAllowDeselect)
+{
+	me.configureCheckBox(me, txt, sz, gfx);
+	me.align = 0;
+	me.group = theGroup;
+	me.allowDeselect = doAllowDeselect;
+}
+void RadioButton_Click(entity me, entity other)
+{
+	if(me.checked)
+	{
+		if(me.allowDeselect)
+			me.checked = 0;
+	}
+	else
+	{
+		entity e;
+		for(e = me.parent.firstChild; e; e = e.Container_nextSibling)
+			if(e != me)
+				if(e.group == me.group)
+					e.checked = 0;
+		me.checked = 1;
+	}
+}
+#endif

Modified: trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c	2007-10-27 09:43:30 UTC (rev 2855)
@@ -31,13 +31,26 @@
 		dlg.addItem(dlg, i, '0 0 0', '1 0.2 0', 1);
 
 		i = spawnLabel();
-		i.configureLabel(i, "Swim swim hungry, swim swim hungry...", 12, 0.5);
-		dlg.addItem(dlg, i, '0 0.3 0', '1 0.2 0', 1);
+		i.configureLabel(i, "Swim swim hungry, swim swim hungry...", 8, 0.5);
+		dlg.addItem(dlg, i, '0 0.3 0', '1 0.1 0', 1);
 
+		i = spawnRadioButton();
+		i.configureRadioButton(i, "RadioButton1", 12, "qcsrc/menu-div0test/baseradiobutton", 1, 0);
+		dlg.addItem(dlg, i, '0.1 0.4 0', '0.4 0.1 0', 1);
+
+		i = spawnRadioButton();
+		i.configureRadioButton(i, "RadioButton2", 12, "qcsrc/menu-div0test/baseradiobutton", 1, 1);
+		dlg.addItem(dlg, i, '0.5 0.4 0', '0.8 0.1 0', 1);
+
+		i = spawnCheckBox();
+		i.configureCheckBox(i, "Do not show this dialog again", 12, "qcsrc/menu-div0test/basecheckbox");
+		i.checked = 1;
+		dlg.addItem(dlg, i, '0.1 0.5 0', '0.8 0.1 0', 1);
+
 		i = spawnButton();
 		i.configureButton(i, "Close", 12, "qcsrc/menu-div0test/basebutton");
 		i.onClick = DialogCloseButton_Click; i.onClickEntity = dlg;
-		dlg.addItem(dlg, i, '0.3 0.6 0', '0.4 0.3 0', 1);
+		dlg.addItem(dlg, i, '0.3 0.7 0', '0.4 0.2 0', 1);
 	me.addItem(me, dlg, '0.2 0.3 0', '0.6 0.4 0', 1);
 	
 	i = spawnImage();

Modified: trunk/data/qcsrc/menu-div0test/oo/constructors.h
===================================================================
--- trunk/data/qcsrc/menu-div0test/oo/constructors.h	2007-10-26 13:29:46 UTC (rev 2854)
+++ trunk/data/qcsrc/menu-div0test/oo/constructors.h	2007-10-27 09:43:30 UTC (rev 2855)
@@ -14,8 +14,8 @@
 #undef ENDCLASS
 #endif
 
-#define CLASS(cname)                 entity spawn##cname() { entity e;
-#define EXTENDS(base)                e = spawn##base ();
-#define METHOD(cname,name,prototype) e.name = name##cname;
-#define ATTRIB(cname,name,type,val)  e.name = val;
-#define ENDCLASS(cname)              e.instanceOf##cname = 1; e.classname = #cname; return e; }
+#define CLASS(cname)                 entity spawn##cname() { entity me;
+#define EXTENDS(base)                me = spawn##base ();
+#define METHOD(cname,name,prototype) me.name = name##cname;
+#define ATTRIB(cname,name,type,val)  me.name = val;
+#define ENDCLASS(cname)              me.instanceOf##cname = 1; me.classname = #cname; return me; }




More information about the nexuiz-commits mailing list