Skip to content

Commit

Permalink
v1.6 (#81)
Browse files Browse the repository at this point in the history
## Templates
#### Make HDA by Template
- New *Inherit parameters* option
- Pick node color and shape
- Pick icon from disk
- Preview for current icon
- Fixed #66 

## Show User Data
- New *Pin to node* mode
- New *Word-Wrap* mode
- Zooming with `Ctrl+Wheel` and `Ctrl+Plus/Minus`
- Display node shape for *nodeshape* key
- Fixed #70

#### Prettify
- Redesigned and generalized
- Support for XML
- Support for INI-like
- Support for comma-separated sequence

## Find Icon
- Default icon size increased from 64x64 to 90x90
- Change icon size with slider in real-time
- Slight UI acceleration
  • Loading branch information
Ivan Titov authored Mar 23, 2021
1 parent addec56 commit d7bac8b
Show file tree
Hide file tree
Showing 18 changed files with 1,682 additions and 415 deletions.
8 changes: 4 additions & 4 deletions OPmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tdk.showGenerateCode(**kwargs)
import houdini_tdk
reload(houdini_tdk)

houdini_tdk.showNodeUserData(cached=kwargs['shiftclick'], **kwargs)
houdini_tdk.showNodeUserData(**kwargs)
</scriptCode>
</scriptItem>

Expand All @@ -53,7 +53,7 @@ houdini_tdk.showNodeUserData(cached=kwargs['shiftclick'], **kwargs)
<context>
<expression>
node = kwargs['node']
return node.type().name().startswith('tdk::template')
return node.type().definition() is not None
</expression>
</context>
<scriptCode>
Expand All @@ -72,11 +72,11 @@ tdk.showMakeHDAByTemplateDialog(**kwargs)
</expression>
</context>
<scriptCode>
from houdini_tdk.utils import openFileLocation
import houdini_tdk as tdk

node = kwargs['node']
path = node.type().definition().libraryFilePath()
openFileLocation(path)
tdk.openFileLocation(path)
</scriptCode>
</scriptItem>

Expand Down
10 changes: 6 additions & 4 deletions python2.7libs/houdini_tdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

from .find_icon import FindIconDialog, findIcon
from .new_hda_version import NewVersionDialog, showNewVersionDialog
from .show_node_user_data import UserDataWindow, showNodeUserData
from .make_hda_by_template import MakeHDAByTemplateDialog, showMakeHDAByTemplateDialog
from .icon_list import IconListDialog, findIcon
from .node_shape_list_dialog import NodeShapeListDialog, findNodeShape
from .generate_code import showGenerateCode
from .hda_doctor import HDADoctorWindow
from .make_hda_by_template import MakeHDAByTemplateDialog, showMakeHDAByTemplateDialog
from .new_hda_version import NewVersionDialog, showNewVersionDialog
from .show_user_data import UserDataWindow, showNodeUserData
from .utils import openFileLocation
22 changes: 8 additions & 14 deletions python2.7libs/houdini_tdk/filter_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Tool Development Kit for SideFX Houdini
Copyright (C) 2020 Ivan Titov
Copyright (C) 2021 Ivan Titov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -27,27 +27,21 @@
from PySide2.QtGui import *
from PySide2.QtCore import *

from .input_field import InputField

class FilterField(QLineEdit):

class FilterField(InputField):
# Signals
accepted = Signal()
accepted = Signal(str)

def __init__(self):
super(FilterField, self).__init__()

self.setPlaceholderText('Type to Filter...')

def keyPressEvent(self, event):
key = event.key()
if key == Qt.Key_Escape:
self.clear()
elif key == Qt.Key_Enter or key == Qt.Key_Return:
self.accepted.emit()

if key == Qt.Key_Enter or key == Qt.Key_Return:
self.accepted.emit(self.text())
else:
super(FilterField, self).keyPressEvent(event)

def mousePressEvent(self, event):
if event.button() == Qt.MiddleButton and \
event.modifiers() == Qt.ControlModifier:
self.clear()
super(FilterField, self).mousePressEvent(event)
101 changes: 101 additions & 0 deletions python2.7libs/houdini_tdk/fuzzy_filter_proxy_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""
Tool Development Kit for SideFX Houdini
Copyright (C) 2021 Ivan Titov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

from __future__ import print_function

try:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

Signal = pyqtSignal
except ImportError:
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *


def fuzzyMatch(pattern, text):
if pattern == text:
return True, 999999

try:
pattern_start = text.index(pattern)
pattern_length = len(pattern)
return True, pattern_length * pattern_length + (1 - pattern_start / 500.0)
except ValueError:
pass

weight = 0
count = 0
index = 0
for char in text:
try:
if char == pattern[index]:
count += 1
index += 1
elif count != 0:
weight += count * count
count = 0
except IndexError:
pass

weight += count * count
if index < len(pattern):
return False, weight

return True, weight + (1 - text.index(pattern[0]) / 500.0)


class FuzzyFilterProxyModel(QSortFilterProxyModel):
def __init__(self, parent=None, accept_text_role=Qt.UserRole, comp_text_role=Qt.DisplayRole):
super(FuzzyFilterProxyModel, self).__init__(parent)

self._accept_text_role = accept_text_role
self.comp_text_role = comp_text_role

self.setDynamicSortFilter(True)
self.setFilterCaseSensitivity(Qt.CaseInsensitive)
self.sort(0, Qt.DescendingOrder)

self._pattern = ''

def setFilterPattern(self, pattern):
self._pattern = pattern.lower()
self.invalidate()

def filterAcceptsRow(self, source_row, source_parent):
if not self._pattern:
return True

source_model = self.sourceModel()
text = source_model.data(source_model.index(source_row, 0, source_parent), self._accept_text_role)
matches, _ = fuzzyMatch(self._pattern, text.lower())
return matches

def lessThan(self, source_left, source_right):
if not self._pattern:
return source_left.row() < source_right.row()

text1 = source_left.data(self.comp_text_role)
_, weight1 = fuzzyMatch(self._pattern, text1.lower())

text2 = source_right.data(self.comp_text_role)
_, weight2 = fuzzyMatch(self._pattern, text2.lower())

return weight1 < weight2
2 changes: 0 additions & 2 deletions python2.7libs/houdini_tdk/generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import os
import tempfile

import os

try:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
Expand Down
Loading

0 comments on commit d7bac8b

Please sign in to comment.