From 58545d5756d8300796a3ef4a0175ebbf055dae40 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Oct 2007 01:04:54 -0400 Subject: [PATCH] Radio buttons and check boxes --- extra/opengl/opengl.factor | 19 +++- extra/ui/gadgets/buttons/buttons-docs.factor | 21 ++--- extra/ui/gadgets/buttons/buttons.factor | 98 ++++++++++++++++---- extra/ui/gadgets/editors/editors.factor | 9 ++ extra/ui/gadgets/labels/labels-docs.factor | 8 +- extra/ui/gadgets/labels/labels.factor | 16 +++- extra/ui/render/render.factor | 27 ++++++ extra/ui/tools/tools.factor | 7 +- 8 files changed, 164 insertions(+), 41 deletions(-) diff --git a/extra/opengl/opengl.factor b/extra/opengl/opengl.factor index 13ce47ba52..d796c2611d 100644 --- a/extra/opengl/opengl.factor +++ b/extra/opengl/opengl.factor @@ -2,7 +2,7 @@ ! Portions copyright (C) 2007 Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types io kernel math namespaces -sequences math.vectors opengl.gl opengl.glu combinators ; +sequences math.vectors math.constants math.functions opengl.gl opengl.glu combinators arrays ; IN: opengl : coordinates [ first2 ] 2apply ; @@ -63,6 +63,23 @@ IN: opengl : gl-poly ( points -- ) GL_LINE_LOOP (gl-poly) ; +: circle-steps dup length v/n 2 pi * v*n ; + +: unit-circle dup [ sin ] map swap [ cos ] map ; + +: adjust-points [ [ 1 + 0.5 * ] map ] 2apply ; + +: scale-points 2array flip [ v* ] curry* map [ v+ ] curry* map ; + +: circle-points ( loc dim steps -- points ) + circle-steps unit-circle adjust-points scale-points ; + +: gl-circle ( loc dim steps -- ) + circle-points gl-poly ; + +: gl-fill-circle ( loc dim steps -- ) + circle-points gl-fill-poly ; + : prepare-gradient ( direction dim -- v1 v2 ) tuck v* [ v- ] keep ; diff --git a/extra/ui/gadgets/buttons/buttons-docs.factor b/extra/ui/gadgets/buttons/buttons-docs.factor index d791e7e192..d398255bc4 100644 --- a/extra/ui/gadgets/buttons/buttons-docs.factor +++ b/extra/ui/gadgets/buttons/buttons-docs.factor @@ -7,11 +7,7 @@ HELP: button $nl "A button's appearance can vary depending on the state of the mouse button if the " { $link gadget-interior } " or " { $link gadget-boundary } " slots are set to instances of " { $link button-paint } "." $nl -"A button can be selected, which is distinct from being pressed. This state is held in the " { $link button-selected? } " slot, and is used by the " { $link } " word to construct a row of buttons for choosing among several alternatives." } ; - -HELP: >label -{ $values { "obj" "a label specifier" } { "gadget" "a new " { $link gadget } } } -{ $description "Convert the object into a gadget suitable for use as the label of a button. If " { $snippet "obj" } " is already a gadget, does nothing. Otherwise creates a " { $link label } " gadget if it is a string and an empty gadget if " { $snippet "obj" } " is " { $link f } "." } ; +"A button can be selected, which is distinct from being pressed. This state is held in the " { $link button-selected? } " slot, and is used by the " { $link } " word to construct a row of buttons for choosing among several alternatives." } ; HELP: