fix issue #42 - editors update after loading of file; fix theme

This commit is contained in:
Vadim Lopatin 2015-01-30 10:59:07 +03:00
parent 62c94537a2
commit 98f90165ba
4 changed files with 44 additions and 13 deletions

View File

@ -1149,6 +1149,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
protected uint _iconsPaneWidth = 16; protected uint _iconsPaneWidth = 16;
protected uint _foldingPaneWidth = 16; protected uint _foldingPaneWidth = 16;
protected uint _modificationMarksPaneWidth = 8; protected uint _modificationMarksPaneWidth = 8;
/// when true, call measureVisibileText on next layout
protected bool _contentChanged = true;
/// Modified state change listener /// Modified state change listener
Signal!ModifiedStateListener onModifiedStateChangeListener; Signal!ModifiedStateListener onModifiedStateChangeListener;
@ -1496,23 +1499,27 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
override void onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter, Object source) { override void onContentChange(EditableContent content, EditOperation operation, ref TextRange rangeBefore, ref TextRange rangeAfter, Object source) {
//Log.d("onContentChange rangeBefore=", rangeBefore, " rangeAfter=", rangeAfter, " text=", operation.content); //Log.d("onContentChange rangeBefore=", rangeBefore, " rangeAfter=", rangeAfter, " text=", operation.content);
updateMaxLineWidth();
measureVisibleText();
if (source is this) { if (source is this) {
if (operation.action == EditAction.ReplaceContent) { if (operation.action == EditAction.ReplaceContent) {
// loaded from file _contentChanged = true;
// fully replaced, e.g., loaded from file or text property is assigned
_caretPos = rangeAfter.end; _caretPos = rangeAfter.end;
_selectionRange.start = _caretPos; _selectionRange.start = _caretPos;
_selectionRange.end = _caretPos; _selectionRange.end = _caretPos;
updateMaxLineWidth();
measureVisibleText();
ensureCaretVisible(); ensureCaretVisible();
correctCaretPos(); correctCaretPos();
requestLayout(); requestLayout();
} else if (operation.action == EditAction.SaveContent) { } else if (operation.action == EditAction.SaveContent) {
// saved // saved
} else { } else {
_caretPos = rangeAfter.end; _contentChanged = true;
_caretPos = rangeAfter.end;
_selectionRange.start = _caretPos; _selectionRange.start = _caretPos;
_selectionRange.end = _caretPos; _selectionRange.end = _caretPos;
updateMaxLineWidth();
measureVisibleText();
ensureCaretVisible(); ensureCaretVisible();
} }
} else { } else {
@ -2283,6 +2290,10 @@ class EditLine : EditWidgetBase {
_clientRect = rc; _clientRect = rc;
applyMargins(_clientRect); applyMargins(_clientRect);
applyPadding(_clientRect); applyPadding(_clientRect);
if (_contentChanged) {
measureVisibleText();
_contentChanged = false;
}
} }
@ -2401,6 +2412,18 @@ class EditBox : EditWidgetBase {
return this; return this;
} }
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
override void layout(Rect rc) {
if (visibility == Visibility.Gone) {
return;
}
super.layout(rc);
if (_contentChanged) {
measureVisibleText();
_contentChanged = false;
}
}
override protected Point measureVisibleText() { override protected Point measureVisibleText() {
Point sz; Point sz;
FontRef font = font(); FontRef font = font();
@ -2442,7 +2465,7 @@ class EditBox : EditWidgetBase {
/// update verticat scrollbar widget position /// update verticat scrollbar widget position
override protected void updateVScrollBar() { override protected void updateVScrollBar() {
int visibleLines = _clientRect.height / _lineHeight; // fully visible lines int visibleLines = _lineHeight ? _clientRect.height / _lineHeight : 1; // fully visible lines
if (visibleLines < 1) if (visibleLines < 1)
visibleLines = 1; visibleLines = 1;
_vscrollbar.setRange(0, _content.length - 1); _vscrollbar.setRange(0, _content.length - 1);
@ -2494,7 +2517,7 @@ class EditBox : EditWidgetBase {
_caretPos.line = _content.length - 1; _caretPos.line = _content.length - 1;
if (_caretPos.line < 0) if (_caretPos.line < 0)
_caretPos.line = 0; _caretPos.line = 0;
int visibleLines = _clientRect.height / _lineHeight; // fully visible lines int visibleLines = _lineHeight > 0 ? _clientRect.height / _lineHeight : 1; // fully visible lines
if (visibleLines < 1) if (visibleLines < 1)
visibleLines = 1; visibleLines = 1;
if (_caretPos.line < _firstVisibleLine) { if (_caretPos.line < _firstVisibleLine) {

View File

@ -531,12 +531,16 @@ class TabHost : FrameLayout, TabHandler {
return this; return this;
} }
protected Visibility _hiddenTabsVisibility = Visibility.Invisible;
@property Visibility hiddenTabsVisibility() { return _hiddenTabsVisibility; }
@property void hiddenTabsVisibility(Visibility v) { _hiddenTabsVisibility = v; }
/// signal of tab change (e.g. by clicking on tab header) /// signal of tab change (e.g. by clicking on tab header)
Signal!TabHandler onTabChangedListener; Signal!TabHandler onTabChangedListener;
protected override void onTabChanged(string newActiveTabId, string previousTabId) { protected override void onTabChanged(string newActiveTabId, string previousTabId) {
if (newActiveTabId !is null) { if (newActiveTabId !is null) {
showChild(newActiveTabId, Visibility.Invisible, true); showChild(newActiveTabId, _hiddenTabsVisibility, true);
} }
if (onTabChangedListener.assigned) if (onTabChangedListener.assigned)
onTabChangedListener(newActiveTabId, previousTabId); onTabChangedListener(newActiveTabId, previousTabId);
@ -671,6 +675,9 @@ class TabWidget : VerticalLayout, TabHandler, TabCloseHandler {
_tabControl.renameTab(index, name); _tabControl.renameTab(index, name);
} }
@property Visibility hiddenTabsVisibility() { return _tabHost.hiddenTabsVisibility; }
@property void hiddenTabsVisibility(Visibility v) { _tabHost.hiddenTabsVisibility = v; }
/// select tab /// select tab
void selectTab(string ID, bool updateAccess = true) { void selectTab(string ID, bool updateAccess = true) {
_tabHost.selectTab(ID, updateAccess); _tabHost.selectTab(ID, updateAccess);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 249 B

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<theme id="theme_default" fontSize="15" <theme id="theme_default"
fontSize="14"
fontFace="Verdana,Arial,DejaVu Sans" fontFace="Verdana,Arial,DejaVu Sans"
fontFamily="SansSerif" fontFamily="SansSerif"
> >
@ -241,7 +242,7 @@
backgroundColor="#D0D0D0" backgroundColor="#D0D0D0"
layoutWidth="FILL_PARENT" layoutWidth="FILL_PARENT"
layoutHeight="WRAP_CONTENT" layoutHeight="WRAP_CONTENT"
padding="4,4,4,4" padding="1,1,1,1"
layoutWeight="0" layoutWeight="0"
/> />
<style id="DOCK_HOST" <style id="DOCK_HOST"
@ -300,19 +301,19 @@
backgroundImageId="toolbar_background" backgroundImageId="toolbar_background"
layoutWidth="WRAP_CONTENT" layoutWidth="WRAP_CONTENT"
layoutHeight="WRAP_CONTENT" layoutHeight="WRAP_CONTENT"
margins="2,2,2,2" margins="1,1,1,1"
/> />
<style id="TOOLBAR_BUTTON" <style id="TOOLBAR_BUTTON"
backgroundImageId="toolbar_button_background" backgroundImageId="toolbar_button_background"
align="Center" align="Center"
margins="1,1,1,1" margins="1,1,1,1"
padding="4,4,4,4" padding="2,2,2,2"
/> />
<style id="TOOLBAR_CONTROL" <style id="TOOLBAR_CONTROL"
backgroundImageId="toolbar_control_background" backgroundImageId="toolbar_control_background"
align="Center" align="Center"
margins="1,1,1,1" margins="1,1,1,1"
padding="4,4,4,4" padding="2,2,2,2"
/> />
<style id="TOOLBAR_SEPARATOR" <style id="TOOLBAR_SEPARATOR"
align="Center" align="Center"
@ -321,7 +322,7 @@
<style id="TREE_ITEM" <style id="TREE_ITEM"
padding="1,1,1,1" padding="1,1,1,1"
minWidth="100" minWidth="100"
minHeight="15" minHeight="14"
layoutWidth="FILL_PARENT" layoutWidth="FILL_PARENT"
layoutHeight="WRAP_CONTENT" layoutHeight="WRAP_CONTENT"
fontSize="14"> fontSize="14">