-
Notifications
You must be signed in to change notification settings - Fork 236
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
Improvements to the StatusView #852
Conversation
* Support for predicates by introducing add_item(). * Support for performing click actions on items. * Support for optional tooltips on item hover. * Deprecate the usage of get_item().
Forgot to mention that I also documented parts of the StatusView code using EmmyLua which can serve as an experiment of how one would document the core code directly. |
* Items are now objects that can be retrieved and manipulated. * clip rect is used for left and right panes * initial support for items to do their own custom drawing by also doing a clip rect for them * a custom background color can be specified for the item. * a command or function can be executed on item click. * Introduced functionality to easily hide or show all or specific items. * Better handling of deprecated get_items() * Spacing is automatically added to items and cleaned on deprecated items. * Default items where separated and given the names: doc:file, doc:position, doc:indentation, doc:lines, doc:line-ending, core.commandview. * Some default right or left click actions where given to the default items. * Started adding required bits to support dragging to left and right panes when some items aren't visible. Note: should work well enough already but maybe some repetitive stuff can be cleaned out.
Restructured almost everything that I did before, borrowed some ideas from vsc statusbar api and Implemented some more features as described on latest commit, for convenience will also paste them here:
Note: should work well enough already but maybe some repetitive stuff can be cleaned out. Also here a screen capture showing some of the things that can be done now: statusview-latest.mp4 |
c11f447
to
3452d49
Compare
Dragging and scrolling left or right panels is now supported, now last missing bit is detecting the visible area of an item for click and mouse hover events: statusview-drag-scroll.mp4 |
20dc06b
to
ae8890f
Compare
ae8890f
to
128e10b
Compare
For reference, leaving some sample code on how to do custom drawing into the status bar: if not core.status_view:get_item("my:custom-item") then
local item = core.status_view:add_item(nil, "my:custom-item", StatusView.Item.LEFT)
item.on_draw = function(x, y, h, calc_only)
--true when the status bar needs to know the width of drawing area
if calc_only then
return 100
end
--if calc_only not true is time to draw
renderer.draw_text(style.font, "Hello", x, y, style.text)
end
item.background_color = { common.color "#0f6773" }
item.tooltip = "my item"
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about having an hovered background color for items with on_click
commands?
If so, an Item.background_color_hovered
would be needed. Also the hovered status should be passed to on_draw
.
This isn't too important, but resizing doesn't gracefully update the scrolled position:
ugly_resize.mp4
---@return table right | ||
function StatusView:get_items(nowarn) | ||
if not nowarn and not self.get_items_warn then | ||
core.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really add a warning
log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, and change the error icon maybe to X
and use the error icon !
for warnings with some orange or yellow color.
Implemented: statusview-hoverbg.mp4
Fixed (sorry for flickering on preview seems my mesa opengl driver has wayland issues with sdl when doing that): statusview-resizing.mp4 |
Features implemented:
Other stuff for the future that I'm not sure could implement now:clip_rect
Demonstration
statusview-changes.mp4