nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.25k stars 233 forks source link

Submenus Branch (space bar menu) #448

Closed zeffii closed 10 years ago

zeffii commented 10 years ago

makes sense when moniker 'modifier' doesn't. Transforms are very specific operations, whereas modifier can be a whole range of different operations.

Maybe

nortikin commented 10 years ago

sad we cannot make subcategory

nortikin commented 10 years ago

not sure we need this.

zeffii commented 10 years ago

None of these are modifiers, they are dedicated Transform operations

nortikin commented 10 years ago

did you realy did it? wow! cool if in 3D this duplicated... maybe insert to panel creation of triple nodes? when created, it searches for layout sverchok tree and inserts node generator and node viewer and node object in and in 3d empty, so with empty you manage matrix... how idea?

zeffii commented 10 years ago

try the branch, it already checks those things

zeffii commented 10 years ago

could certainly add extra ops to add real objects to scene. but not yet

zeffii commented 10 years ago

https://gist.github.com/anonymous/cb9af0fa0b5f8ec04c99

ly29 commented 10 years ago

Nice

AgustinJB commented 10 years ago

Really nice!

I also think some menu restructuration should be done. Transforms make sense to me.

zeffii commented 10 years ago

the amount of code involved is depressing..but I just wanted to see how it looks..

zeffii commented 10 years ago

doooozle

zeffii commented 10 years ago

add n grab now working

zeffii commented 10 years ago

Yes Nortikin! I think finally I slowed down enough to understand what you meant earlier. I think this code provides an easy way to extend menus and even offer custom "node ensembles", (we add one node from a specials list and automatically can get common nodes added simultaneously)

case: adding Image Decomposer, i would probably always want

Not only limited to Nodes, but also (as you say) adding objects to 3d view too. Objects which always get used in conjunction with certain nodes. Could reuse the IO code here to add ensembles from a json folder

zeffii commented 10 years ago

both menu.py and nodeview_space_menu.py could read from the same nodes dict, but they would need to be equivalent. (this would reduce duplication)

for example

class NODEVIEW_MT_AddConditionals(bpy.types.Menu):
    bl_label = "Conditionals"

    def draw(self, context):
        layout = self.layout
        node_details = [
            # bl_idname, shortname, <icon> (optional)
            ['SvLogicNode', 'Logic'],
            ['SvSwitchNode', 'Switch'],
            ['SvNeuroElman1LNode', 'Neuro'],
        ]
        layout_draw_categories(layout, node_details)

if this list is declared in menu.py as

    node_cats["Conditionals"] = [
            ['SvLogicNode', 'Logic'],
            ['SvSwitchNode', 'Switch'],
            ['SvNeuroElman1LNode', 'Neuro'],
    ]

then


# have node_cats available

class NODEVIEW_MT_AddConditionals(bpy.types.Menu):
    bl_label = "Conditionals"

    def draw(self, context):
        layout_draw_categories(self.layout, node_cats[self.bl_label))

and slightly modify the for category, nodes in node_cats.items(): from menu.py to ignore 3rd sublist items (icons)

zeffii commented 10 years ago

this way we could continue to edit the menu easily from menu.py, and nodeview_space_menu.py automatically adjusts to changes

nortikin commented 10 years ago

it cannot import sverchok.menu is it works for you, @zeffii ?

nortikin commented 10 years ago

it rise needs to make own icons and bgl image menu implementation. not nice to choose standard icons here.

zeffii commented 10 years ago

yes works here, what is your sverchok folder called?

ly29 commented 10 years ago

@zeffii Since we have added the sverchok folder to the python import path you can just import menu. I have some doubts how safe it is with such generic names as menu etc...

ly29 commented 10 years ago

Also it strikes me that perhaps we should split utils into sverchok-ui and utils since it has a growing number of files, some utils, some panels etc.

zeffii commented 10 years ago

agreed.. about utils / vs ui

I thought I tried importing menu first..? seems not. yes this works nicer

zeffii commented 10 years ago

menu = imported_modules[-1] it was already silently conflicting with this

zeffii commented 10 years ago

I don't think bgl is ready for drawing nice icons, even loading them as raster seems like a lot of extra work. Using blf loading icon font files at least offloads some work, downside is monochrome.

