Skip to content

Commit 2622ffd

Browse files
committed
UI: Use theme colours in main display #94
1 parent 582ca7a commit 2622ffd

File tree

5 files changed

+75
-55
lines changed

5 files changed

+75
-55
lines changed

ChangeLog

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1-
2020-06-14 (0.12.19)
1+
2020-06-14 (12.19)
2+
UI: Use theme colours in main display #94
3+
4+
2020-06-14 (12.19)
25
FLTK: line numbers colours #93
36
SDL: restore window size #95
47

5-
2020-06-06 (0.12.19)
8+
2020-06-06 (12.19)
69
COMMON: minor performance tweak
710

8-
2020-05-11 (0.12.19)
11+
2020-05-11 (12.19)
912
ANDROID: complain when samsung keyboard detected
1013
COMMON: fix compile warnings
1114

12-
2020-05-11 (0.12.19)
15+
2020-05-11 (12.19)
1316
FLTK: Fix compile warnings with updated gcc
1417

15-
2020-05-10 (0.12.19)
18+
2020-05-10 (12.19)
1619
COMMON: Fix ABSMIN/ABSMAX transposed #96
1720

18-
2020-05-09 (0.12.19)
21+
2020-05-09 (12.19)
1922
COMMON: Fix crash when passing non-array to CHART
2023
SDL: show icon in linux build
2124

22-
2020-05-07 (0.12.19)
25+
2020-05-07 (12.19)
2326
COMMON: Fix image.save() to array destination
2427

25-
2020-05-04 (0.12.19)
28+
2020-05-04 (12.19)
2629
COMMON: INPUT crash #99
2730
COMMON: Fix compile warnings with updated gcc
2831

29-
2020-03-07 (0.12.19)
32+
2020-03-07 (12.19)
3033
COMMON: implement DEFINEKEY undo #92
3134
UI: added R157 colour theme #94
3235

33-
2020-02-13 (0.12.19)
36+
2020-02-13 (12.19)
3437
AUDIO: fix integration with latest version of miniaudio library
3538

3639
2020-02-13 (0.12.18)

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [0.12.19])
10+
AC_INIT([smallbasic], [12.19])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET

src/platform/android/app/src/main/assets/main.bas

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
const app = "main.bas?"
2-
const boldOn = chr(27) + "[1m"
3-
const boldOff = chr(27) + "[21m"
4-
const scrollHome = chr(27) + "m"
1+
const boldOn = "\033[1m"
2+
const boldOff = "\033[21m"
3+
const scrollHome = "\033m"
54
const char_h = txth("Q")
65
const char_w = txtw(".")
76
const lineSpacing = 2 + char_h
8-
const idxEdit = 6
9-
const idxFiles = 7
10-
const colGrey = rgb(100, 100, 100)
11-
const colBkGnd = rgb(31, 28, 31)
12-
const colText = 2
13-
const colLink = 3
7+
const wnd = window()
8+
const theme = wnd.theme
9+
const colBkGnd = theme.background
10+
const colText = theme.text1
11+
const colFile = theme.text2
12+
const colDir = theme.text3
13+
const colText2 = theme.text4
14+
const colNav = theme.text5
15+
const colNav2 = theme.text6
1416
const menu_gap = -(char_w / 2)
1517
const is_sdl = instr(sbver, "SDL") != 0
1618
const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
19+
const idxEdit = 6
20+
const idxFiles = 7
1721
const saveasId = "__bn_saveas__"
1822
const renameId = "__bn_rename__"
1923
const deleteId = "__bn_delete__"
@@ -37,7 +41,7 @@ func mk_bn(value, lab, fg)
3741
bn.value = value
3842
bn.label = lab
3943
bn.color = fg
40-
mk_bn = bn
44+
return bn
4145
end
4246

4347
func mk_menu(value, lab, x)
@@ -46,9 +50,9 @@ func mk_menu(value, lab, x)
4650
bn.y = ypos * char_h
4751
bn.value = value
4852
bn.label = "[" + lab + "]"
49-
bn.color = colLink
53+
bn.color = colNav
5054
bn.type = "link"
51-
mk_menu = bn
55+
return bn
5256
end
5357

