Blender  V3.3
abstract_view.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "interface_intern.h"
8 
9 #include "UI_abstract_view.hh"
10 
11 namespace blender::ui {
12 
14 {
15  /* Actually modifies the item, not the view. But for the public API it "feels" a bit nicer to
16  * have the view base class register the items, rather than setting the view on the item. */
17  item.view_ = this;
18 }
19 
20 /* ---------------------------------------------------------------------- */
25 {
26  return is_reconstructed_;
27 }
28 
30 {
31  uiBlock *old_block = new_block.oldblock;
32  if (!old_block) {
33  is_reconstructed_ = true;
34  return;
35  }
36 
38  &new_block, reinterpret_cast<uiViewHandle *>(this));
39  if (old_view_handle == nullptr) {
40  /* Initial construction, nothing to update. */
41  is_reconstructed_ = true;
42  return;
43  }
44 
45  AbstractView &old_view = reinterpret_cast<AbstractView &>(*old_view_handle);
46 
47  /* Update own persistent data. */
48  /* Keep the rename buffer persistent while renaming! The rename button uses the buffer's
49  * pointer to identify itself over redraws. */
50  rename_buffer_ = std::move(old_view.rename_buffer_);
51  old_view.rename_buffer_ = nullptr;
52 
53  update_children_from_old(old_view);
54 
55  /* Finished (re-)constructing the tree. */
56  is_reconstructed_ = true;
57 }
58 
61 /* ---------------------------------------------------------------------- */
65 bool AbstractView::listen(const wmNotifier & /*notifier*/) const
66 {
67  /* Nothing by default. */
68  return false;
69 }
70 
73 /* ---------------------------------------------------------------------- */
78 {
79  return rename_buffer_ != nullptr;
80 }
81 
83 {
84  if (is_renaming()) {
85  return false;
86  }
87 
88  rename_buffer_ = std::make_unique<decltype(rename_buffer_)::element_type>();
89  return true;
90 }
91 
93 {
95  rename_buffer_ = nullptr;
96 }
97 
99 {
100  return *rename_buffer_;
101 }
103 {
104  return *rename_buffer_;
105 }
106 
109 } // namespace blender::ui
#define BLI_assert(a)
Definition: BLI_assert.h:46
struct uiViewHandle uiViewHandle
Definition: UI_interface.h:76
virtual bool listen(const wmNotifier &) const
void update_from_old(uiBlock &new_block)
virtual void update_children_from_old(const AbstractView &old_view)=0
void register_item(AbstractViewItem &item)
Span< char > get_rename_buffer() const
uiViewHandle * ui_block_view_find_matching_in_old_block(const uiBlock *new_block, const uiViewHandle *new_view)
uiBlock * oldblock