From cb9ecc89ca3edf6db99ed17c407867ca55dfebca Mon Sep 17 00:00:00 2001 From: Amy Bowersox Date: Wed, 11 Dec 2019 15:52:49 -0700 Subject: [PATCH] add the undo and clear commands with their icons --- resources/i_clear.png | Bin 0 -> 3927 bytes resources/i_undo.png | Bin 0 -> 3348 bytes scripts/demo1.py | 36 ++++++++++++++++++++++++++++-------- src/Makefile | 8 +++++++- src/stockobj.c | 10 ++++++++++ 5 files changed, 45 insertions(+), 9 deletions(-) create mode 100755 resources/i_clear.png create mode 100755 resources/i_undo.png diff --git a/resources/i_clear.png b/resources/i_clear.png new file mode 100755 index 0000000000000000000000000000000000000000..3d5a4a2be03ad5fc48f071a273aae2c8d177fd10 GIT binary patch literal 3927 zcmZ8kS2P?7*Bzrq7rl=XQ9=fzMK@|h8>1(#az_n8Mvpd#Fr!4f4AEj3y+?1+dk>>U ziztZ}K_d9whkvc_`yTe$XYIAlemLjl>{w$%9U4jwN&o;rqo=D0yJhgdpa9<11v}44 z0D$T;2yTgl+53aMd|o)YK1YC%fnEp@BEZ!N00>x|v$pXQ%dh-1FFa1K2IA>iZ~m0o z&3!F0l~~AqU(xUD*Tvx0cd}%KrO9fq`){uNr^Aktwldm!nS3b7=yF50QF24i6KicN zj`w|)m#-PFJC=)o5ci9pPf0~zU3Z0O2d^GBw&$WQPfFe^ozd<6jI8zVb>+3|45Qxq zCL6vRtb;flJXWdwd|i1t$X9$ph`I`PI>>z}x2C#__J12m!l`VloW%z1zwGVTxu_WV z&F_4bGyDGi{%0fvF&Z0FH(qYB>a=Tz8mZiQ_mk3M-Rx+!HGF;yHkuA#FA6^oJQvU6 z<^4RCqhb^ma|PW0H6HphOec$$33$lcM4tLFFeK>n@YED>IaRBXKnybBRrABXVds?H zaHE?E!c4YfUF8KJrN?vDemE$`&#b+ngZT&}M6a81q@Bw?L1G2*D#>yZ%^7nV3HPyn z(JJn@SW`JB`(*0J+8eQ#0)G2WK(@>!)YATpVFI8-kz!iL_~W`n?#mkYg|^r3v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D;@Uml*p>7%rmP}I& zEjg5tPtPm`-2sd}4%_|oj2jNR8K&H5i*NG~V?Ih?C6+T$mQy9UsK6_Nw5V4!Fio`{ z4*O2=3kH}X<`z*{eC&oZidRtC4@~<$aGi%xUEoNsu!f0Ihjxwe1t~`gZBS!K(Wd}n z!lUj_WX(oR&`+81D(yM)l4Iu;*{A3R`9Ni#h;I0t(B7{i0I2X+H{S&1pNxn+vh(!eB4(jk;lTu3( zDqO{6Y2*;@ugO9_J#TNOr&P3|56rorX8ZbjF_U!D(X(3I*J2ep4%5rm!jKPK1^6F& zpVQLsA&RivjNzqL+EOgc(gZWfqc~6yI9!tCp3~m(tOG~R=01-~$EsF9`gyaePF1or z`x;~H*9=d~Ud~?Wtn~4~T>0L(WQ|vbN}iLXvAoR^t$+HP*Q&duq1ulWjJWt&s5~At zN{Vra9z(n>O=N~yr6k0%8|BNsh`O()bb>Qx%wbQ96)@58CZiN}T z)1k9Hs#_O~TggLaK!E|Es4<^H=#lEhN=0Ta7MX%F$@|gwK~+1vOJWjFI6JTLkTV3_ zNPFQL{-iwuU+M)_;Gz@5J3Q7lT5v2-fcX)niAJs>3aN#t7Xskzi_4;~z^j3k7wOhW&QThPr7BMKR_I#-N%`?qo)dijxh{ z3F0-vsxV7(Lb_%84aF@6r9WHGH;`ND*nFrm9y!Jq9rh{WF2z!1;wYb$gW#r>#>Y39 zZLfy4`7OKx>G#mFEKwN?W*^9$JEhIG1I%@Jg5Gu7t(3>DZYZxLM3Uo)Z2X2ng;b_Y z%lr4!y)LuPR#Td84`TMCW9Qk7E}<#teje4z^MoOaGbN;~Sf(XD{7h9YH#eJ6AeU-Q zMcGwDQ<9DGDdaG2*h1IIFry#}S!aL`?y)wc<;^ literal 0 HcmV?d00001 diff --git a/resources/i_undo.png b/resources/i_undo.png new file mode 100755 index 0000000000000000000000000000000000000000..62b023366ead39554dc0d96223c646d0b9c39adc GIT binary patch literal 3348 zcmV+v4eRoWP) zaB^>EX>4U6ba`-PAZ2)IW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rB zpK$-|ryXH_O?$~mBtm^<{mz3jksKN)Ix!@LW>IH-g zg1&c}${#)fP~Y@u682XDR0P33_jl3E9n@1v#tNNx#BVy>)AwK@? z^F!6XNpW!$Tni3F%=a_C-#2dsjo0iUbpE$&dl0tk= zJZ{hhi66NxyZpwv;IP0mLq<9|PaGl^3vDd7F)JD>@icK*Q8mgJGA=8ew>YciDr?@8 zzc857R#IH2IgA*V5Jv(cWK>Z?85Sb6YNVJ*(tgy#KjiomeSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{007`gL_t(o!|j;M z5yT(}h6%BQG?>yXz*anYvYWkSoQyA6vted`ZZX1qfDp+RVJZ(R9K-!mEPjYat>{|%rDs*6 z9oKLBMWJGai{AUb_3GQnP_Z=Bla5xQXPEfW+Ey@e$HbCOGt95D%2xHgp={S|Uk-|` z*p%y1#J+CMSv6pR0000= rect[0]) and (x < rect[2]) and (y >= rect[1]) and (y < rect[3]) @@ -106,6 +108,19 @@ def repaint(): hdc.solid_rectangle(drawing_rect[0], drawing_rect[1], drawing_rect[2], drawing_rect[3]) for obj in objects_drawn: draw_object(obj) + +def undo_last(): + global objects_drawn + if len(objects_drawn) > 0: + last = len(objects_drawn) - 1 + del objects_drawn[last] + repaint() + +def clear_all(): + global objects_drawn + if len(objects_drawn) > 0: + objects_drawn.clear() + repaint() # --- Graphic feedback -- @@ -215,10 +230,10 @@ def on_touchclick(x, y): select_next_tool() elif point_in_rect(color_select_rect, x, y): select_next_color() - elif point_in_rect(cmd3_rect, x, y): - print("Click command 3") - elif point_in_rect(cmd4_rect, x, y): - print("Click command 4") + elif point_in_rect(undo_rect, x, y): + undo_last() + elif point_in_rect(clear_rect, x, y): + clear_all() def on_button_click(button): if button == 1: # Button 1 = Set backlight level @@ -235,12 +250,17 @@ hdc.text_color = LTGRAY hdc.rop2 = upiwin.R2_COPYPEN hdc.rectangle(tool_select_rect[0], tool_select_rect[1], tool_select_rect[2], tool_select_rect[3]) hdc.rectangle(color_select_rect[0], color_select_rect[1], color_select_rect[2], color_select_rect[3]) -hdc.rectangle(cmd3_rect[0], cmd3_rect[1], cmd3_rect[2], cmd3_rect[3]) -hdc.rectangle(cmd4_rect[0], cmd4_rect[1], cmd4_rect[2], cmd4_rect[3]) +hdc.rectangle(undo_rect[0], undo_rect[1], undo_rect[2], undo_rect[3]) +hdc.rectangle(clear_rect[0], clear_rect[1], clear_rect[2], clear_rect[3]) draw_current_tool() draw_current_color() +hdc_bits.select_object(bmp_undo) +hdc.bitblt(undo_rect[0] + 6, undo_rect[1] + 6, undo_rect[0] + 54, undo_rect[1] + 54, hdc_bits, 0, 0, 0) +hdc_bits.select_object(bmp_clear) +hdc.bitblt(clear_rect[0] + 6, clear_rect[1] + 6, clear_rect[0] + 54, clear_rect[1] + 54, hdc_bits, 0, 0, 0) + # Main message loop msg = {} while upiwin.get_message(msg): diff --git a/src/Makefile b/src/Makefile index b8289c8..aff9c9b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ SPLASHSCREEN=splash-vmwcblk.png OBJS=main.o sysinput.o ep_init.o ep_upiwin.o ep_backlight.o ep_msg.o ep_graphics.o ep_devctxt.o ep_bitmap.o \ ep_upiwin_tmp.o ep_util.o fbinit.o rect.o gfxobj.o devctxt.o dc_screen.o fontengine.o \ bitmap.o stockobj.o fbprimitive.o log.o gpio.o msg_queue.o time_func.o config.o \ - i_freehand.o i_line.o i_rect.o i_fillrect.o splash.o + i_freehand.o i_line.o i_rect.o i_fillrect.o i_undo.o i_clear.o splash.o LIBS=-lpython3.7m -lcrypt -lfreetype -lbcm2835 -lpthread -ldl -lutil -lm CFLAGS=-I/usr/include/python3.7m -I/usr/include/freetype2 -I/usr/include/libpng16 \ -Wall -Werror -fstack-protector -fwrapv -fno-PIE -g -O3 -DDEBUG_ASSERT @@ -39,5 +39,11 @@ i_rect.bin: $(RESOURCES)/i_rect.png $(BUILDUTILS)/mkgfx i_fillrect.bin: $(RESOURCES)/i_fillrect.png $(BUILDUTILS)/mkgfx $(BUILDUTILS)/mkgfx $(RESOURCES)/i_fillrect.png i_fillrect.bin +i_undo.bin: $(RESOURCES)/i_undo.png $(BUILDUTILS)/mkgfx + $(BUILDUTILS)/mkgfx $(RESOURCES)/i_undo.png undo.bin + +i_clear.bin: $(RESOURCES)/i_clear.png $(BUILDUTILS)/mkgfx + $(BUILDUTILS)/mkgfx $(RESOURCES)/i_clear.png i_clear.bin + clean: rm -f upiwin *.o splash.bin *~ diff --git a/src/stockobj.c b/src/stockobj.c index 82350d8..394195a 100755 --- a/src/stockobj.c +++ b/src/stockobj.c @@ -20,6 +20,14 @@ extern uint8_t _binary_i_fillrect_bin_start[]; extern uint8_t _binary_i_fillrect_bin_end; extern uint8_t _binary_i_fillrect_bin_size; +extern uint8_t _binary_i_undo_bin_start[]; +extern uint8_t _binary_i_undo_bin_end; +extern uint8_t _binary_i_undo_bin_size; + +extern uint8_t _binary_i_clear_bin_start[]; +extern uint8_t _binary_i_clear_bin_end; +extern uint8_t _binary_i_clear_bin_size; + typedef struct tagSTOCKBITMAPDESC { PCSTR name; INT32 width; @@ -32,6 +40,8 @@ static const STOCKBITMAPDESC stock_bitmaps[] = { {"line", 48, 48, _binary_i_line_bin_start }, {"rect", 48, 48, _binary_i_rect_bin_start }, {"fillrect", 48, 48, _binary_i_fillrect_bin_start }, + {"undo", 48, 48, _binary_i_undo_bin_start }, + {"clear", 48, 48, _binary_i_clear_bin_start }, {NULL, 0, 0, NULL } };