Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it work with Blender 4.0 #35

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ With this Blender addon you can display mouse and keyboard input

### Installation Instructions

- Download the **shortcut_VUr-master.zip** file from Jayanam's Github https://github.com/jayanam/shortcut_VUr (Press green button top right corner).
- In Blender 2.8 go to **Edit** > **Add-ons** and on the right side of that window click on **Install** button.
- Download the **shortcut_VUr-master.zip** file from Github (press green button on top right corner).
- In Blender go to **Edit** > **Add-ons** and on the right side of that window click on **Install** button.
- In pop-up window navigate to where you downloaded the **shortcut_VUr-master.zip** file, select it and click **Install Add-on from File...** button on top right corner.
- Back in the **Add-ons** preferences window search for **Object: Shortcut VUr** check the checkbox next to it and click **Save Preferences** button if you want to be able to see it on any new Blender projects you open.
- Back in the **Add-ons** preferences window search for **Object: Shortcut VUr** check the checkbox next to it and click **Save Preferences** button if you want to be able to see it on any new Blender projects you open.
- Back in your **3D Viewport** (Shift + F5), On the right side of the 3D Viewport you will see a vertical tab called **Shortcut VUr**, click on it and then press **Start Shortcut VUr** button to start seeing the mouse clicks and the keys you press on your keyboard on the lower left side of your screen.


Expand Down
8 changes: 6 additions & 2 deletions scv_draw_util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import bpy
import gpu

from gpu_extras.batch import batch_for_shader
Expand Down Expand Up @@ -41,7 +42,10 @@ def create_batches(self, context, mouse_input):
self.vertices_left = ((self.x_off, 20 + self.y_off), (self.x_off, 50 + self.y_off), (self.x_off + 20, 50 + self.y_off), (self.x_off + 20, 20 + self.y_off))
self.vertices_right = ((self.x_off + 50, 20 + self.y_off), (self.x_off + 50, 50 + self.y_off), (self.x_off + 70, 50 + self.y_off), (self.x_off + 70, 20 + self.y_off))
self.vertices_middle = ((self.x_off + 30, 30 + self.y_off), (self.x_off + 30, 50 + self.y_off), (self.x_off + 40, 50 + self.y_off), (self.x_off + 40, 30 + self.y_off))
self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
if bpy.app.version < (4, 0, 0):
self.shader = gpu.shader.from_builtin("2D_UNIFORM_COLOR")
else:
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")

self.batch_left_button = batch_for_shader(self.shader, 'TRIS', {"pos" : self.vertices_left}, indices = self.indices)
self.batch_right_button = batch_for_shader(self.shader, 'TRIS', {"pos" : self.vertices_right}, indices = self.indices)
Expand All @@ -67,4 +71,4 @@ def draw_buttons(self, left, middle, right):
self.batch_middle_button.draw(self.shader)

self.__set_color(right)
self.batch_right_button.draw(self.shader)
self.batch_right_button.draw(self.shader)
7 changes: 5 additions & 2 deletions scv_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

def create_font(id, size, color):
blf.color(id, color.r, color.g, color.b, 1.0 )
blf.size(id, size, 72)
if bpy.app.version < (4, 0, 0):
blf.size(id, size, 72)
else:
blf.size(id, size)

def draw_text(text, x, y, font_id):
blf.position(font_id, x, y , 0)
Expand Down Expand Up @@ -117,7 +120,7 @@ def detect_mouse(self, event):
def cancel(self, context):
if context.window_manager.SCV_started:
self.unregister_handlers(context)
return {'CANCELLED'}
return None

def finish(self):
self.unregister_handlers(context)
Expand Down