9876543210

9876543210

not really, and it would take up precious desktop space. 3D packages use panning (shift MMB) instead; it’s faster than using a horizontal and vertical scrollbar. Also, since a 3D space can be HUGE, it would be tough to know how to scale the bar.

9876543210

Yes there is most definetely a need for this. I have been stuck on this issue with large models in user view. The script could be done as a scriptlink, spacehandler for the script window so the option could be made avaliable to save in specific window for redraw later.
> like the hotspots script, that I have in Camera Viev only, I could have scrollbars draw in the scripts window only, set as default.
Also scrollbars are hard coded in many places already they should be coded into the scripts window by default, you should try to help with this.

The main uses I would see needed is to make this work for the scripts sub menus which are currently stuck on about 35 scripts with no scrolling.

I am currently testing , a script to acheive similar through middle mouse scrolling. The script is by Mariano and is a shell for script scrolling and tooltips.
I suggest you PM him to exchange ideas on this and so as to improve this function.

As an End User, I find there is a lack of uniformity to script sizing and a scroll function, even mmouse drag also would be a good soloution to scripts with a oversized ui.
I do have Blender set up so this is not an issue for me, it is however a welcome advance towards greater uniformity in scripting both for older scripts to be updated and for inclusion in the template for new scripts. :slight_smile:

Thanks M.A.

oh, yes. definately for menus. sorry. the UV menu was very long.The IPO list is long, even the view menu is long, as is the Image format menu (18 items). Luckily, the up/down reverse function works most of the time, altho I remeber the UV menu getting cut off.

In 2.42, the Node Editor window was fixed size, so a scrollbar would be useful there. Also, with ED and just complicated scenes in general, the outliner gets long.

9876543210

9876543210

