From da6f65a3d38f4f4db13bbbec6ea6a60c1d11cb0a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Sep 2011 22:41:12 -0700 Subject: [PATCH] ui.gadgets.tables: don't try to render multi-line strings, since all table rows must have the same height. Fixes #65 --- basis/ui/gadgets/tables/tables.factor | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor index 08b27d2020..f4fee89410 100644 --- a/basis/ui/gadgets/tables/tables.factor +++ b/basis/ui/gadgets/tables/tables.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2010 Slava Pestov. +! Copyright (C) 2008, 2011 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs hashtables arrays colors colors.constants fry kernel math math.functions math.ranges math.rectangles math.order @@ -6,7 +6,8 @@ math.vectors namespaces opengl sequences ui.gadgets ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.worlds ui.gestures ui.render ui.pens.solid ui.text ui.commands ui.images ui.gadgets.menus ui.gadgets.line-support models combinators -combinators.short-circuit fonts locals strings sets sorting ; +combinators.short-circuit fonts locals splitting strings sets +sorting ; IN: ui.gadgets.tables ! Row rendererer protocol @@ -68,10 +69,13 @@ GENERIC: cell-height ( font cell -- y ) GENERIC: cell-padding ( cell -- y ) GENERIC: draw-cell ( font cell -- ) -M: string cell-width text-width ; -M: string cell-height text-height ceiling ; +: single-line ( str -- str' ) + dup [ "\r\n" member? ] any? [ string-lines " " join ] when ; + +M: string cell-width single-line text-width ; +M: string cell-height single-line text-height ceiling ; M: string cell-padding drop 0 ; -M: string draw-cell draw-text ; +M: string draw-cell single-line draw-text ; CONSTANT: image-padding 2