Changing the theme does not update Canvas widgets when the tool window is not displayed

Hello,
Is this a bug or do I have to update each canvas manually when the dialog is refreshed?
It also seems to me that the Text widget color does not update automatically when
the theme changes and the dialog is visible.
I wanted to take advantage of the fact that I can work with themes and
do not want to use custom colors.
The background is one canvas and the other widgets are also canvases but my class is “RotaryWidget”.

I also tried using renoise.app().theme_observable and updating all Canvas widgets automatically when the window is redisplayed, but it doesn’t work :frowning:

this is my widget gui:

function RotaryWidget:create_gui()
    local gui = self.vb:stack{
        size={self.size, self.size + 20},
        background="invisible",
        views={
            self.vb:canvas{
                id="main_canvas",
                size={self.size, self.size},
                mouse_events={"drag", "down", "up"},
                mouse_handler=function(event) self:mouse_handler(event) end,
                render=function(ctx) self:render(ctx) end,
            },
            self.vb:text{
                id="textval",
                width=self.size,
                origin={0, math.floor(self.size * 0.5) - 10},
                text=tostring(self.value),
                color= "main_font",
                align="center",
                font="bold",
                style="strong",
            },
            self.vb:text{
                id="label",
                width=self.size,
                origin={0, self.size},
                text=self.idx,
                color="main_font",
                align="center",
                font="bold",
                style="normal",
            },
        },
    }
    return gui
end

Are you pre-creating the GUI views while the tool is initialized, and not when showing the dialog? That would explain the missing update.

But yes, it would be nice if Renoise internally automatically updates colors set via strings. It currently only fetches the actual values and sets them as color values.

If you use theme colors in the canvas, you need to listen to renoise.app().theme_observable and update the canvas accordingly. We could magically track that, but I don’t think that’s really necessary as theme changes usually don’t happen that often. It’s simply not worth all the needed extra work.

I create all widgets during initialization.
Since there is not much, I got around it like this:

function app_idle()
  if not dialog.visible then
    Notifiers:remove(rnt.app_idle_observable, app_idle)
    Notifiers:remove(renoise.app().theme_observable, theme_changed)
  end
end

function theme_changed()
    vbs.background:update()
    for _, widget in pairs(Widgets) do
        widget.fill_color = renoise.app().theme:color("selected_button_back")
        widget.stroke_color = renoise.app().theme:color("selected_button_back")
        widget.vbs.label.color = renoise.app().theme:color("main_font")
        widget.vbs.textval.color = renoise.app().theme:color("main_font")
        widget.vbs.main_canvas:update()
    end
    Button.vbs.label.color = renoise.app().theme:color("main_font")
    Button.vbs.canvas:update()
end

function prepare_for_start()

  if(dialog and dialog.visible) then
    dialog:show()
    return
  end

  theme_changed()
  dialog = renoise.app():show_custom_dialog('TapeDeck', make_gui, key_handler)
  Notifiers:add(renoise.tool().app_idle_observable, app_idle)
  Notifiers:add(renoise.app().theme_observable, theme_changed)

end

It’s not pretty, but it seems to work.
Thanks to this, I noticed that the error in the definitions is precisely in determining the current color.
there is renoise.app().theme.color()

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.