Skip to content

Commit

Permalink
Feature: smooth scrolling (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3rndt authored Jun 28, 2021
1 parent ce4dda1 commit c3ecad2
Show file tree
Hide file tree
Showing 76 changed files with 264 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ adding
addOldestMessage: aMessage

self messages add: aMessage.
self triggerEvent: #newMessage with: aMessage.
self triggerEvent: #loadedMessage with: aMessage.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"newFromChatEvent:" : "TR 6/15/2021 16:51" },
"instance" : {
"addNewestMessage:" : "js 8/2/2020 12:58",
"addOldestMessage:" : "js 8/2/2020 12:58",
"addOldestMessage:" : "JB 6/28/2021 09:31",
"canSendMessages" : "5/11/2021 10:09:15",
"canSendMessages:" : "TR 5/5/2021 16:31",
"core" : "per 6/4/2021 16:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"loggedInUserID:" : "rs 7/5/2020 14:48",
"pendingRequests" : "pk 5/13/2021 09:46",
"pendingRequests:" : "pk 5/13/2021 09:46",
"receiveLoop" : "pk 6/27/2021 13:27",
"receiveLoop" : "per 6/28/2021 16:26",
"registerCallback:" : "pk 6/18/2021 09:41",
"requestFile:with:" : "RS 6/23/2021 16:43",
"requestUser:with:" : "RS 6/23/2021 16:45",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default values
defaultMessageMargin

^ 10
^ 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default values
defaultMessageWrapper

^ Morph new
cellInset: self defaultMessageMargin;
color: Color transparent;
layoutPolicy: TableLayout new;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default values
defaultScrollOffsetBeforeLoading

^ 50
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
messages
addAtBottom: aMessage

| wrapper |
wrapper := self wrapperFor: (TCUMessage newFrom: aMessage).
self scroller addMorphBack: wrapper.
self items addLast: wrapper.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
messages
addAtTop: aMessage

| wrapper |
wrapper := self wrapperFor: (TCUMessage newFrom: aMessage).
self scroller addMorphFront: wrapper.
self items addFirst: wrapper.

self vScrollBar maximumValue = self vScrollBar value
ifTrue: [self scrollToNewestMessage].
self scrollBy: 0 @ (wrapper height negated).

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
messages
addMessages

self showChatMessagesFrom: self lowestVisibleMessage.
self chat messages reversed
collect: [:message | self addAtBottom: message]
from: 1
to: self chat numberOfMessages.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
event handling
accessing
core

^ self owner core
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ messages
displayChat: aChat

self chat removeActionsWithReceiver: self.
aChat when: #newMessage send: #addMessages to: self.
aChat when: #newMessage send: #addAtBottom: to: self.
aChat when: #loadedMessage send: #addAtTop: to: self.
self
chat: aChat;
lowestVisibleMessage: 0;
addMessages.
showMessages;
isLoadingHistory: true.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ initialize

self
chat: TCCNullChat new;
clipSubmorphs: true;
messages: OrderedCollection new.
alwaysShowVScrollBar;
isLoadingHistory: false.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isLoadingHistory: aBoolean

isLoadingHistory := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isLoadingHistory

^ isLoadingHistory

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
drawing
scrollToNewestMessage

self items notEmpty ifTrue: [self scrollToShow: self items last].

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
drawing
showMessages

self
clearItems;
addMessages;
scrollToNewestMessage.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
stepping and presenter
step

self isLoadingHistory ifTrue:
[self scroller offset y < self class defaultScrollOffsetBeforeLoading
ifTrue: [self core getChatHistoryFrom: self chat id]].
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
messages
wrapperFor: aTCUMessage

| wrapper |
wrapper := self class defaultMessageWrapper
width: self scroller width;
height: aTCUMessage height;
yourself.

aTCUMessage isOutgoing
ifTrue: [ wrapper listDirection: #rightToLeft ]
ifFalse: [ wrapper listDirection: #leftToRight ].

wrapper addMorph: aTCUMessage.
^ wrapper
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"class" : {
"defaultMessageMargin" : "js 7/31/2020 15:50" },
"defaultMessageMargin" : "per 6/20/2021 11:51",
"defaultMessageWrapper" : "JB 6/28/2021 09:58",
"defaultScrollOffsetBeforeLoading" : "JB 6/26/2021 10:15" },
"instance" : {
"addMessageAtBottom:" : "RK 6/26/2021 10:15",
"addMessages" : "js 8/2/2020 22:16",
"addAtBottom:" : "per 6/28/2021 15:55",
"addAtTop:" : "per 6/28/2021 16:15",
"addMessages" : "JB 6/28/2021 09:32",
"chat" : "js 7/31/2020 16:39",
"chat:" : "js 7/31/2020 16:39",
"clearMessages" : "js 7/31/2020 16:46",
"core" : "js 8/2/2020 22:11",
"displayChat:" : "f.w. 8/1/2020 04:53",
"handleMouseWheel:" : "f.w. 7/31/2020 23:53",
"initialize" : "js 7/31/2020 17:19",
"lowestVisibleMessage" : "f.w. 7/31/2020 23:55",
"lowestVisibleMessage:" : "f.w. 7/31/2020 23:55",
"messages" : "rs 6/17/2020 19:10",
"messages:" : "rs 6/17/2020 19:10",
"scrollDown" : "js 8/2/2020 22:17",
"scrollUp" : "js 8/2/2020 22:17",
"showChatMessagesFrom:" : "js 8/2/2020 22:18" } }
"core" : "JB 6/26/2021 10:22",
"displayChat:" : "JB 6/28/2021 09:32",
"initialize" : "JB 6/26/2021 10:17",
"isLoadingHistory" : "JB 6/26/2021 10:16",
"isLoadingHistory:" : "JB 6/26/2021 10:16",
"scrollToNewestMessage" : "per 6/24/2021 23:14",
"showMessages" : "per 6/24/2021 23:12",
"step" : "JB 6/26/2021 10:22",
"wrapperFor:" : "JB 6/28/2021 09:40" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
],
"commentStamp" : "rs 6/17/2020 21:32",
"instvars" : [
"messages",
"chat",
"lowestVisibleMessage" ],
"isLoadingHistory" ],
"name" : "TCUChatMessageList",
"pools" : [
],
"super" : "Morph",
"super" : "TCUList",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default values
defaultTitleBarHeight

