Commit Graph

56 Commits

Author SHA1 Message Date
Harley Acheson
aa88d9a8e3 Revert "UI: Input Placeholders"
This reverts commit b0515e34f9.
Unintentionally added to 4.0
2023-10-11 08:01:24 -07:00
Harley Acheson
b0515e34f9 UI: Input Placeholders
Optional inline hint describing the expected value of an input field.

Pull Request: https://projects.blender.org/blender/blender/pulls/112104
2023-10-11 00:47:13 +02:00
Pratik Borhade
b5ebf31fb1 Fix #113022: Disabled menu item's text uses inner color
This fails to differentiate between active buttons and disabled buttons
for some custom themes (and also in blender light theme)

Instead use text color with 0.5 alpha value for disabled item's text.
(Don't blend between text and inner color)

Pull Request: https://projects.blender.org/blender/blender/pulls/113082
2023-10-06 12:54:14 +02:00
Campbell Barton
b4d3bd134b Cleanup: quiet ASAN warning with invalid value for eButGradientType
-1 was assigned to eButGradientType which isn't a valid value,
add UI_GRAD_NONE to resolve this.
2023-09-27 14:28:47 +10:00
Julian Eisel
427bdc8dcf UI: Remove dead space between tree view items
Part of #107742.

There used to be a small margin between items since the layout feels a
bit crammed otherwise. But this meant the mouse could be between items,
with no item highlighted or reacting to interactions. This was
especially annoying when dragging over items for drag and drop: in
between items dropping wasn't possible, and the drag-tooltip would
disappear, causing notable flickering during motions over the tree view.

The view item is now slightly enlarged to keep a look that is not too
crammed, and still remove the space between items. Item highlights are
still drawn with a smaller height (matching the normal widget height),
since anything else looked odd to me.

This now feels quite consistent with similar UIs (e.g. File Browser list
view or the Outliner), even though we give the items a bit more space.
2023-09-22 17:34:11 +02:00
Leon Schittek
0edd60b4c7 Fix: UI: Don't show padding buttons in menus
Padding buttons are supposed to be invisible but were drawn like
regular menu items.

For the most part it doesn't make a difference, since most themes
use transparent menu items anyway.
But e.g. the "White" theme is using opaque menu items, which
would causes the padding button to overlap at the corner when
the roundness of the menu background is very high.

Pull Request: https://projects.blender.org/blender/blender/pulls/112731
2023-09-22 17:19:33 +02:00
Harley Acheson
a0b4ead737 BLF: Subpixel Positioning, Anti-aliasing, Hinting
Text output using subpixel positioning, subpixel anti-aliasing, and
typographically-correct hinting.

Pull Request: https://projects.blender.org/blender/blender/pulls/105441
2023-09-21 22:43:17 +02:00
Campbell Barton
ab4562738c Cleanup: add asserts, improve wmEvent::utf8_buf doc-string
- rna_Event_unicode_length would return -1 if utf8_buf wasn't a valid
  unicode sequence, while this shouldn't happen, assert and return zero
  instead of returning a bad length.
- Move comment on wmEvent::utf8_buf null termination to a doc-string.
2023-09-18 14:32:15 +10:00
Campbell Barton
ed552e9e4f Cleanup: add suffix to clarify unicode functions that return an error
There were enough cases of callers ignoring a potential the error value,
using the column width for e.g. to calculate pixel sizes, or the size in
bytes to calculate buffer offsets.

Since text fields & labels can include characters that return an error
from BLI_str_utf8_as_unicode, add the suffix to make this explicit.
2023-09-18 13:41:03 +10:00
Pablo Vazquez
2ec2e52a90 UI: Theme: Allow transparency when editing text in widgets
Allow transparency in both text and background color, to allow blending
the selected color with whatever is underneath. Making theming more
flexible, especially since the same property is used in different backgrounds.

Note: this doesn't affect the default themes since all of them have the alpha
component in inner at `1.0`.

Pull Request: https://projects.blender.org/blender/blender/pulls/112090
2023-09-14 19:28:30 +02:00
Campbell Barton
b3f9663011 Cleanup: use a mask combining all pie menu directions
Avoid looping over buttons to check which directions are in use.
2023-09-14 16:10:36 +10:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Harley Acheson
930dadd600 Fix #111831: Proper Highlighting of Inactive Buttons
Deal separately with menu states of Disabled and Inactive buttons,
since we want different hover highlighting for inactive.

Pull Request: https://projects.blender.org/blender/blender/pulls/112159
2023-09-08 19:42:47 +02:00
Leon Schittek
cc1c38f74d UI: Fix inconsistent menu background padding
Remove slight (2 pixels) extra padding at bottom of menus.

Pull Request: https://projects.blender.org/blender/blender/pulls/111826
2023-09-08 17:43:33 +02:00
Campbell Barton
3b0ced2e31 BLI_math: add add_v3_uchar_clamped (previously color_add_v3_i)
Move color_add_v3_i to a public function,
useful for making minor color adjustments.
2023-09-07 15:54:53 +10:00
Harley Acheson
d49c3d4d07 UI: Fixes for the highlighting of Selected Enums
Remove need for adding UI_BUT_LIST_ITEM, and replace use
of UI_BUT_ACTIVE_DEFAULT with UI_SELECT_DRAW

Pull Request: https://projects.blender.org/blender/blender/pulls/111938
2023-09-06 17:55:56 +02:00
Pablo Vazquez
9c1d9b6a82 UI: Hide widget emboss if inner color is fully transparent
Allows themes to have fully transparent widgets when the inner and
outline theme colors are set to 0.0f alpha.

Pull Request: https://projects.blender.org/blender/blender/pulls/111980
2023-09-06 17:53:43 +02:00
Harley Acheson
8a3766e241 Fix #111017: Improvements to the drawing of Color Ramps
Color Ramp widget with themed outline, handling of line width changes,
padding fixes, scaling fixes, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/111903
2023-09-06 00:00:40 +02:00
Harley Acheson
9f4b28bba8 UI: Highlight Selected Enum
Highlight the currently-selected item in enum, and some other, lists.

Pull Request: https://projects.blender.org/blender/blender/pulls/111074
2023-09-01 21:33:03 +02:00
Rawalanche
0e090369d6 Fix #109439: Use List Item widget colors for View Item widgets
As concluded in discussion under #109439, the View Item widgets are
supposed to use List Item widget theme colors. This patch does that.

Co-authored-by: Harley Acheson <harley.acheson@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/111584
2023-09-01 20:02:20 +02:00
Harley Acheson
2dc1dcc43e UI: Slight reduction and centering of UI_BTYPE_SEPR_LINE
A small reduction in the vertical space used by the menu separating
rule. Also centers the line within its space. Looks more balanced when
used between titles and content.

Pull Request: https://projects.blender.org/blender/blender/pulls/111764
2023-09-01 17:12:48 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Julian Eisel
5dcf704324 Refactor: Solve invalid icon-id enum values, use type alias
Some code attempted to use `BIFIconID` instead of `int` to pass around
icon-ids. Problem is, that this is just a subset of the allowed ids,
more icons may be created at runtime and extend the range of valid
icon-ids. Such icons could give runtime warning prints.

Idea is to use a `using BIFIconID = int;` instead. This way there is
still a descriptive type name, while the whole dynamic range of possible
icon-ids is supported.

Additionally multiple `using BIFIconID = int;` declarations are valid,
so we can place these in multiple headers and use the type name in APIs
instead of just `int`, whithout having to include a single header
defining them. A type mismatch (one instance differs from the others)
will result in a compiler error.

Pull Request: https://projects.blender.org/blender/blender/pulls/111052
2023-08-14 12:06:35 +02:00
Jacques Lucke
cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Hans Goudey
ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey
bc8c892c65 Cleanup: Move WM headers to C++
Also move a few more headers that included WM headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/110815
2023-08-04 23:11:22 +02:00
Julian Eisel
98142f5e35 UI: Asset Shelf Support (Experimental Feature)
No user visible changes expected, except of new experimental feature
option.

------------------------------------------------------------------------------

This introduces asset shelves as a new standard UI element for accessing
assets. Based on the current context (like the active mode and/or tool), they
can provide assets for specific workflows/tasks. As such they are more limited
in functionality than the asset browser, but a lot more efficient for certain
tasks.

The asset shelf is developed as part of the brush assets project (see #101895),
but is also meant to replace the current pose library UI.

Support for asset shelves can quite easily be added to different editor types,
the following commit will add support for the 3D View. If an editor type
supports asset shelves, add-ons can chose to register an asset shelf type for
an editor with just a few lines of Python.

It should be possible to entirely remove `UILayout.asset_view_template()` once
asset shelves are non-experimental.

Some changes are to be expected still, see #107881.

Task: #102879
Brush asset workflow blog post: https://code.blender.org/2022/12/brush-assets-workflow/
Initial technical documentation: https://developer.blender.org/docs/asset_system/user_interface/asset_shelf/

Pull Request: #104831
2023-08-03 16:54:39 +02:00
Julian Eisel
8662575f40 UI: Avoid slight text color flashing while clicking preview tiles
Text of preview-tile widgets would change color while pressing the mouse
button on them, this wasn't useful and just made the UI feel glitchy.
The widget background already indicates the state well.

Preview-tile widgets are currently only used in the asset view template.
More usages will be introduced in the asset-shelf patch (#104831).
2023-08-02 21:09:06 +02:00
Harley Acheson
1b1349cee4 UI: Indeterminate Button State
No user visible changes expected, the new button state is not used yet.

Setting a new uiBut drawflag shows items in an indeterminate state, not
indicating a specific value or state.

Pull Request: https://projects.blender.org/blender/blender/pulls/108210
2023-07-17 19:37:15 +02:00
Campbell Barton
68fbdda77f UI: remove recently added PIE progress display type
PIE was too similar to RING, as there is no need for two similar display
styles - make only one available.

Removal based on replies to !109882.
2023-07-15 16:14:10 +10:00
Harley Acheson
c6adafd8ef UI: add progress indicator variations & RNA API
Add pie and ring styles of progress indicators. Exposes progress bar to
the Python API and adds a "type" property to allow style variation.

This can be used for scripts & add-ons to show progress in the UI.

Ref !109882.

Co-authored-by: Campbell Barton <campbell@blender.org>
2023-07-12 14:00:39 +10:00
Campbell Barton
e63a77eeb8 Cleanup: rename uiButProgressbar to uiButProgress
Prepare for other types of progress to be added.
2023-07-12 13:31:46 +10:00
Harley Acheson
4a80d0b6d5 Refactor: UTF-8 Character Defines
Use defined UTF-8 Universal character names in place of byte escape
sequences and literals.

Pull Request: https://projects.blender.org/blender/blender/pulls/109163
2023-06-26 06:05:18 +02:00
Campbell Barton
cf29e011be Cleanup: remove all strcpy calls in source/blender/editors/
Replace with STRNCPY or BLI_strncpy, while many cases were safe,
translated source strings could cause buffer overflows, see: #108917.
2023-06-19 11:58:33 +10:00
Campbell Barton
74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Julian Eisel
c89354da80 UI: Properly center text under previews
The text under previews would be quite close to the preview, so that
there was more space below it than above. Center it vertically in the
available space now. Also, the horizontal padding was only applied to
the right side of the text rectangle, meaning horizontally centered text
would be too far left. Apply the padding equally, this doesn't affect
available space for the text too much.

See #108018 for before/after pictures.

Pull Request: https://projects.blender.org/blender/blender/pulls/108018
2023-05-17 18:10:54 +02:00
Julian Eisel
76112f1439 Fix double highlighting of preview tiles in asset view template
The highlighting of preview tiles would be too strong in asset view
templates and grid views (only used in branches so far). This is because
two buttons are overlayed on top of each other, and both would
highlight. Ensure the overlayed preview tile button doesn't use any
highlighting.
2023-05-17 17:54:35 +02:00
Campbell Barton
3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Sergey Sharybin
a12a8a71bb Remove "All Rights Reserved" from Blender Foundation copyright code
The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.

The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.

However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.

This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software ...

This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
2023-03-30 10:51:59 +02:00
Harley Acheson
f78f05c749 Refactor: U.dpi_fac -> U.scale_factor
A renaming of UI scale factors from names that imply a relationship to
monitor DPI to names that imply that they simply change "scale"

Pull Request: https://projects.blender.org/blender/blender/pulls/105750
2023-03-17 04:19:05 +01:00
Chris Blackbourn
86ceb6722f Cleanup: format 2023-02-26 11:55:22 +13:00
Harley Acheson
7216eb8879 UI: UIList Hover Highlighting
Add mouse hover highlighting for items in UILists, in both list mode
and preview tile mode.

See 104677 for more details

Differential Revision: https://projects.blender.org/blender/blender/pulls/104677

Reviewed by Brecht Van Lommel
2023-02-21 13:03:17 -08:00
Campbell Barton
91346755ce Cleanup: use '#' prefix for issues instead of 'T'
Match the convention from Gitea instead of Phabricator's T for tasks.
2023-02-12 14:56:05 +11:00
Clément Foucault
7e0e07657c GPU: Cleanup GPU_batch.h documentation and some of the API for consistency
Documented all functions, adding use case and side effects.

Also replace the use of shortened argument name by more meaningful ones.

Renamed `GPU_batch_instbuf_add_ex` and `GPU_batch_vertbuf_add_ex` to remove
the `ex` suffix as they are the main version used (removed the few usage
of the other version).

Renamed `GPU_batch_draw_instanced` to `GPU_batch_draw_instance_range` and
make it consistent with `GPU_batch_draw_range`.
2023-02-09 22:46:35 +01:00
Campbell Barton
9f5c17f4af Cleanup: comments in code 2023-02-06 12:25:04 +11:00
Julian Eisel
d204830107 UI: Make uiBut safe for non-trivial construction
No user-visible changes expected.

Essentially, this makes it possible to use C++ types like `std::function`
inside `uiBut`. This has plenty of benefits, for example this should help
significantly reducing unsafe `void *` use (since a `std::function` can hold
arbitrary data while preserving types).

----

I wanted to use a non-trivially-constructible C++ type (`std::function`) inside
`uiBut`. But this would mean we can't use `MEM_cnew()` like allocation anymore.

Rather than writing worse code, allow non-trivial construction for `uiBut`.
Member-initializing all members is annoying since there are so many, but rather
safe than sorry. As we use more C++ types (e.g. convert callbacks to use
`std::function`), this should become less since they initialize properly on
default construction.

Also use proper C++ inheritance for `uiBut` subtypes, the old way to allocate
based on size isn't working anymore.

Differential Revision: https://developer.blender.org/D17164

Reviewed by: Hans Goudey
2023-02-03 16:35:51 +01:00
Hans Goudey
08b2d04021 Cleanup: Use std::swap instead of macro in C++ code 2023-01-09 11:30:36 -05:00