It is currently Tue Apr 25, 2017 11:21 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GW 4.4
Unread postPosted: Sat Dec 03, 2016 4:15 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Hi Nicolas,

I see that you didn't include GW_PAGE_SCALE() in GW 4.4, which I really think would have been a great addition.
As an alternative, what would you think of creating a third party lib GW_UTILS.bas which would contain useful functions which don't find their way into the core GW.bas?
Such 3pp lib could grow as needed.

I report an example below.

/ Luca

Code:
! This is the third party lib "GW_UTILS.bas"
! http://laughton.com/basic/programs/html/GW%20(GUI-Web%20lib)/
!
! This lib requires the main lib "GW.bas" and of course Android RFO-BASIC!
! To download the lib when you have "GW.bas" on your device, do:
!    GW_DOWNLOAD_THIRD_PARTY("GW_UTILS.bas")
!
! USAGE: in your program do: INCLUDE "GW.bas"
! Then call:
!      GW_PAGE_SCALE (mypage, zoom) % Changes page scaling -- zoom = 0.1 .. 1
!      GW_SET_VIEWPORT (mypage, "param1=value1 param2=value2 ...") % Changes viewport for page
!      :PARAM:          :VALUES
!      :width           :device-width|1 .. 10000
!      :height          :device-height|1 .. 10000
!      :initial-scale   :0.1 .. 10
!      :minimum-scale   :0.1 .. 10
!      :maximum-scale   :0.1 .. 10
!      :user-scalable   :yes|no
!      NOTE: Default Viewport is:
!        width=device-width initial-scale=1 minimum-scale=1 maximum-scale=1 user-scalable=no

INCLUDE "GW.bas"

FN.DEF GW_PAGE_SCALE(page, zoom)
  script$ ="$(document).ready(function(){"
  script$+="$('body').css({transform:'scale("+STR$(zoom)+")'"
  script$+=",transformOrigin:'0 0',width:'"+INT$(100/zoom)+"%'});});"
  GW_INJECT_HTML(page, "<script>" + script$ + "</script>")
FN.END

FN.DEF GW_SET_VIEWPORT(page, new_viewport$)
  IF !IS_IN(",", new_viewport$) THEN new_viewport$ = REPLACE$(new_viewport$, " ", ", ")
  page$ = GW_PAGE$(page)
  left = IS_IN("content='", page$) + 8
  right = LEN(page$) - IS_IN("'><style>", page$) + 1
  new_page$ = LEFT$(page$, left) + new_viewport$ + RIGHT$(page$, right)
  LIST.REPLACE 1, ABS(page), new_page$
FN.END


Top
 Profile  
 
 Post subject: Re: GW 4.4
Unread postPosted: Sat Dec 03, 2016 4:56 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5485
Location: Paris, France
Hello Luca,

So far only Gilles showed interest in a scaling function for the page.
I proposed GW_PAGE_SCALE() although I really wasn't satisfied of it (it looks too much like a coarse hack).
Also, I didn't get any feedback on it...

Plus, it's a 4-line function (!)
If one user wants a feature that needs 4 lines of code, it wouldn't be very fair that I slow-down everybody else's GW program by adding a new function to the lib, would it ? ;)

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW 4.4
Unread postPosted: Sat Dec 03, 2016 5:01 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5485
Location: Paris, France
The GW_UTILS third-party lib is a good idea ;)

You don't need me to propose it!
Feel free to put it in Paul's FTP > html/GW (GUI-Web lib)/third-party-libs

It will be a nice addition to have another "misc-featured" third-party lib, as long as it's supported (and ideally maintained).

Glad to see you onboard :mrgreen:

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW 4.4
Unread postPosted: Sat Dec 03, 2016 6:12 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Hi Nicolas,

I'll gladly maintain GW_SET_VIEWPORT(), but you'll need to maintain your GW_PAGE_SCALE() ;).
The 3rd party lib GW_UTILS.bas should be a misc collection of small utility functions from different sources.
Then from time to time if one understands that a specific function gets popular, it could be promoted into GW.bas.

By the way, would you prefer GW_SET_VIEWPORT or GW_CHANGE_VIEWPORT?

Luca


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
suspicion-preferred