^ 50

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ addMessageWindow

self
messageListWindow: (TCUChatMessageList new
height: self height - self class defaultInputfieldHeight;
height: self height - self class defaultInputfieldHeight - self class defaultTitleBarHeight;
width: self width;
color: Color white;
lowestVisibleMessage: 0;
topLeft: self topLeft;
hide);
topLeft: self topLeft + (0 @ self class defaultTitleBarHeight);
hide;
yourself);
addMorph: self messageListWindow.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ createTitleBar
borderWidth: 0;
color: TCUDefaultValues colorLightGray;
width: self width;
height: self class defaultTitleBarHeigth;
height: self class defaultTitleBarHeight;
topLeft: self topLeft;
layoutPolicy: TableLayout new;
listDirection: #leftToRight;
layoutInset: 2;
hResizing: #spaceFill;
vResizing: #shrinkWrap;
cellInset: 12).
cellInset: 12;
yourself).

self titleBar on: #mouseDown send: #showInfoPage to: self.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"class" : {
"defaultInputfieldHeight" : "rs 6/12/2020 20:03",
"defaultTitleBarHeigth" : "sp 8/2/2020 15:15",
"defaultTitleBarHeight" : "JB 6/28/2021 09:42",
"newWithHeight:width:" : "RS 5/20/2021 21:18" },
"instance" : {
"addChatTitle" : "RS 5/20/2021 18:31",
"addHiddenInfoPage" : "per 6/15/2021 09:02",
"addInputBar" : "js 6/13/2020 17:59",
"addMemberCount" : "JB 6/4/2021 21:48",
"addMessageWindow" : "JB 6/11/2021 18:33",
"addMessageWindow" : "JB 6/28/2021 09:42",
"addSendButton" : "js 6/13/2020 18:46",
"addTextInputField" : "JB 6/11/2021 18:33",
"addTitleBar" : "RS 5/29/2021 18:12",
Expand All @@ -17,15 +17,15 @@
"clear" : "RS 5/20/2021 21:13",
"core" : "js 8/2/2020 22:11",
"createInputBar" : "JB 6/11/2021 18:33",
"createTitleBar" : "JB 6/11/2021 18:33",
"createTitleBar" : "JB 6/28/2021 09:42",
"infoPage" : "RS 5/20/2021 21:14",
"infoPage:" : "RS 5/20/2021 21:14",
"initialize" : "RS 5/20/2021 19:29",
"inputBar" : "rs 6/13/2020 10:38",
"inputBar:" : "rs 6/13/2020 10:38",
"messageListWindow" : "rs 6/17/2020 19:12",
"messageListWindow:" : "rs 6/17/2020 19:13",
"newChatSelected:" : "RS 5/20/2021 21:18",
"newChatSelected:" : "JB 6/19/2021 14:33",
"selectedChat" : "rs 6/13/2020 09:11",
"selectedChat:" : "rs 6/13/2020 09:11",
"showInfoPage" : "per 5/30/2021 11:51",
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
indicateKeyboardFocus

^ false
Loading

0 comments on commit c3ecad2

Please sign in to comment.