The time now is Fri 20 Apr 2018, 07:19
All times are UTC - 4 |
Page 1 of 4 [46 Posts] |
Goto page: 1, 2, 3, 4 Next |
Author |
Message |
SFR

Joined: 26 Oct 2011 Posts: 1655
|
Posted: Mon 19 Nov 2012, 15:56 Post subject:
BDraw v1.8 Subject description: Have you ever been making drawings...within a button? |
|
I wrote simple graphic program in Gtkdialog and this is crazy, but...it works!
It uses <button> widget as a drawing area (that's why "BDraw").
Take a look at the screenshot; the toolbox area contains (from left to right):
- current shape
- stroke width
- transparency level
- stroke color
- fill color
(next row):
- Undo - delete last drawn object, doesn't work with Load & Save
- Load - load a picture, only .bdr format is accepted (well, it's SVG really, but has specific arrangement of lines)
- Save - save as .bdr (for further editing) or as .png (you can choose output resolution)
- Quit
Few words about drawing:
When you choose, eg. Line or Circle, then press the mouse button on starting point, drag cursor to the ending point and release button.
But there are two exceptions:
1. Text - press and release the button on starting point; this point will become the bottom-left beginning of the text.
Then choose a font (avoid fonts with digits in their names, they won't work [EDIT: they work since v1.1]), style and size and in the next window enter some text.
2. Arc - press the mouse button on starting point, drag cursor to the ending point and release button, then move cursor to another point and press space [EDIT: since v1.3 - press right mouse button].
(Then you can move cursor to another place and press space again, and so on.)
The drawing area is fixed to 512x512, but it doesn't matter IMHO, since it's vector graphic. As I wrote above you can adjust final resolution while exporting to PNG.
Hint: since you're drawing within a button, it blinks on hover and clicking. To avoid this, just draw filled rectangle that fills all space. This will also remove default transparency of the background.
Requirements:
- Gtkdialog >= 0.7.21 (version 1.0)
- Gtkdialog >= 0.8.0 (versions >= 1.1)
- Gtkdialog >= 0.8.1 (versions >= 1.3)
- base64 (versions >= 1.4)
- Xdialog
- rsvg-convert (for .png output)
- xwininfo
- getcurpos
- awk, sed, and so on.
(all of these should be already present in most/all of recent Puppies)
I've attached standalone, gzip'ed scripts - unpack, make executable and click to launch.
I didn't make a pet, but if someone could kindly make a nice icon for this app (I simply can't draw!) then I'll do it.
Tested on:
- Slacko-5.3.3, 5.4, 5.5
- Lupuplus-528.005
- Precise-5.4.1
- Akita-beta13
- FatDog64-601
- Carolina-0.0.3
- uPup-Precise-5.4.X.4
_____________
Edit:
Version 1.1 uploaded, see this post for changelog.
Version 1.2 uploaded, see this post for changelog.
Version 1.3 uploaded, see this post for changelog.
Version 1.4 uploaded, see this post for changelog.
Version 1.5 uploaded, see this post for changelog.
Version 1.5 replaced with v1.5.1, see this post for details.
Version 1.6 uploaded, see this post for changelog.
Version 1.6.1 uploaded, see this post for changelog.
Version 1.7 uploaded, see this post for changelog
Version 1.8:
- removed 'vercmp' dependency and used 'busybox dc' for compatibility with Fatdog
Have fun & Greetings!
 |
Description |
Unpack, make executable & click to launch. 43bfa01b0baee491411a227aaf5ad0eb bdraw-1.8.sh
|

Download |
Filename |
bdraw-1.8.sh.tar.gz |
Filesize |
7 KB |
Downloaded |
131 Time(s) |
Description |
Unpack, make executable & click to launch. MD5: b9d67555b28214610854e35cfd6a8fe2 bdraw-1.7.sh
|

Download |
Filename |
bdraw-1.7.sh.gz |
Filesize |
6.77 KB |
Downloaded |
400 Time(s) |
Description |
Unpack, make executable & click to launch. MD5: 1b568be289430f13b46cacf8eda91ed6 bdraw-1.6.1.sh
|

Download |
Filename |
bdraw-1.6.1.sh.gz |
Filesize |
7.3 KB |
Downloaded |
474 Time(s) |
Description |
Unpack, make executable & click to launch. MD5: 2a73ea728b2e3e61c81a94802d22c117 bdraw-1.6.sh WARNING - this version may not work due to <spinbutton> failure in some cases. Reason: comma as decimal separator.
|

Download |
Filename |
bdraw-1.6.sh.gz |
Filesize |
7.29 KB |
Downloaded |
699 Time(s) |
Description |
Unpack & click to launch.
|

Download |
Filename |
bdraw-1.4.sh.gz |
Filesize |
6.51 KB |
Downloaded |
690 Time(s) |
Description |
Unpack & click to launch.
|

Download |
Filename |
bdraw-1.3.sh.gz |
Filesize |
5.86 KB |
Downloaded |
693 Time(s) |
Description |
Unpack & click to launch.
|

Download |
Filename |
bdraw-1.2.sh.gz |
Filesize |
4.95 KB |
Downloaded |
676 Time(s) |
Description |
Unpack & click to launch.
|

Download |
Filename |
bdraw-1.1.sh.gz |
Filesize |
5.04 KB |
Downloaded |
688 Time(s) |
Description |
Unpack & click to launch. (this is old version 1.0)
|

Download |
Filename |
bdraw.sh.gz |
Filesize |
3.63 KB |
Downloaded |
738 Time(s) |
Description |
|
Filesize |
55.77 KB |
Viewed |
1771 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Last edited by SFR on Sat 21 Mar 2015, 11:08; edited 26 times in total
|
Back to top
|
|
 |
puppyluvr

Joined: 06 Jan 2008 Posts: 3466 Location: Chickasha Oklahoma
|
Posted: Mon 19 Nov 2012, 19:44 Post subject:
|
|
Hello,
Amazing.. Simply amazing..
Who would have thought... Well, you of course..
Ohh, the possibilities....
Been playing with gtk lately..
I believe we yet just touching on what it can do..
All the parts are there, its just figuring out creative ways to use them..
Like this...
I`ve already got ideas for this...
_________________ Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!
Puppy since 2.15CE...
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1447 Location: Ukraine
|
Posted: Tue 20 Nov 2012, 05:53 Post subject:
|
|
Dear SFR,
Yes, amazing! Congrats.
With kind regards,
vovchik
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1655
|
Posted: Tue 20 Nov 2012, 06:09 Post subject:
|
|
Thanks guys!
I still can't believe it works...
The one who discovered how to draw on screen borders in C64 must have felt similarly.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Tue 20 Nov 2012, 06:28 Post subject:
|
|
Brilliant!
zigbert (who happens to be an artist, major gtkdialog fan and svg fan) will fall in love with this!
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2571 Location: UK
|
Posted: Tue 20 Nov 2012, 06:45 Post subject:
|
|
Oh. My. Word.
_________________ Akita Linux, VLC-GTK, Pup Search, Pup File Search
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1447 Location: Ukraine
|
Posted: Wed 21 Nov 2012, 07:52 Post subject:
|
|
Dear SFR,
I wonder whether I shouldn't try to port your code to BaCon. It is brilliant (yours), but we would get a real speed increase and, if UPX'd, it would be about 7-10k and be a very responsive little draw program. What do you think?
With kind regards,
vovchik
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Wed 21 Nov 2012, 08:42 Post subject:
|
|
Refreshing!
Sometimes, codelines get you in a good mood.
_________________ Stardust resources
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1655
|
Posted: Wed 21 Nov 2012, 09:21 Post subject:
|
|
vovchik wrote: | Dear SFR,
I wonder whether I shouldn't try to port your code to BaCon. It is brilliant (yours), but we would get a real speed increase and, if UPX'd, it would be about 7-10k and be a very responsive little draw program. What do you think?
With kind regards,
vovchik |
I think it's great idea, thank you! But if you could wait a while - I'm working on some little improvements (unfortunately they require Gtkdialog >= 0.8.0 now, but on the other hand every modern Puppy has it) and I did overlook 2-3 things, must fix them now.
I'll post it ASAP, maybe even today.
Thanks again you all &
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1655
|
Posted: Wed 21 Nov 2012, 16:18 Post subject:
|
|
SFR wrote: | The drawing area is fixed to 512x512, but it doesn't matter IMHO, since it's vector graphic. As I wrote above you can adjust final resolution while exporting to PNG. |
Well, it matters really if we consider ratio...
Fortunately it's been solved (in a bit ugly, but somehow working way).
Franky, since the beginning I wanted to add the choice of size of drawing area, but the problem was that if the area was too narrow, the bottom widgets made the whole window stretched, including the "Main Button".
Even if I used <hbox></hbox>, the button was aligned to the right, which was completely opposite of what I wanted.
And even the great trick with <hbox><text> unveiled by Zigbert in his Gtkdialog thread didn't work, because although Main Button was aligned to the left, still was stretched too much.
The idea was to add another, invisible button next the Main One, which equalize the whole size and align Main Button to the left...but how to determine the overall size of a window before it's displayed..?
(Note - I had to consider that each user has different font size what causes different size of bottom buttons).
At first there's created an empty picture with 1x1 resolution and put into that invisible "Fix Button".
Then, when the window is being displayed, appropriate function is called and send to the background, waits 0.2s to make sure that the window is "really" displayed and visible for xwininfo, calculates the proper width of that picture and overwrites it.
The unsolved thing is to automatically refresh/resize "Fix Button" - now it's done when user hover the Main Button area for the first time.
Another thing I'm not happy with: even if drawing area is wide enough and Fix Button's width is set to 1px, there's still thin, vertical bar of empty space next to drawing area, on the right.
The maximum allowed picture resolution is calculated like this:
Max_X = Screen_Width - 64
Max_Y = Screen_Height - 256
Limiting the height is important because:
if
1). Picture height is greater than screen height
and
2). Picture is narrower than bottom widgets
then
when Fix Button is being resized, the whole window is cropped at bottom and adjusted to screen height.
I don't know why this happens and can't fix it, sorry. I hope the resolution limit won't be a big problem to anyone..?
On the other hand you can edit even 1x1 picture (if you have ultra-sensitive mouse and sharp eye).
Well, after all I believe it's fair trade, since BDraw is much more functional now.
And all in all it's just a playful toy.
"Load" button has been removed from the main window and now when app is launched there's a little initial window with "New", "Open" and "Quit" buttons.
Another fixes/additions:
- Oversight in Text tool: if there's more than one space in a row, they'll be displayed as one space; fixed now.
- Fonts with digits in their names - fixed!
- Added "Redo" button. I didn't mention it before, but Undo is multi-level, as well as Redo.
But to avoid some ambiguous mess, after drawing any shape, Redo buffer is cleared.
- Added cursor position view (updated every 1s) and current picture resolution.
@Vovchik - Is it possible to increase the update interval in BaCon, so it'd be close to realtime..?
- few minor code improvements
PS. Only two widgets seem to require Gtkdialog-0.8.0, so if someone would like to backport it to 0.7.21, it's just a matter of replacing <statusbar> with <text> and <timer> with <progressbar> (see Zigbert's thread for details).
First post updated.
Ok, that would be all for now.
Greetings!
 |
Description |
|
Filesize |
31.8 KB |
Viewed |
1498 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1447 Location: Ukraine
|
Posted: Wed 21 Nov 2012, 16:43 Post subject:
|
|
Dear SFR,
I do not know how to tell you that you have uncovered something like quantum mechanics within the GTK button widget. Lovely And I worked for decades at the IAEA and did their first TCP/IP. You captured something essential. Nice
With kind regards,
vovchik
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 917
|
Posted: Wed 21 Nov 2012, 17:11 Post subject:
|
|
SFR, I just saw this and had to say-
This is the first drawing program that made me actually feel like drawing something (not that anyone else would share that interest after seeing how I draw....)
Very clean, attractive, and cleverly done.
Hats off to you,
Regards,
s
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Wed 21 Nov 2012, 17:28 Post subject:
|
|
SFR
The tips-thread is a bit old - it was written in those days before Thunor stepped up. Gtkdialog was not that powerful, and we needed more workarounds.
Some thoughts:
- I usual align widgets to the left by including a text widget. <text space-expand="true" space-fill="true"><label>""</label></text>
- You can make the drawing size larger than screen-size by setting the <button> widget inside a <vbox scrollable="true">
- I think it would be possible to use a <pixmap> widget instead of the <button> for the drawing. gtkdialog supports <eventbox> which can add <actions> to nonactive widgets like the <pixmap>.
- The <timer> can be updated more frequently than each sec. <timer visible="false" milliseconds="true" interval="100">
Sigmund
_________________ Stardust resources
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1655
|
Posted: Wed 21 Nov 2012, 18:49 Post subject:
|
|
Hey Zigbert.
Quote: | - I usual align widgets to the left by including a text widget. <text space-expand="true" space-fill="true"><label>""</label></text> |
Yes, this is the trick I tried - the problem is that the Left Button becomes stretched anyway and covers ~half of the window (horizontally).
Couldn't find out any way to get its real size.
Quote: | - You can make the drawing size larger than screen-size by setting the <button> widget inside a <vbox scrollable="true"> |
Good thinking, but I'll lose the ability to calculate mouse position properly...hmm, maybe in one of future Gtkdialog version will be something like "read-vbox/hbox-scrollbar-shift".
Quote: | - I think it would be possible to use a <pixmap> widget instead of the <button> for the drawing. gtkdialog supports <eventbox> which can add <actions> to nonactive widgets like the <pixmap>. |
I didn't play with Gtkdialog >= 0.8.1 yet, but I'll try it one of these days, thanks!
Quote: | - The <timer> can be updated more frequently than each sec. <timer visible="false" milliseconds="true" interval="100"> |
Just tried and it works and looks nice...but unfortunately, it slows down response time and if user presses button and starts to drag the cursor too sudden, the initial X & Y coordiantes are incorrectly calculated.
Well, it happens even now with interval="1" (sec.), but to a lesser extent.
Thanks you for your tips, appreciated!
And thanks again to all of you for kind words &
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
Geoffrey

Joined: 30 May 2010 Posts: 2345 Location: Queensland
|
Posted: Wed 21 Nov 2012, 21:56 Post subject:
|
|
Good stuff, tried it in Carolina with gtkdialog version 0.8.3 r473M, it all works.
_________________ Carolina: Recent Repository Additions

|
Back to top
|
|
 |
|
Page 1 of 4 [46 Posts] |
Goto page: 1, 2, 3, 4 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|