# Compact Brush Toggler

**URL:** <https://krita-artists.org/t/compact-brush-toggler/33798>\
**Category:** Plugins and Scripts\
**Created:** [December 25, 2021, 12:39pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798 "2021-12-25T12:39:51Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [May 12, 2022, 2:58am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/21 "2022-05-12T02:58:58Z")

</div>

That’s good to hear.

do note that there is still a bug about resetting presets of the brush that at this point only extending libkis i think is the solution and i cant do it in python. [I have started with it] so if you use popup pallete a lot it get troublesome. 😅

OTH i can’t live without this plugin anymore. So im willing to improve it / just need to get time to do it.

---

<div class="post-metadata">

**Author:** ![804708803](https://krita-artists.org/letter_avatar_proxy/v4/letter/8/3bc359/32.png) [@804708803](https://krita-artists.org/u/804708803)\
**Post date:** [July 29, 2022, 2:18am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/22 "2022-07-29T02:18:28Z")

</div>

![QQ截图20220729101222](https://krita-artists.org/uploads/default/original/3X/6/6/665e0788f05edcc7fb6eea14cd6ac87be735abca.png)  
Could you set shortcut keys for the rotation of your brush? like the new photoshop.

---

<div class="post-metadata">

**Author:** ![tachiko](https://krita-artists.org/user_avatar/krita-artists.org/tachiko/32/30199_2.png) [@tachiko](https://krita-artists.org/u/tachiko)\
**Post date:** [January 3, 2023, 12:01am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/23 "2023-01-03T00:01:58Z")

</div>

Can you add toggle soak ink using the brush engine brushes, and toggle paint mode perhaps.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 3, 2023, 2:19am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/24 "2023-01-03T02:19:46Z")

</div>

I’ll look into it.  
I think the next customization step is allowing for adding removing toggles. There are some other toggles im thinking of adding.

---

<div class="post-metadata">

**Author:** ![LunarKreatures](https://krita-artists.org/user_avatar/krita-artists.org/lunarkreatures/32/231342_2.png) [@LunarKreatures](https://krita-artists.org/u/LunarKreatures)\
**Post date:** [January 3, 2023, 4:46am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/25 "2023-01-03T04:46:20Z")

</div>

Using the nightly for 5.2 of the 31 of December krita had an error with the plugin enabled, may be worth checking out. Haven’t tested any newer nightly yet. If i remember correctly it was an error when calling findchild

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 3, 2023, 4:47am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/26 "2023-01-03T04:47:28Z")

</div>

Thank you for the heads up - will do .

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 3, 2023, 4:51pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/27 "2023-01-03T16:51:21Z")

</div>

So far:  
soak ink - [done]  
paint mode - inconsistent , it uses QRadioButton so still need to know whats going on there.

5.2 Dec31 issue - have not check yet.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 4, 2023, 1:04am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/28 "2023-01-04T01:04:29Z")

</div>

[![](https://krita-artists.org/uploads/default/original/3X/6/3/634bd6dcb149123c32ac146bb4eaa2197b74e42b.jpeg "Compact Brush Toggler New Toggles , Paint Mode and Soak Ink") ](https://www.youtube.com/watch?v=QMBxtUYMCm4)

Needed some sleep to figure out the Paint mode.  
I’ll push this update today and edit this post ,  
but i might push another update later this week - not for functionality but to change the icon to custom ones.

I feel they don’t represent how they work right now.

![image](https://krita-artists.org/uploads/default/original/3X/8/3/83325be77176df6431d01c5083f6ca27ac6c526d.png) ![image](https://krita-artists.org/uploads/default/original/3X/a/d/ade46a0a693d069e2e303b56fb11b4d52f144328.png)

For now, I use show coloring icon.  
For Soak Ink, Off → no soak ink, On → Soak Ink  
For Paint Mode, Off → Build up, On → Wash

> [@804708803](#):
>
> Could you set shortcut keys for the rotation of your brush? like the new photoshop.

I wish im capable of adding that, I still have not figure out the rotating widget.

[EDIT] : The git repository have been updated with Soak and Paint Mode. Color Rate is a bit… it work on my linux mint. My internet is going haywire so. Also have not tested on 5.1.4 nightly of dec 31 to latest. will do after work.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 4, 2023, 3:32am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/29 "2023-01-04T03:32:46Z")

</div>

Hello I have check it :  
and it seems the issue is that the pop up frame object name has been change from “popup frame” to “KisPopupButtonFrame”. Post Dec 31 nightly.

This branch has the fix version for 5.2: [i cant put in my main for now till 5.2 but will update it in split]

> **[GitHub - kaichi1342/CompactBrushToggler at v.0.1.3a1](https://github.com/kaichi1342/CompactBrushToggler/tree/v.0.1.3a1)**
>
> v.0.1.3a1

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 1:54pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/30 "2023-01-07T13:54:24Z")

</div>

🫣

Rotation spiny thing…

[![](https://krita-artists.org/uploads/default/original/3X/6/4/64f809e3f5dfa7c6cd20845d2e7da616853bb58e.jpeg "CBT Rotation") ](https://www.youtube.com/watch?v=Z9uMXSFN0KM)

would be really nice to be able to make this native… 🥲

---

<div class="post-metadata">

**Author:** ![Michelist](https://krita-artists.org/user_avatar/krita-artists.org/michelist/32/65826_2.png) [@Michelist](https://krita-artists.org/u/Michelist)\
**Post date:** [January 7, 2023, 1:56pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/31 "2023-01-07T13:56:58Z")

</div>

You are magnificent!

Michelist

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 1:58pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/32 "2023-01-07T13:58:33Z")

</div>

It’s causing lag on the first selection of brush… so i don’t think its good to add it on the UI.  
I’ll look into actions and just tying it to a shortcut.

Its visible around 0:14. and I confirmed that its due to the plugin.

[my machine is pretty good spec - w/ plenty of ram so its happen here it probably be worse on other machine]

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 4:18pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/33 "2023-01-07T16:18:42Z")

</div>

After testing the performance lag at the brush switch doesnt seem to be much related to the plugin.

though after testing a bit more … i stand that its still much better as shortcut bound than being in the docker. The workflow is not intuitive.

I have not tried making an extension - but if anyone want to this is how i track it in the brush editor.

```auto

    #----------------------------------------------------#
    # For Traversing nodes to get to Brush Editor Docker #
    # #
    #----------------------------------------------------#
    
    def walk_widgets(self,start):
        stack = [(start, 0)]
        while stack:
            cursor, depth = stack.pop(-1)
            yield cursor, depth
            stack.extend((c, depth + 1) for c in reversed(cursor.children()))

    def get_brush_editor(self):
        for window in QApplication.topLevelWidgets():
            if isinstance(window, QFrame) and window.objectName() == 'popup frame':
                for widget, _ in self.walk_widgets(window):
                    real_cls_name = widget.metaObject().className()
                    obj_name = widget.objectName()
                    if real_cls_name == 'KisPaintOpPresetsEditor' and obj_name == 'KisPaintOpPresetsEditor':
                        return widget

 
    #----------------------------------------------------#
    # Get the corresponding container of the #
    # brush property selected on the list view #
    #----------------------------------------------------#
    def selectBrushContainer(self,br_property):
        editor = self.get_brush_editor()
        option_widget_container = editor.findChild(QWidget, 'frmOptionWidgetContainer')
        current_view = None
        selectedRow = None 
        for view in option_widget_container.findChildren(QListView):
            if view.metaObject().className() == 'KisCategorizedListView':
                if view.isVisibleTo(option_widget_container):
                    current_view = view
                    break
                
        if current_view:
            current_settings_widget = current_view.parent()
            s_model = current_view.selectionModel()
            model = current_view.model()
            target_index = None
            for row in range(model.rowCount()):
                index = model.index(row,0)   
                if index.data() == br_property: 
                    target_index = index
                    selectedRow = row
                    break
                    
            if target_index is not None: 
                s_model.clear()
                s_model.select(target_index, QItemSelectionModel.SelectCurrent)
                s_model.setCurrentIndex(target_index, QItemSelectionModel.SelectCurrent)
                current_view.setCurrentIndex(target_index)
                current_view.activated.emit(target_index)
                
        
        container_info = dict()
        container_info["model_index"] = target_index
        container_info["current_view"] = current_view
        container_info["row_count"] = selectedRow
        container_info["option_widget_container"] = option_widget_container
        container_info["current_settings_widget"] = current_settings_widget

        return container_info  

    /* Call This to rotate the brush angle */
    def set_brushRotValue(self, rotationValue):  
        container_info = self.selectBrushContainer("Brush Tip")
        current_view = container_info["current_view"] 
        option_widget_container = container_info["option_widget_container"] 
        current_settings_widget = container_info["current_settings_widget"]  
        
        if current_view:
            for spin_box in current_settings_widget.findChildren(QDoubleSpinBox): 
                if spin_box.isVisibleTo(option_widget_container) and spin_box.metaObject().className() == 'KisAngleSelectorSpinBox' :   
                    spin_box.setValue(rotationValue) 
                    break

```

This will account for both the One in the predefined brush tip and the standard brushtip.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 5:31pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/34 "2023-01-07T17:31:44Z")

</div>

I tired making extension because this thing is haunting me… Its almost there.  
I needed to execute toggleOutline off/on [so that the outline update] if i didnt do that you need to move the cursor for it to update. Im pressing F10 F11,  
A couple of times i got confuse and pressed [].  
It rotates at 5 deg increment

On different note - it got attack by the reset to default size thing when you are changing too fast.

Much better off to code this as native. 🥲 If only i could.

[https://drive.google.com/file/d/1AynWy7rAjpkyoNj48lRe\_OlneXW8UVVw](https://drive.google.com/file/d/1AynWy7rAjpkyoNj48lRe_OlneXW8UVVw)

this ends my rotation adventure.

---

<div class="post-metadata">

**Author:** ![EyeOdin](https://krita-artists.org/user_avatar/krita-artists.org/eyeodin/32/2662_2.png) [@EyeOdin](https://krita-artists.org/u/EyeOdin)\
**Post date:** [January 7, 2023, 6:06pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/35 "2023-01-07T18:06:16Z")

</div>

In case your curious about dockers and extensions, my plugins are both at the same time I managed to connect them successfully.

So can use the extension and then update the docker from there.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 9:57pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/36 "2023-01-07T21:57:33Z")

</div>

I’m studying yours and @Grum999 yesterday as I use both of them. Its a big help , thank you.

As for this, Krita has a behavior of resetting brushsize when an action is trigerred. I feel it will be an issue. I mitigated most of it with exemption - it still hapen on rapid press.

---

<div class="post-metadata">

**Author:** ![EyeOdin](https://krita-artists.org/user_avatar/krita-artists.org/eyeodin/32/2662_2.png) [@EyeOdin](https://krita-artists.org/u/EyeOdin)\
**Post date:** [January 7, 2023, 10:02pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/37 "2023-01-07T22:02:03Z")

</div>

I did something for brush size with Tela. I honestly forget everything to say anything but I don’t remember brush size being awkward but this plugin is something I never do so I am not sure.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 7, 2023, 11:43pm UTC](https://krita-artists.org/t/compact-brush-toggler/33798/38 "2023-01-07T23:43:24Z")

</div>

Its nature of this plugin - since it just modify the value in the UI.  
When it modify something in the brush editor by walking down all elements there till find the target and change the value of the target. the brush size somehow resets.

I’ll take this chance to ask, how do one determine if the shortcut press is long or short?

Also… do you incorporate custom Icon Sets?

thank you ^-^

---

<div class="post-metadata">

**Author:** ![EyeOdin](https://krita-artists.org/user_avatar/krita-artists.org/eyeodin/32/2662_2.png) [@EyeOdin](https://krita-artists.org/u/EyeOdin)\
**Post date:** [January 8, 2023, 12:15am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/39 "2023-01-08T00:15:12Z")

</div>

as a docker it is kinda impossible if the mouse is not over the docker and still it will not read always. I made the extension to have my own shortcuts but then I had to compete for the same keys. But there si a thing called like Key or Keyboard Event or something and you can listen to the event of a key but for an actual action being triggered I don’t know.

with my new plugin is were I will try to listen to some stuff but it is like document creation, save and the like.

to determine if it is long or short I guess you have to make a QTimer that is single shot and make a threshold limit to consider one or another. I did a Feature request a while back to help with it but no one was interested in it nor can I find it now. lol

As for the Icon set in the past I had custom sets but I started to think about making it as compatible with Krita’s theme as possible.But in the past I would make a SVG in Inkscape, extract it’s code of the save into my docker python script as a function and then I would use it to trigger a QIcon object inside the button or where ever. and because I was all inside the script I was able to change the color of single elements on the icon by reloading it again but with a different hex code for the object.

---

<div class="post-metadata">

**Author:** ![kaichi1342](https://krita-artists.org/user_avatar/krita-artists.org/kaichi1342/32/8174_2.png) [@kaichi1342](https://krita-artists.org/u/kaichi1342)\
**Post date:** [January 8, 2023, 12:20am UTC](https://krita-artists.org/t/compact-brush-toggler/33798/40 "2023-01-08T00:20:24Z")

</div>

I think i accidentaly found solution to my brushSize issue.

as for icons, i guess i need to ask Krita team. After my goal is when i learned enough to eventually extend krita api and make this native. I forgot that theme compatibility is important for a moment there

Thank you for answering my questions ^-^

[Previous page](https://krita-artists.org/t/compact-brush-toggler/33798.md?page=1)

[Next page](https://krita-artists.org/t/compact-brush-toggler/33798.md?page=3)