5458
func mk_scratch()
@@ -72,7 +76,6 @@ func mk_scratch()
7276
tsave scratch_file, text
7377
result = true
7478
catch e
75-
local wnd = window()
7679
logprint e
7780
wnd.alert("Failed to create: " + scratch_file)
7881
end try
@@ -87,7 +90,7 @@ sub do_okay_button(bn_extra)
8790
button.label = "[Close]"
8891
button.x = (xmax - txtw(button.label)) / 2
8992
button.y = ypos * char_h
90-
button.color = colLink
93+
button.color = colNav
9194
button.type = "link"
9295
if (ismap(bn_extra)) then
9396
frm.inputs << bn_extra
@@ -117,7 +120,7 @@ sub do_about()
117120
print "__)| | |(_||||_)/--\__)|\_"
118121
endif
119122
print
120-
color 7
123+
color colText
121124
print "Version "; sbver
122125
print
123126
print "Copyright (c) 2002-2020 Chris Warren-Smith"
@@ -133,17 +136,17 @@ sub do_about()
133136
else
134137
bn_home.label = "https://smallbasic.github.io/pages/android.html"
135138
endif
136-
bn_home.color = colLink
139+
bn_home.color = colNav
137140
print:print
138141

139-
color colGrey
142+
color colText2
140143
print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. ";
141144
print "This program is free software; you can use it ";
142145
print "redistribute it and/or modify it under the terms of the ";
143146
print "GNU General Public License version 2 as published by ";
144147
print "the Free Software Foundation." + chr(10)
145148
print
146-
color 7
149+
color colText
147150
server_info()
148151
do_okay_button(bn_home)
149152
clear_screen()
@@ -152,7 +155,7 @@ end
152155
sub do_setup()
153156
local frm
154157

155-
color 3, colBkGnd
158+
color colText, colBkGnd
156159
cls
157160
print boldOn + "Setup web service port number."
158161
print boldOff
@@ -161,7 +164,7 @@ sub do_setup()
161164
print "this screen without making any changes."
162165
print "The current setting is: " + env("serverSocket")
163166
print
164-
color 15, 3
167+
color colText, colBkGnd
165168
input socket
166169

167170
if (len(socket) > 0) then
@@ -174,7 +177,7 @@ sub do_setup()
174177
env("serverToken=" + token)
175178
endif
176179

177-
color 3, colBkGnd
180+
color colText, colBkGnd
178181
cls
179182
print "Web service port number: " + env("serverSocket")
180183
print
@@ -196,7 +199,6 @@ sub do_setup()
196199
env("fontId=" + frm.inputs(0).selectedIndex)
197200

198201
local msg = "You must restart SmallBASIC for this change to take effect."
199-
local wnd = window()
200202
wnd.alert(msg, "Restart required")
201203
clear_screen()
202204
end
@@ -293,9 +295,9 @@ end
293295

294296
sub listFiles(byref frm, path, sortDir, byref basList)
295297
local lastItem, bn, abbr, gap, n, lab, name, txtcol, i
296-
local name_col = 3
297-
local size_col = 3
298-
local date_col = 3
298+
local name_col = colNav
299+
local size_col = colNav
300+
local date_col = colNav
299301

300302
if (right(path, 1) != "/") then
301303
path += "/"
@@ -307,28 +309,28 @@ sub listFiles(byref frm, path, sortDir, byref basList)
307309
sort basList use filecmpfunc0(x,y)
308310
case 1
309311
sort basList use filecmpfunc1(x,y)
310-
name_col = 6
312+
name_col = colNav2
311313
case 2
312314
sort basList use filecmpfunc2(x,y)
313-
size_col = 5
315+
size_col = colNav2
314316
case 3
315317
sort basList use filecmpfunc3(x,y)
316-
size_col = 6
318+
size_col = colNav2
317319
case 4
318320
sort basList use filecmpfunc4(x,y)
319-
date_col = 5
321+
date_col = colNav2
320322
case 5
321323
sort basList use filecmpfunc5(x,y)
322-
date_col = 6
324+
date_col = colNav2
323325
end select
324326

325-
bn = mk_bn(0, "Files in " + path, 7)
327+
bn = mk_bn(0, "Files in " + path, colText)
326328
bn.type = "label"
327329
bn.x = 0
328330
bn.y = -lineSpacing
329331
frm.inputs << bn
330332

331-
bn = mk_bn(backId, "[Go up]", 3)
333+
bn = mk_bn(backId, "[Go up]", colNav)
332334
bn.type = "link"
333335
bn.x = 0
334336
bn.y = -linespacing
@@ -358,7 +360,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
358360
lastItem = len(basList) - 1
359361
for i = 0 to lastItem
360362
node = basList(i)
361-
txtcol = iff(node.dir, 3, 2)
363+
txtcol = iff(node.dir, colDir, colFile)
362364
name = node.name
363365
if (abbr) then
364366
bn = mk_bn(path + name, name, txtcol)
@@ -377,7 +379,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
377379

378380
gap = 12 - len(str(node.size))
379381
n = iff(gap > 1, gap, 1)
380-
bn = mk_bn(0, node.size + space(n) + timestamp(node.mtime), colGrey)
382+
bn = mk_bn(0, node.size + space(n) + timestamp(node.mtime), colText)
381383
bn.type = "label"
382384
bn.y = -1
383385
gap = 29 - len(name)
@@ -388,7 +390,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
388390
end
389391

