reduce relayouts

This commit is contained in:
Vadim Lopatin 2015-01-29 18:24:07 +03:00
parent c6b5028ff1
commit 4df4c0fc04
4 changed files with 21 additions and 1 deletions

View File

@ -527,7 +527,7 @@ class Win32FontManager : FontManager {
override ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face) {
//Log.i("getFont()");
FontDef * def = findFace(family, face);
Log.i("getFont() found face ", def.face, " by requested face ", face);
//Log.i("getFont() found face ", def.face, " by requested face ", face);
if (def !is null) {
int index = _activeFonts.find(size, weight, italic, def.family, def.face);
if (index >= 0)

View File

@ -529,6 +529,10 @@ class ListWidget : WidgetGroup, OnScrollHandler {
pwidth -= m.left + m.right + p.left + p.right;
if (parentHeight != SIZE_UNSPECIFIED)
pheight -= m.top + m.bottom + p.top + p.bottom;
bool oldNeedLayout = _needLayout;
Visibility oldScrollbarVisibility = _scrollbar.visibility;
_scrollbar.visibility = Visibility.Visible;
_scrollbar.measure(pwidth, pheight);
@ -606,6 +610,10 @@ class ListWidget : WidgetGroup, OnScrollHandler {
}
}
measuredContent(parentWidth, parentHeight, sz.x + _sbsz.x, sz.y + _sbsz.y);
if (_scrollbar.visibility == oldScrollbarVisibility) {
_needLayout = oldNeedLayout;
_scrollbar.cancelLayout();
}
}
@ -715,6 +723,8 @@ class ListWidget : WidgetGroup, OnScrollHandler {
makeSelectionVisible();
_makeSelectionVisibleOnNextLayout = false;
}
_needLayout = false;
_scrollbar.cancelLayout();
}
/// Draw widget at its position to buffer

View File

@ -779,6 +779,12 @@ class MainMenu : MenuWidgetBase {
deactivate();
}
/// request relayout of widget and its children
//override void requestLayout() {
// Log.d("MainMenu.requestLayout is called");
// super.requestLayout();
//}
/// bring focus to main menu, if not yet activated
void activate() {
debug(DebugMenus) Log.d("activating main menu");

View File

@ -927,6 +927,10 @@ class Widget {
}
void cancelLayout() {
_needLayout = false;
}
/// set new timer to call onTimer() after specified interval (for recurred notifications, return true from onTimer)
ulong setTimer(long intervalMillis) {
return window.setTimer(this, intervalMillis);