by Aerilius » Wed Sep 05, 2012 11:37 pm
In some situations the possibilities with SketchUp's built-in UI elements are easily exhausted, they are either too obtrusive (UI.inputbox), too hidden (VCB) or not flexible enough (Toolbar). In my case I needed only a few tool options that were not worth to have a webdialog or that would be rather confusing on a toolbar (where users expect tools). So I created these UI elements using the View.draw methods, nothing new, except that I made some sort of toolkit that can be implemented with only a few lines (example): - Code: Select all
class TestTool
include AE::GUI::OnScreen
def initialize
window.layout=({:margin=>5, :orientation=>:horizontal, :align=>:center, :valign=>:top})
button = Button.new("Click Me"){ UI.messagebox("Clicked!") }
slider = Slider.new("Radius", [0,100]){|value| @@radius = value }
window.add(button, slider)
end
end
https://bitbucket.org/Aerilius/onscreen-gui/wiki/HomeMore widgets can be added and the style can be changed with a CSS-like syntax. sketchup_css.png
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by driven » Thu Sep 06, 2012 12:40 am
Excellent,
I'll give it a spin on my mac... if I can clone the source for AE::GUI::OnScreen ??
john
Last edited by driven on Thu Sep 06, 2012 12:58 am, edited 1 time in total.
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3034
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Jim » Thu Sep 06, 2012 12:55 am
Nice idea. It definitely fills a niche for some types of plugins. 
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Dan Rathbun » Thu Sep 06, 2012 1:51 am
interesting!
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5042
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Aerilius » Thu Sep 06, 2012 4:02 am
driven wrote:if I can clone the source for AE::GUI::OnScreen ??
An easy way (without need for git) is to download a zip archive (top right corner "get source"). Then in SketchUp: load "ae_OnScreenGUI.rb" # (which loads the other files) Sketchup.active_model.select_tool(AE::GUI::OnScreen::TestTool.new)
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by Anton_S » Thu Sep 06, 2012 7:06 am
-
Anton_S
- PluginStore Author

-
- Posts: 1213
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by thomthom » Thu Sep 06, 2012 8:35 am
Very nice! I got framework of my own for this - but I've never got around to release it for public consumption. One thing to note - if you want to draw lines of odd size then you need to offset the co-ordinates by 0.5. (This is only on nVidia cards I think - ATI adjust to pixel grid automatically last time I checked on my very old Radeon 9800) I'm building a wrapper to let me draw shapes that adjust correctly to the pixel grid. It's combined with a cache system - where it takes all the drawing call that View does. This means that you send drawing instructions to the cache when something changes and in the draw event it simply draws all the instructions which has been pre-processed. This easily avoids unnecessary calculations in the draw event which often slows down the refresh rate. I'm also working on a GL vector image system, which you might find interesting. I'll see if I can extract tit to standalone code. It's a system mean for replacement of my GL bitmap drawing (which can only handle a handful of small bitmaps before things get to slow.). The GL vector image framework let you define shapes etc in a simple text file which then loaded is converted into GL drawing instructions. Nice for scalable vector images. Just wish I had time for a simple drawing editor - or a converter from something like SVG to GL. It'd be cool to consolidate some of this into a large framework.
-

thomthom
- PluginStore Author

-
- Posts: 19487
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by driven » Fri Sep 07, 2012 2:44 am
Aerilius wrote:An easy way (without need for git) is to download a zip archive (top right corner "get source").
I don't see any source option, but I can at TT's repositry on yours, it says Repositories Aerilius has no public repositories.any clues or could you PM the zip file cheers john
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3034
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Chris Fullmer » Fri Sep 07, 2012 4:40 am
Well done. I had a pretty awesome RGB color selector box 90% made. But I never quite figured out one of the conversions that I needed, so I never finished. Maybe I should finish it and pass it on to you. I'd love to see it released finally.
-

Chris Fullmer
- SketchUp Team

