Commit Graph

70 Commits

Author SHA1 Message Date
Campbell Barton 7020b33e14 Cleanup: remove outdated comment 2024-01-10 10:04:13 +11:00
Julian Eisel 4c8847ec4f Cleanup: Remove `extern "C"` from DNA headers
`extern "C"` did not actually have an effect here since it only impacts
name mangling of functions, not structs (or other class types). Now this
can get in the way when we add C++ blocks with functions , e.g.
templates are not allowed in code with C-linkage.

Most of these were added in ad4b7741db, even though it was known that
this doesn't have any impact. Reason was because developers thought they
would have to add that to all direct and indirect includes to be able to
use a header in C++ (a common misconception). Now with most files
compiled in C++, it's obvious that this isn't the case.

Pull Request: https://projects.blender.org/blender/blender/pulls/111926
2023-09-04 15:59:40 +02:00
Julian Eisel 0d1f3f445a UI: Support page based scrolling in View2D
No user visible changes expected. The feature is not exposed yet.

For the asset shelf (#102879), design is to use a paginated scrolling
style. That means, that any scrolling will always snap to a multiple of
the page size (the size used when pressing the Page Up/Down keys).
Together with strict region size snapping (implemented in the asset
shelf patch, #104831), this gives a clean scrolling experience where
partially visible rows are avoided (impossible even).

Introduces:
- `View2D.flag` value `V2D_SNAP_TO_PAGESIZE_Y`, which will cause any
  scrolling to only use multiples of the page size.
- A custom page size via `View2D.page_size_y` for when the full region
  size is not the appropriate page size value.
- API function `UI_view2d_offset_y_snap_to_closest_page()` to enforce
  the snapping from outside View2D. The asset shelf uses this to keep
  strict scrolling over DPI changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109154
2023-07-03 15:15:18 +02: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
Campbell Barton 13c815085b Cleanup: spelling in comments 2023-05-24 11:21:18 +10:00
Campbell Barton 6424fbca94 Cleanup: spelling 2022-09-19 14:52:27 +10:00
Campbell Barton 95fd163074 Cleanup: spelling in comments 2022-08-17 15:43:17 +10:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton 5c63c0a58c Docs: use doxygen formatting for DNA
Differentiate doc-strings from title/section text.
Also use explicit doxygen references to struct members
so it's not ambiguous which member is being referenced.

Note that these changes aren't complete (some files weren't touched).
2021-12-20 19:07:10 +11:00
Aditya Y Jeppu 997b5fe45d VSE strip thumbnails
Draw thumbnails as strip overlay. This works for movie and image strips.
To draw thumbnails, this overlay has to be enabled and strips must be
tall enough.

The thumbnails are loaded from source file using separate thread and
stored in cache.

Drawing code uses only images stored in cache, and if any is missing,
background rendering job is started. If job can not render thumbnail,
to prevent endless loop of creating job for missing image it sets
`SEQ_FLAG_SKIP_THUMBNAILS` bit of `Sequence` flag.

To prevent visual glitches during timeline panning and zooming, `View2D`
flag `V2D_IS_NAVIGATING` is implemented. If bit is set, drawing code
will look for set of evenly distributed thumbnails that should be
guaranteed to exist and also set of previously displayed thumbnails.
Due to volatile nature of cache these thumbnails can be missing anyway,
in which case no new thumbnails will be drawn for particular strip.

Cache capacity is limited to 5000 thumbnails and performs cleanup of
non visible images when limit is reached.

ref T89143

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D12266
2021-09-21 10:55:04 +02:00
Campbell Barton ced94bc11c Cleanup: code comments punctuation / spacing 2021-07-23 17:03:51 +10:00
Julian Eisel ad4b7741db Build-system: Force C linkage for all DNA type headers
Some DNA headers already did this, most did not. Even though many of them would
be included in C++ files and thus compiled as C++. This would be confusing and
developers may think they have to add `extern "C"` too a whole lot of
(indirect) includes to be able to use a C header in C++.

However, this is a misconception.
`extern "C"` does not cause code to be compiled with C rather than C++! It only
causes the linker to not use C++ function name mangling. See
https://stackoverflow.com/a/1041880.
Because extern DNA headers don't have function declarations, using `extern "C"`
actually should not have any effect. On the other hand, adding it causes no
harm and avoids confusion. So let's just have it consistently in C header
files.

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

Reviewed by: Bastien Montagne, Sybren Stüvel
2020-11-19 13:41:50 +01:00
Hans Goudey 8cbd09672d Cleanup: Remove unused View2D variables and function
It looks like this code was left over from tabbed panels in the
properties editor. It wasn't used anywhere except for in one line of
the horizontally-aligned panel code that was recently removed.

Differential Revision: https://developer.blender.org/D8651
2020-09-30 12:21:35 -05:00
Jacques Lucke 7283e6fb73 Merge branch 'blender-v2.90-release' into master 2020-08-07 10:04:57 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Campbell Barton 901ee66ea1 Cleanup: use term init instead of initialize/initialise
The abbreviation 'init' is brief, unambiguous and already used
in thousands of places, also initialize is often accidentally
written with British spelling.
2020-08-01 13:51:05 +10:00
Jacques Lucke 3b9813fe50 UI: Move scrollbars to the right in animation editors
The text, that was in the scrollbars, stays on the left.

Reviewers: brecht, billreynish

Differential Revision: https://developer.blender.org/D4821
2019-05-08 15:16:05 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton 6a03199b50 Cleanup: use '_pad' convention for padding in all DNA structs
Avoids mixing these in with regular variables in code-completion.

Use char for pad members except for 'void *', to make size clearer.

Removed/shrink a few redundant padding vars which were >= 8 bytes.
2019-02-27 15:09:48 +11:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton 328a0f975b Cleanup: comment line length (DNA)
Prevents clang-format wrapping text before comments.
2019-01-15 23:15:35 +11:00
Campbell Barton 5a43406e1b Cleanup: move DNA comments before struct members
Needed for clang-format in some cases, see: T53211
2019-01-08 00:43:00 +11:00
Brecht Van Lommel 3eab8156d3 UI: don't change scrollbar size on mouse move, only fade.
It's not necessary to do both, and trying to hit a target that changes
size is annoying.
2018-07-11 12:35:44 +02:00
Campbell Barton 18d87e79e9 Merge branch 'master' into blender2.8 2018-06-29 09:25:40 +02:00
Campbell Barton b372766816 Cleanup: trailing newlines 2018-06-29 09:23:51 +02:00
Campbell Barton 06a1a66a9b Merge branch 'master' into blender2.8 2018-06-17 17:10:19 +02:00
Campbell Barton 78fbd146f3 Cleanup: trailing space for DNA headers 2018-06-17 17:04:09 +02:00
Julian Eisel 51efeb6834 UI: Hide & shrink scroll-bars based on cursor position
Scroll-bars are now hidden unless the cursor approaches them, in which case they
smoothly grow and become more & more visible. Note that since 0d309144020168e55,
scroll-bars are drawn on top of editor contents. There's no more jumping of
buttons when scroll-bars appear.

Technical notes:
* AZones are used to adjust scrollbars based on mouse movements

  We may want to support screen level AZones if we want scrollbars to also
  smoothly appear when approaching them from a different area.
  I also plan to make further changes to AZones to clean up stuff a bit.
* Had to move AZone handling to a post ARegion init stage, since we need the
  updated View2D data from there.
* View2D masks and scroller rectangles are now updated on every redraw. It's
  cheap to do that though.
2018-05-07 11:42:12 +02:00
Julian Eisel 3c7500ca71 Cleanup: Use enums for View2D value defines
Makes the file much less cluttered and more structured.
Also made some whitespace tweaks.
2018-04-26 14:07:03 +02:00
Campbell Barton 912397756a Fix T44432: Zoom to mouse fails /w FCurve editor 2015-04-21 13:10:32 +10:00
Ton Roosendaal fa28e50ac2 Region scrollbar fix!
Now scrollbars correctly hide and show, making space for the actual contents
in a region. It solves several old hacks, and puts view2d code a bit more
back in control as well. 

Implementation notes:

- The view2d mask feature is working again
- The #define V2D_SCROLL_HORIZONTAL_HIDE means: "turn on hiding".
- Code for UI_view2d_region_reinit() is enforcing better standard view settings

But... two hack/patches needed to be added:

- Region panel drawing: if after generating the button panels it appears
  a scroller hides or reveils, it calls all the generating code again.
  (a simple scale doesn't work due to rounding differences in layout code)

- View2d code that maps 'tot' and 'cur' rects: if this code detects that
  the mask changes, it calcs the map code again.

Also a bugfix (issue in 2.65)

- The left/bottom area split widget was drawing 1 pixel too large sometimes, 
  leaving bad trails on moving area dividers.
2012-12-26 13:05:39 +00:00
Campbell Barton f3ece5a108 style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
Campbell Barton c140ccb9fd 2d smoothview now scales back the time to move for smaller view zoom/panning.
also the compositor bounds (used for scroll bars), were only calculated when pressing the home key in 2.63, how this is updated on draw
2012-08-12 19:35:47 +00:00
Campbell Barton 9cce2d8645 smooth-view for 2d views, graph editor, sequencer, node view, works with border zoom, view selected, view all. 2012-08-12 01:07:31 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Campbell Barton ca629d5ccc minor dna header cleanup 2011-12-30 07:25:49 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Nathan Letwory 22dbae84e5 DNA header files are now grouped under the same module. No further documentation done. 2011-02-17 20:48:12 +00:00
Matt Ebb b09ee4923d Fix [#21711] Position of 2d cursor is not displayed correctly and cannot be set
in uv/image editor properties panel

Note: Moved UV editor 2d cursor to SpaceImage rather than View2d, so it's 
more accessible to RNA.
2010-03-30 05:52:05 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Joshua Leung 1277543732 Various tweaks to View2D code for handling of scrollbar interactions in relation to bug 19881:
* Clearly labelled the way that the scrollbar hiding works. Also see the report comments for an overview
* Added another pair of flags for another one of the cases in which scrollbars should also get ignored; when the entire contents of the view are visible, a pair of flags is now set in the view2d data (instead of for the scrollers tempdata only) for detecting this case too
* Fixed the potential for scrollbars without zoom handles shown to have those handles still considered. This still happened in the User Preferences window, but has now been disabled.

--

These changes still don't solve the bug though. Currently after the scrollbar operator passes through, the Outliner's activate-selection operators still fail to start.
2010-01-31 11:13:31 +00:00
Brecht Van Lommel 408ba429e6 2.5: Buttons View
* When resizing the window, the top position is now preserved,
  instead of the center position.
* Fix zoom level not being preserved in various cases, when
  changing both with and height. This replaces some earlier code
  which did this at screen level but wasn't very reliable.
* Different tabs now each preserve their own scroll.
* When switching between tabs, it now scrolls to show as many
  buttons as possible, instead of possibly showing empty space.
  There is a trade-off here between doing that keeping the
  buttons in the same place, no ideal solution exists I think.
* Change zooming in/out to be symmetric, for example doing
  numpad + then - did not give the original zoom level back.
* Added some calls to avoid hanging tooltips when manipulating
  the view.

Internals:
* Added V2D_KEEPOFS_X and V2D_KEEPOFS_Y to keep the top/bottom
  rather than the center.
* Renamed V2D_KEEPZOOM to V2D_LIMITZOOM (seems more appropriate),
  and make V2D_KEEPZOOM preserve the zoom level.
2009-07-29 22:57:53 +00:00
Ton Roosendaal 5a0896e1a3 2.5
Cleanup of scroller drawing in 2D windows.

Before:
http://download.blender.org/institute/rt11.jpg
After:
http://download.blender.org/institute/rt12.jpg

Will add 'zoom' widget circles later, as mockupped here:
http://www.reynish.com/files/blender25/fcurve_scrollbar.png

Also note the scale values are inside scroller; drawing it
on top conflicts with current frame item and markers.

Currently scroller disappear entirely when view is total.

For Joshua:
To make sliders behave nicely, the boundbox (v2d->tot) has to
be refreshed on each change. I've added it in graph drawing
now, but it could be notifier based I guess... not sure what
the correct anim api call would be. Can discuss tomorrow!

On todo:
Layout config hints so people can make scroller positions swap.
2009-07-02 18:12:46 +00:00
Ton Roosendaal 4e232753c0 2.5
Some drawing tweaks for animsys:

- added notifier ND_KEYS type, to send proper notes around.
  now insert-key redraws fcurve/action view
- made slider-draggers disappear when view is total or bigger.

Also experimented with making sliders go away entirely, but
this conflicts too much with current code for channel lists.

Ali: I think you have to make call that calculates the 'tot'
for channels, and run this in region listener, including the
totRect update for view2d.

The 'minsize' for channels also fails when there's a slider,
it always doesn't fit then :)
2009-01-28 18:26:47 +00:00
Joshua Leung ad4d061091 View2D - Vertical (within area) syncing for channel lists to stay in sync with the relevant keyframes...
I still need to work out how to get this to work correctly as soon as an Action Editor instance is created.
2008-12-21 11:56:42 +00:00
Joshua Leung dae839639d View2D: More bugfixes
* Added flags to View2D to specify whether the view should have pixel offsets applied (this is able to be specified per axis, just in case the need arises). Currently, this is only used for headers, where the UI elements were not as smooth + round as they could be

* Fixed IPO/Action/NLA so that new instance will show channel lists by default and with scrollers

* Fixed Outliner zoom-in/out on changing windowsize. I didn't notice this on my previous custom .B.blend file, but the problem was apparent in the default setup.
2008-12-18 09:20:29 +00:00
Joshua Leung f518fa8ea7 View2D: Presets for Initialising Views
Improved the View2D API so that initialising View2D data in init() callbacks (called on new regions and also on resizing regions) for regions is easier. 

Added a few preset view configurations for use when initialising new views. Views with the V2D_IS_INITIALISED flag set will not be reinitialised in the init() callbacks. Currently, some of these configurations will set/override all settings (like V2D_COMMONVIEW_LIST and V2D_COMMONVIEW_HEADER), while other ones serve a more supplimentary role (i.e. V2D_COMMONVIEW_TIMELINE only sets the x-axis settings, relying on the region to have already set the relevant y-axis settings). 
The future of such supplimentary configurations is yet to be seen, as I'm currently not sure whether they will cause the code to become too confusing, as you'd have to keep track of which settings belong/are set where. So far, only a few areas have been ported to use this. Tomorrow I'll check on a few more.

As this commit touches a lot of files, hopefully there aren't any critical bugs I've missed here.
2008-12-16 11:24:24 +00:00
Joshua Leung 21ca594625 View2D: Simplification and documentation of settings
I've gone through and simplified some of the redundant options while documenting the various settings (in the code and also in the Wiki Doc), to make it clearer how to use each option.

'Preset' view-types have yet to be fully implemented, but started groundwork for this. Only some commonly used view configurations will be defined using this method. For all others, they still need to define all relavent view settings themselves (as there's too much variation in terms of the various editor's use of View2D).

IPO Editor now draws with channels on the left, like all other anim editors. Now, how to make this wider...
2008-12-15 11:58:57 +00:00