Skip to content

Commit 8ab824d

Browse files
committed
ANDROID: In editor, hide status when scrolled
1 parent 5ff45e1 commit 8ab824d

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2019-03-02 (0.12.15)
2+
ANDROID: In editor, hide status when scrolled
3+
14
2019-02-26 (0.12.15)
25
ANDROID: Fix POINT returning transposed red + blue
36

src/platform/android/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ apply plugin: "com.github.ben-manes.versions"
2323
task clean(type: Delete) {
2424
delete rootProject.buildDir
2525
}
26+
27+
task test {
28+
doLast {
29+
exec {
30+
commandLine 'sh', '-c', 'adb -a logcat -c && \
31+
adb -a shell am start net.sourceforge.smallbasic/net.sourceforge.smallbasic.MainActivity && \
32+
adb -a logcat DEBUG:I smallbasic:I AndroidRuntime:E *:S'
33+
}
34+
}
35+
}

src/platform/android/jni/runtime.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ void System::editSource(strlib::String loadPath, bool restoreOnExit) {
952952
cleanFile.append(" - ");
953953
cleanFile.append(fileName);
954954

955+
bool showStatus = true;
955956
int w = _output->getWidth();
956957
int h = _output->getHeight();
957958
int charWidth = _output->getCharWidth();
@@ -985,6 +986,7 @@ void System::editSource(strlib::String loadPath, bool restoreOnExit) {
985986
editWidget->setCursorRow(gsb_last_line + editWidget->getSelectionRow() - 1);
986987
runtime->alert(gsb_last_errmsg);
987988
}
989+
988990
_srcRendered = false;
989991
_output->setStatus(cleanFile);
990992
_output->redraw();
@@ -994,8 +996,20 @@ void System::editSource(strlib::String loadPath, bool restoreOnExit) {
994996
while (_state == kEditState) {
995997
MAEvent event = getNextEvent();
996998
switch (event.type) {
999+
case EVENT_TYPE_POINTER_PRESSED:
1000+
if (!showStatus && event.point.x < editWidget->getMarginWidth()) {
1001+
_output->setStatus(editWidget->isDirty() ? dirtyFile : cleanFile);
1002+
showStatus = true;
1003+
}
1004+
break;
1005+
case EVENT_TYPE_POINTER_RELEASED:
1006+
if (showStatus && event.point.x < editWidget->getMarginWidth() && editWidget->getScroll()) {
1007+
_output->setStatus("");
1008+
showStatus = false;
1009+
}
1010+
break;
9971011
case EVENT_TYPE_OPTIONS_BOX_BUTTON_CLICKED:
998-
if (editWidget->isDirty()) {
1012+
if (editWidget->isDirty() && !editWidget->getScroll()) {
9991013
_output->setStatus(dirtyFile);
10001014
_output->redraw();
10011015
}
@@ -1068,10 +1082,8 @@ void System::editSource(strlib::String loadPath, bool restoreOnExit) {
10681082
redraw = widget->edit(event.key, sw, charWidth);
10691083
break;
10701084
}
1071-
if (widget->isDirty() && !dirty) {
1072-
_output->setStatus(dirtyFile);
1073-
} else if (!widget->isDirty() && dirty) {
1074-
_output->setStatus(cleanFile);
1085+
if (editWidget->isDirty() != dirty && !editWidget->getScroll()) {
1086+
_output->setStatus(editWidget->isDirty() ? dirtyFile : cleanFile);
10751087
}
10761088
if (redraw) {
10771089
_output->redraw();

src/ui/textedit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct TextEditInput : public FormEditInput {
101101
int getRow() const { return _cursorRow + 1; }
102102
int getPageRows() const { return _height / _charHeight; }
103103
int getLines() { return _buf.lineCount(); }
104+
int getMarginWidth() { return _marginWidth; }
104105
void getSelectionCounts(int *lines, int *chars);
105106
int getSelectionRow();
106107
int getSelectionStart() { return _state.select_start; }

0 commit comments

Comments
 (0)