-
Notifications
You must be signed in to change notification settings - Fork 471
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
Migrate widgets constants to use getter/setter style #4972
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,38 @@ DimensionsTooltip = require('gui.widgets.dimensions_tooltip') | |
Tab = TabBar.Tab | ||
makeButtonLabelText = Label.makeButtonLabelText | ||
|
||
DOUBLE_CLICK_MS = Panel.DOUBLE_CLICK_MS | ||
STANDARDSCROLL = Scrollbar.STANDARDSCROLL | ||
SCROLL_INITIAL_DELAY_MS = Scrollbar.SCROLL_INITIAL_DELAY_MS | ||
SCROLL_DELAY_MS = Scrollbar.SCROLL_DELAY_MS | ||
---@return boolean | ||
function getDoubleClickMs() | ||
return Panel.DOUBLE_CLICK_MS | ||
end | ||
function setDoubleClickMs(value) | ||
Panel.DOUBLE_CLICK_MS = value | ||
end | ||
|
||
---@return boolean | ||
function getStandardScroll() | ||
return Scrollbar.STANDARDSCROLL | ||
end | ||
function setStandardScroll(value) | ||
Scrollbar.STANDARDSCROLL = value | ||
end | ||
Comment on lines
+41
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. STANDARDSCROLL is a constant and doesn't need a function wrapper. we could keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (my vote is that it doesn't make the API clearer) |
||
|
||
---@return boolean | ||
function getScrollInitialDelayMs() | ||
return Scrollbar.SCROLL_INITIAL_DELAY_MS | ||
end | ||
function setScrollInitialDelayMs(value) | ||
Scrollbar.SCROLL_INITIAL_DELAY_MS = value | ||
end | ||
|
||
---@return boolean | ||
function getScrollDelayMs() | ||
return Scrollbar.SCROLL_DELAY_MS | ||
end | ||
function setScrollDelayMs(value) | ||
Scrollbar.SCROLL_DELAY_MS = value | ||
end | ||
|
||
|
||
|
||
return _ENV |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,7 +277,7 @@ Label.ATTRS{ | |
auto_width = false, | ||
on_click = DEFAULT_NIL, | ||
on_rclick = DEFAULT_NIL, | ||
scroll_keys = STANDARDSCROLL, | ||
scroll_keys = Scrollbar.STANDARDSCROLL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we have multiple other widgets referencing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the issue here, I think, is that widgets can't include another option is to move all constants (and settable preferences) into a separate, common file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, maybe that would be a circular dependency. In that case, I think we do need a separate constants file. Making Label depend on Scrollbar for a shared constant feels very arbitrary to me, and could result in cyclical dependencies down the road if we add more constants that multiple widgets need. |
||
} | ||
|
||
---@param args widgets.Label.attrs.partial | ||
|
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.
Could you update this to indicate that the
control-panel
orgui/control-panel
interfaces should be used to set these properties? That goes for the others as well. You can remove thewidget.*
function references. These docs were written before the control panel was a thing.The
gui/control-panel
interface looks like this:and the
control-panel
interface looks like this:the functions should no longer be called by anything other than the control panel interfaces