Skip to content

Commit 4c645f7

Browse files
committed
gui fixes
1 parent 0234554 commit 4c645f7

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

eth_view_process.c

+35-18
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ static void draw_dec_number(Canvas* canvas, uint8_t x, uint8_t y, uint8_t num) {
7272

7373
static void draw_static_mode(Canvas* canvas, uint8_t mode) {
7474
const uint8_t s1 = 13;
75-
const uint8_t s2 = 30;
76-
const uint8_t s3 = 17;
77-
const uint8_t s4 = 20;
78-
const uint8_t s = 40;
75+
const uint8_t s2 = 31;
76+
const uint8_t s3 = 19;
77+
const uint8_t s4 = 21;
78+
const uint8_t s = 35;
7979
const uint8_t h = 7;
8080
const uint8_t y = 10;
8181
const uint8_t y1 = 15;
@@ -84,25 +84,25 @@ static void draw_static_mode(Canvas* canvas, uint8_t mode) {
8484
canvas_invert_color(canvas);
8585
canvas_draw_box(canvas, s, y, s1, h);
8686
canvas_invert_color(canvas);
87-
canvas_draw_str(canvas, 43, y1, "ip");
87+
canvas_draw_str(canvas, 38, y1, "ip");
8888
}
8989
if(mode == EthViewDrawStaticModeMask) {
9090
canvas_invert_color(canvas);
9191
canvas_draw_box(canvas, s + s1, y, s2, h);
9292
canvas_invert_color(canvas);
93-
canvas_draw_str(canvas, 57, y1, "mask");
93+
canvas_draw_str(canvas, 53, y1, "mask");
9494
}
9595
if(mode == EthViewDrawStaticModeGateway) {
9696
canvas_invert_color(canvas);
9797
canvas_draw_box(canvas, s + s1 + s2, y, s3, h);
9898
canvas_invert_color(canvas);
99-
canvas_draw_str(canvas, 85, y1, "gw");
99+
canvas_draw_str(canvas, 82, y1, "gw");
100100
}
101101
if(mode == EthViewDrawStaticModeDNS) {
102102
canvas_invert_color(canvas);
103103
canvas_draw_box(canvas, s + s1 + s2 + s3, y, s4, h);
104104
canvas_invert_color(canvas);
105-
canvas_draw_str(canvas, 104, y1, "dns");
105+
canvas_draw_str(canvas, 102, y1, "dns");
106106
}
107107
}
108108

@@ -154,17 +154,17 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
154154
}
155155
}
156156
} else if(process->type == EthWorkerProcessStatic) {
157-
canvas_draw_frame(canvas, 36, 18, 21, 13);
158-
canvas_draw_frame(canvas, 59, 18, 21, 13);
159-
canvas_draw_frame(canvas, 82, 18, 21, 13);
160-
canvas_draw_frame(canvas, 105, 18, 21, 13);
161-
canvas_draw_box(canvas, 36, 10, 90, 7);
157+
canvas_draw_frame(canvas, 31, 18, 21, 13);
158+
canvas_draw_frame(canvas, 55, 18, 21, 13);
159+
canvas_draw_frame(canvas, 79, 18, 21, 13);
160+
canvas_draw_frame(canvas, 103, 18, 21, 13);
161+
canvas_draw_box(canvas, 29, 10, 97, 7);
162162
uint8_t mode = ((EthViewDrawStatic*)process->draw_struct)->current_mode;
163163
uint8_t current_digit = ((EthViewDrawStatic*)process->draw_struct)->current_digit;
164164
uint8_t* adress = draw_static_get_current_adress((EthViewDrawStatic*)process->draw_struct);
165165
uint8_t editing = ((EthViewDrawStatic*)process->draw_struct)->editing;
166166
for(uint8_t i = 0; i < 4; ++i) {
167-
if(i == mode) {
167+
if(i == mode && process->editing) {
168168
draw_static_mode(canvas, mode);
169169
} else {
170170
canvas_invert_color(canvas);
@@ -173,7 +173,7 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
173173
}
174174
}
175175
for(uint8_t i = 0; i < 4; ++i) {
176-
uint8_t x = 38 + i * 23;
176+
uint8_t x = 33 + i * 24;
177177
draw_dec_number(canvas, x, 27, adress[i]);
178178
if(editing && (current_digit / 3 == i)) {
179179
uint8_t x1 = x + 6 * (current_digit % 3);
@@ -213,7 +213,11 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
213213
uint8_t octet = ((EthViewDrawInit*)process->draw_struct)->current_octet;
214214
uint8_t* mac = ((EthViewDrawInit*)process->draw_struct)->mac;
215215
if(key == InputKeyLeft) {
216-
if(octet > 0) octet -= 1;
216+
if(octet > 0) {
217+
octet -= 1;
218+
} else {
219+
process->editing = 0;
220+
}
217221
} else if(key == InputKeyRight) {
218222
if(octet < 11) octet += 1;
219223
} else if(key == InputKeyUp) {
@@ -231,7 +235,11 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
231235
uint8_t editing = ((EthViewDrawStatic*)process->draw_struct)->editing;
232236
if(editing) {
233237
if(key == InputKeyLeft) {
234-
if(digit > 0) digit -= 1;
238+
if(digit > 0) {
239+
digit -= 1;
240+
} else {
241+
((EthViewDrawStatic*)process->draw_struct)->editing = 0;
242+
}
235243
} else if(key == InputKeyRight) {
236244
if(digit < 11) digit += 1;
237245
} else if(key == InputKeyUp) {
@@ -240,6 +248,9 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
240248
adress_change_dec_digit(adress, digit, -1);
241249
} else if(key == InputKeyOk) {
242250
((EthViewDrawStatic*)process->draw_struct)->editing = 0;
251+
} else if(key == InputKeyBack) {
252+
mode = 0;
253+
((EthViewDrawStatic*)process->draw_struct)->editing = 0;
243254
}
244255
} else {
245256
if(key == InputKeyLeft) {
@@ -252,12 +263,18 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
252263
if(mode < 3) {
253264
mode += 1;
254265
}
255-
} else if(key == InputKeyUp || key == InputKeyDown) {
266+
} else if(key == InputKeyDown || key == InputKeyOk) {
256267
((EthViewDrawStatic*)process->draw_struct)->editing = 1;
268+
} else if(key == InputKeyBack || key == InputKeyUp) {
269+
process->editing = 0;
257270
}
258271
}
259272
((EthViewDrawStatic*)process->draw_struct)->current_mode = mode;
260273
((EthViewDrawStatic*)process->draw_struct)->current_digit = digit;
274+
} else {
275+
if(key == InputKeyBack || key == InputKeyLeft) {
276+
process->editing = 0;
277+
}
261278
}
262279
}
263280

finik_eth_app.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ int32_t finik_eth_app(void* p) {
152152
app->cursor_position = CURSOR_CLICK_PROCESS;
153153
view_port_update(app->view_port);
154154
furi_delay_ms(150);
155-
app->eth_worker->active_process->editing = 1;
156155
char str[] = "test string 0 with some parameters";
157156
str[12] += cnt % 10;
158157
cnt += 1;
@@ -161,7 +160,7 @@ int32_t finik_eth_app(void* p) {
161160
ethernet_view_process_print(
162161
app->eth_worker->dhcp_process,
163162
"test dhcp process string. loooooong world");
164-
app->cursor_position = CURSOR_INSIDE_PROCESS;
163+
app->cursor_position = CURSOR_CHOOSE_PROCESS;
165164
} else if(event.key == InputKeyRight) {
166165
eth_worker_set_active_process(
167166
app->eth_worker, (EthWorkerProcess)app->draw_process);
@@ -171,11 +170,7 @@ int32_t finik_eth_app(void* p) {
171170
}
172171
} else if(event.type == InputTypePress && app->cursor_position == CURSOR_INSIDE_PROCESS) {
173172
if(app->eth_worker->active_process->editing) {
174-
if(event.key == InputKeyBack) {
175-
app->eth_worker->active_process->editing = 0;
176-
} else {
177-
ethernet_view_process_keyevent(app->eth_worker->active_process, event.key);
178-
}
173+
ethernet_view_process_keyevent(app->eth_worker->active_process, event.key);
179174
} else if(event.key == InputKeyLeft) {
180175
app->eth_worker->active_process->editing = 0;
181176
app->cursor_position = CURSOR_CHOOSE_PROCESS;

0 commit comments

Comments
 (0)