spacehandlers would work for the 3d view but is not nessecary but still could be useful to have scroll bars.
I was more thinking to hard code the scroll bar into the 2d scripts window (the only one that does not have this function and to hard code the scrollbar into the script menus also so more scripts can be made available.
Also there is a lot of actual scripts that could benifit from having a scrollbar function to
save resizing windows to fit script ui that is way too big.
Could you please post some code or pm me as I would like to experiment with this.
Thanks M.A.

9876543210

9876543210

Scrollbar would be great, as a python class or included in draw module (actually, there is scrollbar in draw module but I can’t figure out how to make it work). But beside that I would like to see more controls, like treeviews, scrollboxes, checkboxes (ok, there is a toggle, but a nice check box would be… nice :slight_smile: :slight_smile: )

9876543210

9876543210

That hyperupload.com doesn’t work for me :frowning:

This is a bit of a side note:

What would be a pretty neat thing for Blender scripts is a BlenderGL toolkit that mimics blender’s UI in such behaviours as making panels, tabbing them (with all the buttons associated to them)… It could also extend the native UI with nexw widgets, through space handlers (adding toolbars). I did a try some years ago, unfortunately it turned out I didn’t know enough in designing such a system. Anyway, it’s definitely possible, your script is a stone on the way to that.

At term maybe could the whole UI be pythonized? Would that be good? Or just described through python (a generalisation of the Draw module, with some place for extensions) (or XML?)… aaah, I got lost in thinking ^^

have a nice day!

Dani

9876543210

I don’t know about the idea of using a module. Any kind of dependencies cause problems somewhere down the line. I personally prefer scrollable panels too and I’ve just finished implementing a simple scrollbar class and it’s so much better than having items spaced out everywhere. Like I say, my implementation is fairly basic just now with just middle mouse scrolling, drag scrolling and up and down arrows. It also has a way of doing expanding options - kind of like a tree view but not quite.

Currently, I didn’t put in the ability to scroll sideways, the scrollbar stays the same size (not sure if I’ll change that or not because I hate it when programs make the scrollbar too small to use and the limits mean any variation would be of little practical use) and it doesn’t do multiple columns because I don’t plan on using that. But it’s only a couple of hundreds lines of Python code so it’s not a huge problem for people to include in their own scripts. I think it would be better following that route.

I’m sure you figured this out already but in case you didn’t, if you use the sys.sleep command, it stops the script window updates using all your CPU when scrolling.

I’m really surprised at Blender’s lack of using scrollbars in both the general interface and the Python API - it used to have a scrollbar function that somehow got broken.

Well the file list and text editor have a scrollbar so I too am surprised that there is no way to created scrollable list widgets via Python. Perhaps some Blender developer will add that one day. You could even extend the drop down list to show as either drop down or scrollable list like the HTML “select” element. Sure would be handy.

9876543210

Thanks for your code MvGulik. You know, when you have annonounced that you are working on scrollbar, I have also planed to try to make some scroll bar for my script that I’m making and here is my code. I’m not trying to hijack your thread, just sharing my work :slight_smile: This is also just WIP, so there’s a lot of unused vars and it can be optimized… And there’s a bug when scrolbar button size is changed that I have to correct.


#################################
# Author: Damir Prebeg
# Licence: GPL
#################################

import Blender
from Blender import *

g_BtnPosY = 0
g_Top = 0
g_Left = 0
g_Bottom = 0
g_Right = 0

g_StartScrl = False
g_ScrlbarTop = 30 # Distance from script window top
g_ScrlbarBottom = 20 # Distance from script window bottom
g_ScrlbarLeft = 10
g_ScrlbarBtnWidth = 20
g_ScrlbarBtnHeight = 20
g_ScrlCorrection = 10
g_Scrlbar = Draw.Create(0)
    
        
def getWindowSpace():
    Buff = BGL.Buffer(BGL.GL_INT,4)
    BGL.glGetIntegerv(BGL.GL_SCISSOR_BOX,Buff)
    left = Buff[0]
    bottom = Buff[1]
    right = Buff[2]
    top = Buff[3]
    return left,bottom,right,top

def draw():
    global g_Scrlbar, g_BtnPosY, g_StartScrl, g_Top, g_Left, g_Bottom,g_Right, g_ScrlbarTop, g_ScrlbarLeft, g_ScrlbarBtnWidth

    g_Left,g_Bottom,g_Right,g_Top = getWindowSpace()
    
    ScrlbarY = g_BtnPosY+g_Top-g_ScrlbarTop

    BGL.glClearColor(0.600000,0.600000,0.600000,1)
    BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
        
    Draw_Scrollbarr(g_ScrlbarLeft,g_Top-g_ScrlbarTop+g_ScrlbarBtnHeight,g_ScrlbarLeft+g_ScrlbarBtnWidth,10,color=(0.5,0.5,0.5))
    
    g_Scrlbar=Draw.Toggle('<>',1,g_ScrlbarLeft,ScrlbarY, g_ScrlbarBtnWidth, g_ScrlbarBtnHeight,g_Scrlbar.val,'Scrl')
    
    Draw.PushButton('Quit',2,34,g_Top-g_ScrlbarBtnHeight-ScrlbarY,50,20,'Exit script')
    
    BGL.glColor3f(0,0,0) 
    BGL.glRasterPos2d(90,g_Top-g_ScrlbarBtnHeight-ScrlbarY+5) 
    Draw.Text("--> "+str(g_Top-g_ScrlbarTop-ScrlbarY),"normal") 


def Draw_Scrollbarr(left,top,right,bottom,color=(0.5,0.5,0.5)):
    BGL.glColor3f(*color) 
    BGL.glRecti(left,top,right,bottom) 

def event(evt,val):    
    
    events = [Draw.WHEELUPMOUSE, Draw.WHEELDOWNMOUSE, Draw.LEFTMOUSE, Draw.MOUSEY]
    
    if evt == Draw.ESCKEY and not val:
        Draw.Exit()
    elif evt in events:
        do_scrl(evt, val)
        
def do_scrl(evt, val):
    global g_StartScrl, g_Top, g_Bottom, g_BtnPosY, g_ScrlbarTop, g_ScrlbarBottom, g_ScrlCorrection
        
    if evt == Draw.WHEELUPMOUSE:
        if g_BtnPosY + 10 < 0:
            g_BtnPosY = g_BtnPosY + 10
        else:
            g_BtnPosY = 0
    elif evt == Draw.WHEELDOWNMOUSE:
        if g_BtnPosY - 10 > -(g_Top - g_ScrlbarTop - g_ScrlCorrection):
            g_BtnPosY = g_BtnPosY - 10
        else:
            g_BtnPosY = -(g_Top - g_ScrlbarTop - g_ScrlCorrection)
    elif evt == Draw.LEFTMOUSE:
        if g_StartScrl:
            g_StartScrl = False
            g_Scrlbar.val = 0
    elif evt == Draw.MOUSEY:
        if g_StartScrl:
            newY = -(g_Top - g_ScrlbarTop - val+g_ScrlCorrection + g_Bottom)
            ScrlOK = (g_Top-g_ScrlbarTop+newY < g_Top-g_ScrlbarTop) and (val > g_Bottom + g_ScrlbarBottom)
            if ScrlOK:
                g_BtnPosY = -(g_Top - g_ScrlbarTop - val+g_ScrlCorrection + g_Bottom)
            if g_Top-g_ScrlbarTop+newY > g_Top-g_ScrlbarTop:
                g_BtnPosY = 0
            if val < g_Bottom+g_ScrlbarBottom:
                g_BtnPosY = -g_Bottom-(g_Top-g_ScrlbarTop-g_ScrlbarBottom+g_ScrlCorrection-g_Bottom)
    Draw.Redraw()


def bevent(evt):
    global g_StartScrl
    
    if evt == 1:
        g_StartScrl = not g_StartScrl
    elif evt == 2:
        Draw.Exit()

Draw.Register(draw,event,bevent)