From 3d466953d2babdc19e10f5b8d8dcff424d860e87 Mon Sep 17 00:00:00 2001 From: efim Date: Thu, 23 Nov 2023 04:15:11 +0000 Subject: [PATCH] fix: mark & active brick type --- routes/room_page_templates_preview.go | 86 +++++++++++-------- routes/static/out.css | 4 +- routes/templates/tableTemplates.gohtml | 10 +++ routes/templates/tableTemplatesPreview.gohtml | 6 +- 4 files changed, 64 insertions(+), 42 deletions(-) diff --git a/routes/room_page_templates_preview.go b/routes/room_page_templates_preview.go index 36c12b5..f7c9fbe 100644 --- a/routes/room_page_templates_preview.go +++ b/routes/room_page_templates_preview.go @@ -39,7 +39,7 @@ type roomTableData struct { currentPerson rooms.PersonId } -func (room *roomTableData)Persons() []personData { +func (room *roomTableData) Persons() []personData { total := room.Total() persons := make([]personData, 0, total) currentPersonIndex := slices.Index(room.Paricipants, room.currentPerson) @@ -51,10 +51,10 @@ func (room *roomTableData)Persons() []personData { } return persons } -func (r *roomTableData)Total() int { +func (r *roomTableData) Total() int { return len(r.Paricipants) } -func (r *roomTableData)Tangens() float64 { +func (r *roomTableData) Tangens() float64 { total := r.Total() if total == 2 { return 1 @@ -63,18 +63,18 @@ func (r *roomTableData)Tangens() float64 { } type arrowData struct { - IsVisible bool - Height, Width int - Radius int - StartX, StartY int - EndX, EndY int - LargeArcFlag int + IsVisible bool + Height, Width int + Radius int + StartX, StartY int + EndX, EndY int + LargeArcFlag int Angle1X, Angle1Y int Angle2X, Angle2Y int } // arrow data - to draw SVG from current speaker to next speaker -func (r *roomTableData)ArrowData() arrowData { +func (r *roomTableData) ArrowData() arrowData { // TODO figure out size to be around the people // and this is somewhat a win height, width := 150.0, 150.0 @@ -92,8 +92,8 @@ func (r *roomTableData)ArrowData() arrowData { endSector += total } radius := 50.0 - startAngle := 90 + float64(startSector) * ( 360.0 / float64(total) ) - endAngle := 90 + float64(endSector) * ( 360.0 / float64(total) ) + startAngle := 90 + float64(startSector)*(360.0/float64(total)) + endAngle := 90 + float64(endSector)*(360.0/float64(total)) // if need to draw full circle if startSector == endSector { startAngle += 3 // a bit forward @@ -103,42 +103,42 @@ func (r *roomTableData)ArrowData() arrowData { endAngleRad := endAngle * (math.Pi / float64(180)) // endAngle is radius angle, so perpendicular gives direction of teh arrow - x1 := centerX + radius * math.Cos(startAngleRad) - y1 := centerY + radius * math.Sin(startAngleRad) - x2 := centerX + radius * math.Cos(endAngleRad) - y2 := centerY + radius * math.Sin(endAngleRad) + x1 := centerX + radius*math.Cos(startAngleRad) + y1 := centerY + radius*math.Sin(startAngleRad) + x2 := centerX + radius*math.Cos(endAngleRad) + y2 := centerY + radius*math.Sin(endAngleRad) arrowAngleOffset := math.Pi / 4 // 45 degrees - arrowPointDirection := endAngleRad - math.Pi / 2 + arrowPointDirection := endAngleRad - math.Pi/2 arrowheadLen := 10.0 arrowMinusAngle := arrowPointDirection - arrowAngleOffset arrowPlusAngle := arrowPointDirection + arrowAngleOffset - arrowMinusEndX := x2 + arrowheadLen * math.Cos(arrowMinusAngle) - arrowMinusEndY := y2 + arrowheadLen * math.Sin(arrowMinusAngle) - arrowPlusEndX := x2 + arrowheadLen * math.Cos(arrowPlusAngle) - arrowPlusEndY := y2 + arrowheadLen * math.Sin(arrowPlusAngle) + arrowMinusEndX := x2 + arrowheadLen*math.Cos(arrowMinusAngle) + arrowMinusEndY := y2 + arrowheadLen*math.Sin(arrowMinusAngle) + arrowPlusEndX := x2 + arrowheadLen*math.Cos(arrowPlusAngle) + arrowPlusEndY := y2 + arrowheadLen*math.Sin(arrowPlusAngle) // indicates that the shorter of the two possible arcs should be used. largeArcFlag := 0 // - if endAngleRad - startAngleRad > (math.Pi) { + if endAngleRad-startAngleRad > (math.Pi) { // specifies that the longer arc should be chosen. largeArcFlag = 1 } return arrowData{ - IsVisible: true, - Height: int(height), - Width: int(width), - Radius: int(radius), - StartX: int(x1), - StartY: int(y1), - EndX: int(x2), - EndY: int(y2), + IsVisible: true, + Height: int(height), + Width: int(width), + Radius: int(radius), + StartX: int(x1), + StartY: int(y1), + EndX: int(x2), + EndY: int(y2), LargeArcFlag: largeArcFlag, - Angle1X: int(arrowMinusEndX), - Angle1Y: int(arrowMinusEndY), - Angle2X: int(arrowPlusEndX), - Angle2Y: int(arrowPlusEndY), + Angle1X: int(arrowMinusEndX), + Angle1Y: int(arrowMinusEndY), + Angle2X: int(arrowPlusEndX), + Angle2Y: int(arrowPlusEndY), } } @@ -169,7 +169,7 @@ func personDataFromRoom(room *roomTableData, pId rooms.PersonId) personData { } } -func (pData personData)BricksForPerson() []brickState { +func (pData personData) BricksForPerson() []brickState { var result = make([]brickState, 5) for gesture := rooms.ChangeTopic; gesture <= rooms.Meta; gesture++ { // for index := rooms.Meta; index >= rooms.ChangeTopic; index-- { @@ -177,6 +177,8 @@ func (pData personData)BricksForPerson() []brickState { // this results in iteration 4,3,2,1,0,255 wow templateType := "inactiveBrick" switch { + case pData.IsRaised && pData.IsMark && gesture == pData.Raised: + templateType = "markAndRaisedBrick" case pData.IsMark && gesture == pData.Mark: templateType = "markBrick" case pData.IsSpeaker && gesture == pData.Raised: @@ -225,6 +227,10 @@ func roomTemplatesPreview( Id: rooms.PersonId(300), Name: "test person name 3", } + var person4 = rooms.Person{ + Id: rooms.PersonId(400), + Name: "test person name 4", + } aRoom := rooms.Room{ Name: "test", CurrentSpeaker: person3.Id, @@ -232,18 +238,22 @@ func roomTemplatesPreview( person1.Id: person1, person2.Id: person2, person3.Id: person3, + person4.Id: person4, }, Paricipants: []rooms.PersonId{ person1.Id, person2.Id, person3.Id, + person4.Id, }, ParticipantHands: map[rooms.PersonId]rooms.HandGesture{ person3.Id: rooms.ClarifyingQ, person2.Id: rooms.Meta, + person4.Id: rooms.ChangeTopic, }, Marks: map[rooms.HandGesture]rooms.PersonId{ - rooms.Expand: person1.Id, + rooms.Expand: person1.Id, + rooms.ChangeTopic: person4.Id, }, } @@ -282,8 +292,8 @@ func roomTemplatesPreview( }, }, TestPerson: testPersonData, - ARoom: &roomTableData{ - Room: &aRoom, + ARoom: &roomTableData{ + Room: &aRoom, currentPerson: aRoom.Paricipants[0], }, } diff --git a/routes/static/out.css b/routes/static/out.css index f396faa..e557c7a 100644 --- a/routes/static/out.css +++ b/routes/static/out.css @@ -628,8 +628,8 @@ video { grid-template-columns: repeat(2, minmax(0, 1fr)); } -.grid-cols-5 { - grid-template-columns: repeat(5, minmax(0, 1fr)); +.grid-cols-6 { + grid-template-columns: repeat(6, minmax(0, 1fr)); } .grid-rows-\[auto\2c 1fr\] { diff --git a/routes/templates/tableTemplates.gohtml b/routes/templates/tableTemplates.gohtml index 1c24010..3465e5e 100644 --- a/routes/templates/tableTemplates.gohtml +++ b/routes/templates/tableTemplates.gohtml @@ -26,6 +26,14 @@ X {{ end }} +{{ define "markAndRaisedBrick" }} +
+ X +
+{{ end }}

Now for BrickData taking parametrized template name

{{ define "brick" }} @@ -37,6 +45,8 @@ {{ template "speakerBrick" .ColorClass }} {{ else if eq .TemplateType "markBrick" }} {{ template "markBrick" .ColorClass }} +{{ else if eq .TemplateType "markAndRaisedBrick" }} + {{ template "markAndRaisedBrick" .ColorClass }} {{ end }} {{end}} diff --git a/routes/templates/tableTemplatesPreview.gohtml b/routes/templates/tableTemplatesPreview.gohtml index 8dd6112..8d2023e 100644 --- a/routes/templates/tableTemplatesPreview.gohtml +++ b/routes/templates/tableTemplatesPreview.gohtml @@ -1,19 +1,21 @@ {{define "main-content"}} -
+

For each type

-
+

types:

inactive

raised

speaker

mark

+

mark and active

{{ range .Bricks }}
for {{ .Name }}
{{ template "inactiveBrick" .ColorClass }}
{{ template "raisedBrick" .ColorClass }}
{{ template "speakerBrick" .ColorClass }}
{{ template "markBrick" .ColorClass }}
+
{{ template "markAndRaisedBrick" .ColorClass }}
{{ end }}