Skip to content
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

Remove forced list view window updating #29

Merged
merged 1 commit into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions list_view/list_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,25 @@ class ListView {
void set_show_sort_indicators(bool b_val);
void set_edge_style(t_size b_val);

void on_size(bool b_update = true, bool b_update_scroll = true);
void on_size(int cx, int cy, bool b_update = true, bool b_update_scroll = true);
void on_size(bool b_update_scroll = true);
void on_size(int cx, int cy, bool b_update_scroll = true);

void reposition_header();

void get_column_sizes(pfc::list_t<Column>& p_out);
void update_column_sizes();

// void insert_item(t_size index, const t_string_list_const_fast & text, const t_string_list_const_fast & p_groups,
// t_size size); void insert_items(t_size index_start, const pfc::list_base_const_t<InsertItem> & items, bool
// b_update_display = true);
void insert_items(t_size index_start, t_size count, const InsertItem* items, bool b_update_display = true);
void insert_items(t_size index_start, t_size count, const InsertItem* items);

template <class TItems>
void replace_items(t_size index_start, const TItems& items, bool b_update_display = true)
void replace_items(t_size index_start, const TItems& items)
{
replace_items(index_start, items.get_size(), items.get_ptr(), b_update_display);
replace_items(index_start, items.get_size(), items.get_ptr());
}
void replace_items(t_size index_start, t_size count, const InsertItem* items, bool b_update_display = true);
void replace_items(t_size index_start, t_size count, const InsertItem* items);
void remove_item(t_size index);
void remove_items(const pfc::bit_array& p_mask, bool b_update_display = true);
void remove_all_items(bool b_update_display = true);
void remove_items(const pfc::bit_array& p_mask);
void remove_all_items();

enum class HitTestCategory {
NotOnItem,
Expand Down Expand Up @@ -272,7 +269,7 @@ class ListView {
};

void hit_test_ex(POINT pt_client, HitTestResult& result);
void update_scroll_info(bool b_update = true, bool b_vertical = true, bool b_horizontal = true);
void update_scroll_info(bool b_vertical = true, bool b_horizontal = true);
void _update_scroll_info_vertical();
void _update_scroll_info_horizontal();
ItemVisibility get_item_visibility(t_size index);
Expand All @@ -286,7 +283,7 @@ class ListView {

void ensure_visible(t_size index, EnsureVisibleMode mode = EnsureVisibleMode::PreferCentringItem);

void scroll(int position, bool b_horizontal = false, bool update_display = true);
void scroll(int position, bool b_horizontal = false, bool suppress_scroll_window = false);
void scroll_from_scroll_bar(short scroll_bar_command, bool b_horizontal = false);

void get_item_group(t_size index, t_size level, t_size& index_start, t_size& count);
Expand Down Expand Up @@ -314,18 +311,17 @@ class ListView {
void get_search_box_rect(LPRECT rc) const;
unsigned get_search_box_height() const;

void invalidate_all(bool b_update = true, bool b_children = false);
void invalidate_items(t_size index, t_size count, bool b_update_display = true);
void invalidate_all(bool b_children = false);
void invalidate_items(t_size index, t_size count);

void invalidate_items(const pfc::bit_array& mask, bool b_update_display = true);
void invalidate_item_group_info_area(t_size index, bool b_update_display = true);
void invalidate_items(const pfc::bit_array& mask);
void invalidate_item_group_info_area(t_size index);

void update_items(t_size index, t_size count, bool b_update_display = true);
void update_all_items(bool b_update_display = true);
void update_items(t_size index, t_size count);
void update_all_items();

// Current implementation clears sub-items.
void reorder_items_partial(
size_t base, const size_t* order, size_t count, bool update_focus_item = true, bool update_display = true);
void reorder_items_partial(size_t base, const size_t* order, size_t count, bool update_focus_item = true);

enum class VerticalPositionCategory {
OnItem,
Expand Down Expand Up @@ -423,7 +419,7 @@ class ListView {
return ret;
}

void refresh_item_positions(bool b_update_display = true);
void refresh_item_positions();

enum notification_source_t {
notification_source_unknown,
Expand All @@ -435,9 +431,9 @@ class ListView {
// CLIENT FUNCTIONS
void get_selection_state(pfc::bit_array_var& out);
void set_selection_state(const pfc::bit_array& p_affected, const pfc::bit_array& p_status, bool b_notify = true,
bool b_update_display = true, notification_source_t p_notification_source = notification_source_unknown);
notification_source_t p_notification_source = notification_source_unknown);
t_size get_focus_item();
void set_focus_item(t_size index, bool b_notify = true, bool b_update_display = true);
void set_focus_item(t_size index, bool b_notify = true);
bool get_item_selected(t_size index);

bool is_range_selected(t_size index, t_size count)
Expand Down Expand Up @@ -565,8 +561,6 @@ class ListView {
bool disable_redrawing();
void enable_redrawing();

void update_window() { UpdateWindow(get_wnd()); }

const char* get_item_text(t_size index, t_size column);

t_size get_item_count() { return m_items.get_count(); }
Expand Down Expand Up @@ -613,7 +607,7 @@ class ListView {
}
}

void on_focus_change(t_size index_prev, t_size index_new, bool b_update_display = true);
void on_focus_change(t_size index_prev, t_size index_new);

void set_group_level_indentation_enabled(bool b_val)
{
Expand Down Expand Up @@ -795,7 +789,7 @@ class ListView {
void create_header();
void destroy_header();
void build_header();
void update_header(bool b_update = true);
void update_header();

void create_tooltip(/*t_size index, t_size column, */ const char* str);
void destroy_tooltip();
Expand Down Expand Up @@ -878,7 +872,6 @@ class ListView {
bool m_sort_direction{false};
EdgeStyle m_edge_style{edge_grey};
bool m_sizing{false};
bool m_suppress_wm_size_window_updating{false};

bool m_single_selection{false};
bool m_alternate_selection{false};
Expand Down
6 changes: 2 additions & 4 deletions list_view/list_view_columns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ void ListView::set_columns(const pfc::list_base_const_t<Column>& columns)
if (m_initialised) {
build_header();
_update_scroll_info_horizontal();
on_size(false, false);
UpdateWindow(get_wnd());
on_size(false);
}
}

Expand All @@ -64,9 +63,8 @@ void ListView::set_column_widths(const pfc::list_base_const_t<int>& widths)
update_header();
if (m_wnd_header)
SendMessage(m_wnd_header, WM_SETREDRAW, TRUE, NULL);
invalidate_all(false);
invalidate_all();
on_size();
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_ALLCHILDREN | RDW_UPDATENOW);
}

void ListView::get_column_sizes(pfc::list_t<Column>& p_out)
Expand Down
2 changes: 1 addition & 1 deletion list_view/list_view_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ unsigned ListView::calculate_header_height()
return rv;
}

void ListView::update_header(bool b_update)
void ListView::update_header()
{
if (m_wnd_header) {
pfc::vartoggle_t<bool> toggle(m_ignore_column_size_change_notification, true);
Expand Down
16 changes: 7 additions & 9 deletions list_view/list_view_item_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ void ListView::get_selection_state(pfc::bit_array_var& out)
}

void ListView::set_selection_state(const pfc::bit_array& p_affected, const pfc::bit_array& p_status, bool b_notify,
bool b_update_display, notification_source_t p_notification_source)
notification_source_t p_notification_source)
{
pfc::bit_array_bittable p_changed(get_item_count());
if (storage_set_selection_state(p_affected, p_status, &p_changed)) {
invalidate_items(p_changed, b_update_display);
// RedrawWindow(get_wnd(), NULL, NULL, RDW_INVALIDATE|(b_update_display?RDW_UPDATENOW:0));
invalidate_items(p_changed);
if (b_notify)
notify_on_selection_change(p_changed, p_status, p_notification_source);
}
Expand All @@ -27,12 +26,12 @@ t_size ListView::get_focus_item()
return ret;
}

void ListView::set_focus_item(t_size index, bool b_notify, bool b_update_display)
void ListView::set_focus_item(t_size index, bool b_notify)
{
t_size old = storage_get_focus_item();
if (old != index) {
storage_set_focus_item(index);
on_focus_change(old, index, b_update_display);
on_focus_change(old, index);
if (b_notify)
notify_on_focus_item_change(index);
}
Expand Down Expand Up @@ -71,9 +70,8 @@ void ListView::set_item_selected(t_size index, bool b_state)
void ListView::set_item_selected_single(t_size index, bool b_notify, notification_source_t p_notification_source)
{
if (index < m_items.get_count()) {
set_selection_state(pfc::bit_array_true(), pfc::bit_array_one(index), b_notify, false, p_notification_source);
set_focus_item(index, b_notify, false);
UpdateWindow(get_wnd());
set_selection_state(pfc::bit_array_true(), pfc::bit_array_one(index), b_notify, p_notification_source);
set_focus_item(index, b_notify);
// ensure_visible(index);
}
}
Expand Down Expand Up @@ -117,4 +115,4 @@ bool ListView::storage_get_item_selected(t_size index)
return m_items[index]->m_selected;
}

} // namespace uih
} // namespace uih
33 changes: 15 additions & 18 deletions list_view/list_view_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@ const char* ListView::get_item_text(t_size index, t_size column)
return m_items[index]->m_subitems[column];
}

void ListView::insert_items(t_size index_start, t_size count, const InsertItem* items, bool b_update_display)
void ListView::insert_items(t_size index_start, t_size count, const InsertItem* items)
{
__insert_items_v3(index_start, count, items);
__calculate_item_positions(index_start);
// profiler(pvt_render);
update_scroll_info(b_update_display);
if (b_update_display)
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
update_scroll_info();
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE);
}
void ListView::replace_items(t_size index_start, t_size count, const InsertItem* items, bool b_update_display)

void ListView::replace_items(t_size index_start, t_size count, const InsertItem* items)
{
__replace_items_v2(index_start, count, items);
__calculate_item_positions(index_start);
update_scroll_info(b_update_display);
if (b_update_display)
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
update_scroll_info();
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE);
}

void ListView::remove_items(const pfc::bit_array& p_mask, bool b_update_display)
void ListView::remove_items(const pfc::bit_array& p_mask)
{
if (m_timer_inline_edit)
exit_inline_edit();
Expand All @@ -43,21 +42,19 @@ void ListView::remove_items(const pfc::bit_array& p_mask, bool b_update_display)
__remove_item(i - 1);
}
__calculate_item_positions();
update_scroll_info(b_update_display);
if (b_update_display)
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
update_scroll_info();
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE);
}

void ListView::remove_all_items(bool b_update_display)
void ListView::remove_all_items()
{
if (m_timer_inline_edit)
exit_inline_edit();

m_items.remove_all();
update_scroll_info(b_update_display);

if (b_update_display)
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
update_scroll_info();

RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE);
}

void ListView::__replace_items_v2(t_size index_start, t_size countl, const InsertItem* items)
Expand Down Expand Up @@ -375,7 +372,7 @@ void ListView::remove_item(t_size index)
__remove_item(index);
__calculate_item_positions();
update_scroll_info();
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
RedrawWindow(get_wnd(), nullptr, nullptr, RDW_INVALIDATE);
}
void ListView::__remove_item(t_size index)
{
Expand Down
Loading