-
- Posts: 6929
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Boulder, CO
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by thomthom » Fri Sep 07, 2012 9:14 am
The source for GL_Image is here at the repo: https://bitbucket.org/thomthom/tt-libra ... l_image.rbDocs: http://www.thomthom.net/software/sketch ... Image.htmlChris Fullmer wrote:Well done. I had a pretty awesome RGB color selector box 90% made. But I never quite figured out one of the conversions that I needed, so I never finished. Maybe I should finish it and pass it on to you. I'd love to see it released finally.
I was thinking of that one the other day. I way playing with the idea of a viewport on-screen sketching plugin. For when you make videos or make presentations. Needs a colour picker.
-

thomthom
- PluginStore Author

-
- Posts: 19487
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Aerilius » Fri Sep 07, 2012 9:44 am
driven wrote:I don't see any source option
I didn't notice that it was not public (because of the auto-login I didn't see how it looks from outside). I made it downloadable now. Chris Fullmer wrote:But I never quite figured out one of the conversions that I needed, so I never finished.
There are some color conversion methods in my color library.
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by driven » Fri Sep 07, 2012 11:39 am
Aerilius wrote:load "ae_OnScreenGUI.rb" # (which loads the other files) Sketchup.active_model.select_tool(AE::GUI::OnScreen::TestTool.new)
Had to comment out protected line 128 in Window.rb for everything to work, and to stop error messages re. view being a protected method. else, works a treat until I draw something, and I can only get it back by using Sketchup.active_model.select_tool(AE::GUI::OnScreen::TestTool.new)is that right? john
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3034
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by thomthom » Fri Sep 07, 2012 11:43 am
Can we get a public Issue Tracker?
-

thomthom
- PluginStore Author