A lot of extra work designing the right icons, which I would be happy to do if the tools to display them were appropriate.

ly29 commented 10 years ago

This menu solves most of the problems I had with the old menu and feels quite nice. However for the old shift-A and especially T-panel fewer categories works better. This of course is a general problem with blender tabs...

zeffii commented 10 years ago

Yeah I would love to solve that but the solution (i haven't tried yet) seems quite hacky

zeffii commented 10 years ago

OK, there is no nice way to insert a menu item in the NODE_MT header, ( I don't have time to mess with it)

zeffii commented 10 years ago

An alternative is to reimplement the nodeitems_utils.py specifically for sverchok. I'll experiment with it

zeffii commented 10 years ago

bleh..that gets messy too

zeffii commented 10 years ago

This concludes my experiment, I thinks it's pretty cool even tho not all icons are great - at least this allows submenus without too much vagueness.

It is also possible that, unfortunately, these will be my last commits for the foreseeable future.

ly29 commented 10 years ago

Thanks for the effort! For me this makes more sense as a shift-A replacement than space bar. Right now it has the side effect of killing the space menu in other node editors, I will try to tinker a bit with it.

zeffii commented 10 years ago

it might not be possible to selectively override keyboard combos for specific node trees, I think it is forced on the level of the View (ie NodeView ). There is a poll the the Menu to not draw if the tree is not Sverchok tho...

nortikin commented 10 years ago

better to remove icons completely. If you making menu to be clear, not as disoder. We cannot find al icon types now. Overall this idea super

nortikin commented 10 years ago

poll decorator kill space menu completely.

ly29 commented 10 years ago

the easiest things is probably just to bind it to another key than space. problem then is finding it the first time...

zeffii commented 10 years ago

yes, that's not good.. this is very lame :)

zeffii commented 10 years ago

a custom version of nodeitems_utils.py is possible. At the moment some of the code I wrote for the menus and the "dynamically created classes" is very similar to nodeitems_utils.

# from dynamic menu

# does not get registered
class NodeViewMenuTemplate(bpy.types.Menu):
    bl_label = ""

    def draw(self, context):
        layout_draw_categories(self.layout, node_cats[self.bl_label])

# quick class factory.
def make_class(name, node_list):
    name = 'NODEVIEW_MT_Add' + name
    return type(name, (NodeViewMenuTemplate,), {'bl_label': node_list})

from nodeitems_utils

    for cat in cat_list:
        menu_type = type("NODE_MT_category_" + cat.identifier, (bpy.types.Menu,), {
            "bl_space_type": 'NODE_EDITOR',
            "bl_label": cat.name,
            "category": cat,
            "poll": cat.poll,
            "draw": draw_node_item,
            })
zeffii commented 10 years ago

Ctrl+Space then :)

zeffii commented 10 years ago

I have grown to like the icons.. maybe we ask people what they think...and remove if the majority says its crap

zeffii commented 10 years ago

I think in conclusion of this experiment I can say a few things.

1 - The current Pynode Custom tree (in particular nodeitem_utils) is not designed with the idea that there might be a wide variety of nodes (not just node count,, but node catagorization..and subtle subcats)

2 - nodeitem_utils can be overridden, but that was not the goal initially of this experiment

3 - If we are going to use icons, lack of convenient custom icons is a big shame.

nortikin commented 10 years ago

it is crap

zeffii commented 10 years ago

:octocat: my prediction is that bgl driven icons will look equally (if not worse) crappier.

zeffii commented 10 years ago

can implement that they are off by default, is a reasonable compromise

nortikin commented 10 years ago

it is what needed. we will draw icons from zero-point. there will be small icons in future, styled as cricket do. But not now

zeffii commented 10 years ago

i don't disagree. Fresh icons would be best

zeffii commented 10 years ago

tamed default menu, icons are now optional

nortikin commented 10 years ago

))

zeffii commented 10 years ago

should I do a pullrequest?

ly29 commented 10 years ago

Yes, go for it. An then I will sync with SN2 then push that to beta.

zeffii commented 10 years ago

re-open if problems

zohozer commented 7 years ago

@zeffi. How did you get this icons in the menus? Personally I don't have them and don't know how to activate them.

icons