mirror of https://github.com/buggins/dlangui.git
fix issue #42 - editors update after loading of file; fix theme
This commit is contained in:
parent
62c94537a2
commit
98f90165ba
|
@ -1149,6 +1149,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
protected uint _iconsPaneWidth = 16;
|
||||
protected uint _foldingPaneWidth = 16;
|
||||
protected uint _modificationMarksPaneWidth = 8;
|
||||
/// when true, call measureVisibileText on next layout
|
||||
protected bool _contentChanged = true;
|
||||
|
||||
|
||||
/// Modified state change listener
|
||||
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) {
|
||||
//Log.d("onContentChange rangeBefore=", rangeBefore, " rangeAfter=", rangeAfter, " text=", operation.content);
|
||||
updateMaxLineWidth();
|
||||
measureVisibleText();
|
||||
if (source is this) {
|
||||
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;
|
||||
_selectionRange.start = _caretPos;
|
||||
_selectionRange.end = _caretPos;
|
||||
updateMaxLineWidth();
|
||||
measureVisibleText();
|
||||
ensureCaretVisible();
|
||||
correctCaretPos();
|
||||
requestLayout();
|
||||
} else if (operation.action == EditAction.SaveContent) {
|
||||
// saved
|
||||
} else {
|
||||
_caretPos = rangeAfter.end;
|
||||
_contentChanged = true;
|
||||
_caretPos = rangeAfter.end;
|
||||
_selectionRange.start = _caretPos;
|
||||
_selectionRange.end = _caretPos;
|
||||
updateMaxLineWidth();
|
||||
measureVisibleText();
|
||||
ensureCaretVisible();
|
||||
}
|
||||
} else {
|
||||
|
@ -2283,6 +2290,10 @@ class EditLine : EditWidgetBase {
|
|||
_clientRect = rc;
|
||||
applyMargins(_clientRect);
|
||||
applyPadding(_clientRect);
|
||||
if (_contentChanged) {
|
||||
measureVisibleText();
|
||||
_contentChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2401,6 +2412,18 @@ class EditBox : EditWidgetBase {
|
|||
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() {
|
||||
Point sz;
|
||||
FontRef font = font();
|
||||
|
@ -2442,7 +2465,7 @@ class EditBox : EditWidgetBase {
|
|||
|
||||
/// update verticat scrollbar widget position
|
||||
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)
|
||||
visibleLines = 1;
|
||||
_vscrollbar.setRange(0, _content.length - 1);
|
||||
|
@ -2494,7 +2517,7 @@ class EditBox : EditWidgetBase {
|
|||
_caretPos.line = _content.length - 1;
|
||||
if (_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)
|
||||
visibleLines = 1;
|
||||
if (_caretPos.line < _firstVisibleLine) {
|
||||
|
|
|
@ -531,12 +531,16 @@ class TabHost : FrameLayout, TabHandler {
|
|||
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!TabHandler onTabChangedListener;
|
||||
|
||||
protected override void onTabChanged(string newActiveTabId, string previousTabId) {
|
||||
if (newActiveTabId !is null) {
|
||||
showChild(newActiveTabId, Visibility.Invisible, true);
|
||||
showChild(newActiveTabId, _hiddenTabsVisibility, true);
|
||||
}
|
||||
if (onTabChangedListener.assigned)
|
||||
onTabChangedListener(newActiveTabId, previousTabId);
|
||||
|
@ -671,6 +675,9 @@ class TabWidget : VerticalLayout, TabHandler, TabCloseHandler {
|
|||
_tabControl.renameTab(index, name);
|
||||
}
|
||||
|
||||
@property Visibility hiddenTabsVisibility() { return _tabHost.hiddenTabsVisibility; }
|
||||
@property void hiddenTabsVisibility(Visibility v) { _tabHost.hiddenTabsVisibility = v; }
|
||||
|
||||
/// select tab
|
||||
void selectTab(string ID, bool updateAccess = true) {
|
||||
_tabHost.selectTab(ID, updateAccess);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 249 B |
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<theme id="theme_default" fontSize="15"
|
||||
<theme id="theme_default"
|
||||
fontSize="14"
|
||||
fontFace="Verdana,Arial,DejaVu Sans"
|
||||
fontFamily="SansSerif"
|
||||
>
|
||||
|
@ -241,7 +242,7 @@
|
|||
backgroundColor="#D0D0D0"
|
||||
layoutWidth="FILL_PARENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
padding="4,4,4,4"
|
||||
padding="1,1,1,1"
|
||||
layoutWeight="0"
|
||||
/>
|
||||
<style id="DOCK_HOST"
|
||||
|
@ -300,19 +301,19 @@
|
|||
backgroundImageId="toolbar_background"
|
||||
layoutWidth="WRAP_CONTENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
margins="2,2,2,2"
|
||||
margins="1,1,1,1"
|
||||
/>
|
||||
<style id="TOOLBAR_BUTTON"
|
||||
backgroundImageId="toolbar_button_background"
|
||||
align="Center"
|
||||
margins="1,1,1,1"
|
||||
padding="4,4,4,4"
|
||||
padding="2,2,2,2"
|
||||
/>
|
||||
<style id="TOOLBAR_CONTROL"
|
||||
backgroundImageId="toolbar_control_background"
|
||||
align="Center"
|
||||
margins="1,1,1,1"
|
||||
padding="4,4,4,4"
|
||||
padding="2,2,2,2"
|
||||
/>
|
||||
<style id="TOOLBAR_SEPARATOR"
|
||||
align="Center"
|
||||
|
@ -321,7 +322,7 @@
|
|||
<style id="TREE_ITEM"
|
||||
padding="1,1,1,1"
|
||||
minWidth="100"
|
||||
minHeight="15"
|
||||
minHeight="14"
|
||||
layoutWidth="FILL_PARENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
fontSize="14">
|
||||
|
|
Loading…
Reference in New Issue