-
- Posts: 19487
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Fri Sep 07, 2012 11:56 am
My draw cache class. You create an instance of it and call the drawing methods you'd usually call on View to this. And in the tool's draw event to make it render out the cached drawing instructions. Example:- Code: Select all
class MyTool def initialize @drawing_cache = DrawCache.new( Sketchup.active_model.active_view ) end def onLButtonUp(flags, x, y, view) @drawing_cache.line_stipple = '-' @drawing_cache.draw( GL_QUADS, ... ) @drawing_cache.draw( GL_LINES, ... ) @drawing_cache.draw_points( GL_QUADS, ... ) end def draw( view ) @drawing_cache.render end end
DrawCache Class- Code: Select all
module TT::Plugins::BezierSurfaceTools class DrawCache def initialize( view ) @view = view @commands = [] end def clear @commands.clear nil end def render view = @view for command in @commands view.send( *command ) end view end [ :draw, :draw2d, :draw_line, :draw_lines, :draw_points, :draw_polyline, :draw_text, :drawing_color=, :line_stipple=, :line_width=, :set_color_from_line ].each { |symbol| define_method( symbol ) { |*args| @commands << args.unshift( this_method ) @commands.size } } def method_missing( *args ) view = @view method = args.first if view.respond_to?( method ) view.send(*args) else raise NoMethodError, "undefined method `#{method}' for #{self.class.name}" end end def inspect hex_id = TT.object_id_hex( self ) "#<#{self.class.name}:#{hex_id} Commands:#{@commands.size}>" end private def this_method ( caller[0] =~ /`([^']*)'/ and $1 ).intern end end # class DrawCache
end # module
-

thomthom
- PluginStore Author

-
- Posts: 19487
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Jim » Sat Sep 08, 2012 3:50 pm
Here's how it looks on my cheap laptop. Do the sliders work? They did not work for me. It was a little slow with all 3 themes shown. When I commented out all but the native theme, it was better. I wouldnt expect the average plugin to use anywhere close to the number of widgets in the test tool, so performance wouldn't be an issue. 2012-09-08_103757.png
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by sdmitch » Sat Sep 08, 2012 6:09 pm
When I try to test OnScreen GUI no errors are indicated but the window never appears. OnScreenGUI.png
-

sdmitch
- PluginStore Author

-
- Posts: 1496
- Joined: Wed Mar 02, 2011 9:21 pm
- Name: sdmitch
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by Jim » Sat Sep 08, 2012 6:21 pm
Sam, you need to make it the active tool..
Sketchup.active_model.select_tool(TestTool.new)
And you may need to zoom a little to get it to activate - the tool may need a view.invalidate/view.refresh in there somewhere.
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by sdmitch » Sat Sep 08, 2012 6:32 pm
DOH!!!
edit:
Ok now how to use it. I have played around a bit with the testGUI.rb trying to figure out how to get the value from the widget. The slider example seems to emply that variable value should be the current value of the slider but it contains something like "pos(84.0,19.0,-1.0)flags0".
-

sdmitch
- PluginStore Author

-
- Posts: 1496
- Joined: Wed Mar 02, 2011 9:21 pm
- Name: sdmitch
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by Aerilius » Sun Sep 09, 2012 6:34 pm
That's a bug! (the raw data of the event and where the slider was clicked)
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by tomasz » Wed Sep 12, 2012 11:35 am
Thank you for sharing this! I want to revamp SU2KT when time permits. I will report if I find any bugs.
-
tomasz
- SU2TH & SU2KT Developer
-
- Posts: 928
- Joined: Fri Nov 16, 2007 8:46 pm
- Location: Poland
- Name: Tomasz Marek
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by kirill2008 » Fri Sep 14, 2012 10:38 am
I don't even know how to call this coincidence maybe a kind of synchronicity... I mean a few weeks ago the idea to make custom UI library based on view.draw method suddenly came to my mind. And I even started to code it  Actually I needed a kind of adjustment curve editing control for one of my tools and since I didn't find any javascript ready made widget I decided to make my own control based on view.draw... I think it would be interesting to take a look at the result in a video: http://youtu.be/QLfI1McLMa0?hd=1 (skip to 1:08 to view 'Control Curve' window). In short, now I think there is no need to continue coding my own library since OnScreen GUI Toolkit is already exist  . I'll try to adapt 'Control Curve' control in it and post result here if you don't mind. Thanks for sharing your library 
-
kirill2008
- PluginStore Author

-
- Posts: 125
- Joined: Sun Aug 02, 2009 8:06 pm
- Location: Chelyabinsk, Russia
- Name: kirill2008
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Aerilius » Fri Sep 14, 2012 11:04 am
That looks cool! This toolkit is in early development and it's possible that there will be soon bigger changes in the architecture of the underlying code. Dialogs like yours don't exist yet at all, one would have to create a new Dialog class as subclass of Container and then create the dialog titlebar, close buttons etc. maybe border resizing...
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by Chris Fullmer » Sat Sep 15, 2012 2:09 am
Ok, I uploaded my code for the RGB color picker. I'm sure there is lots of optimization that could be done. And its just wrapped in a class. As this development kit keeps improving and adding, maybe the RGB picker could get incorporated into it as well. viewtopic.php?f=180&t=47808Chris
-

Chris Fullmer
- SketchUp Team

-
- Posts: 6929
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Boulder, CO
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by thomthom » Sat Sep 15, 2012 10:31 am
Cool! It'd be really nice to see a unified framework here. We're clearly re-inventing each others work. I have code that reads BMP files and let you draw it - but it's terrible slow.
-

thomthom
- PluginStore Author

-
- Posts: 19487
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by dacastror » Sat Feb 02, 2013 7:22 pm
with this would it be possible to create a dialog that allows the user to enter a number?
(google translator)
-
dacastror
-
- Posts: 138
- Joined: Mon Jun 14, 2010 12:25 am
- Name: Diego Castro
by Aerilius » Sun Feb 03, 2013 12:33 am
Possibly, but it would not be ideal. I also haven't yet got time to finalize this, but I might be able to finish it in future.
-
Aerilius
- PluginStore Author

-
- Posts: 1435
- Joined: Tue Dec 23, 2008 11:00 pm
- Location: Kaiserslautern
- Name: Aerilius
by driven » Sun Feb 03, 2013 12:59 am
Has everyone else seen this one? http://sketchucation.com/forums/viewtopic.php?f=323&t=41982&start=45#p406363it is in the other thread but thought it was easier to ask about if it's here... is it the same concept? john
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3034
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by dacastror » Sun Feb 03, 2013 5:38 pm
I would like to do this, to make a inputbox made with OpenGL, could you please show an example of how to do this?
-
dacastror
-
- Posts: 138
- Joined: Mon Jun 14, 2010 12:25 am
- Name: Diego Castro
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Developers' Forum
|