390392
sub manageFiles()
391-
local f, wnd, bn_edit, bn_files, selectedFile
393+
local f, bn_edit, bn_files, selectedFile
392394

393395
func fileCmpFunc(l, r)
394396
local f1 = lower(l)
@@ -425,7 +427,7 @@ sub manageFiles()
425427
bn_edit.y = char_h + 4
426428
bn_edit.width = xmax
427429
bn_edit.type = "text"
428-
bn_edit.color = "white"
430+
bn_edit.color = colText2
429431
bn_edit.resizable = TRUE
430432
bn_edit.help = "Enter file name, and then click New."
431433
bn_files.x = x1
@@ -518,7 +520,7 @@ sub manageFiles()
518520
else
519521
tload selectedFile, buffer
520522
wnd.graphicsScreen2()
521-
color 7
523+
color colText
522524
cls
523525
len_buffer = len(buffer) - 1
524526
for i = 0 to len_buffer
@@ -569,7 +571,6 @@ sub manageFiles()
569571

570572
createUI()
571573
reloadList(0)
572-
wnd = window()
573574
wnd.showKeypad()
574575

575576
while 1
@@ -606,7 +607,6 @@ func changeDir(s)
606607
chdir s
607608
return true
608609
catch e
609-
local wnd = window()
610610
wnd.alert(e)
611611
return false
612612
end try
@@ -695,17 +695,17 @@ sub main
695695
elif (frm.value == sortNameId) then
696696
cls
697697
sortDir = iff(sortDir==0,1,0)
698-
env("sortDir="+sortDir)
698+
env("sortDir=" + sortDir)
699699
frm = makeUI(path, sortDir)
700700
elif (frm.value == sortSizeId) then
701701
cls
702702
sortDir = iff(sortDir==3,2,3)
703-
env("sortDir="+sortDir)
703+
env("sortDir=" + sortDir)
704704
frm = makeUI(path, sortDir)
705705
elif (frm.value == sortDateId) then
706706
cls
707707
sortDir = iff(sortDir==5,4,5)
708-
env("sortDir="+sortDir)
708+
env("sortDir=" + sortDir)
709709
frm = makeUI(path, sortDir)
710710
fi
711711
wend

src/ui/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818

1919
#define DEFAULT_FOREGROUND 0xa1a1a1
20-
#define DEFAULT_BACKGROUND 0
20+
#define DEFAULT_BACKGROUND 0x1f1c1f
2121
#define HANDLE_SCREEN_BUFFER HANDLE_SCREEN
2222
#define USER_MESSAGE_EXIT 1000
2323

src/ui/window.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "common/pproc.h"
1212
#include "lib/maapi.h"
1313
#include "ui/system.h"
14+
#include "ui/textedit.h"
1415

1516
extern System *g_system;
1617

@@ -26,6 +27,7 @@ extern System *g_system;
2627
#define WINDOW_INSET "insetTextScreen"
2728
#define WINDOW_SETFONT "setFont"
2829
#define WINDOW_SETSIZE "setSize"
30+
#define WINDOW_THEME "theme"
2931

3032
// returns the next set of string variable arguments as a String list
3133
StringList *get_items() {
@@ -107,6 +109,20 @@ void cmd_window_set_size(var_s *self) {
107109
g_system->setWindowSize(width, height);
108110
}
109111

112+
void cmd_window_get_theme(var_s *self) {
113+
EditTheme theme;
114+
theme.setId(g_themeId);
115+
v_init(self);
116+
map_init(self);
117+
map_set_int(self, "background", -theme._background);
118+
map_set_int(self, "text1", -theme._color);
119+
map_set_int(self, "text2", -theme._syntax_text);
120+
map_set_int(self, "text3", -theme._syntax_comments);
121+
map_set_int(self, "text4", -theme._syntax_command);
122+
map_set_int(self, "text5", -theme._syntax_statement);
123+
map_set_int(self, "text6", -theme._syntax_digit);
124+
}
125+
110126
void cmd_window_alert(var_s *self) {
111127
StringList *items = get_items();
112128
if (!prog_error && items->size() > 0) {
@@ -158,6 +174,7 @@ extern "C" void v_create_window(var_p_t var) {
158174
v_create_func(var, WINDOW_INSET, cmd_window_inset);
159175
v_create_func(var, WINDOW_SETFONT, cmd_window_set_font);
160176
v_create_func(var, WINDOW_SETSIZE, cmd_window_set_size);
177+
v_create_func(var, WINDOW_THEME, cmd_window_get_theme);
161178
}
162179

163180
extern "C" void dev_show_page() {

0 commit comments

Comments
 (0)