summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkScroll.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-04-28 12:52:43 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-04-28 12:52:43 (GMT)
commitfaf3d3197da965a56835db30b149ef85ce2384f1 (patch)
tree5f96923234c06f80f20f5a122e3d1b89b3fd1621 /generic/ttk/ttkScroll.c
parenta45cd9e5e3fc6da137e7a23ebd4b507b3905c142 (diff)
downloadtk-faf3d3197da965a56835db30b149ef85ce2384f1.zip
tk-faf3d3197da965a56835db30b149ef85ce2384f1.tar.gz
tk-faf3d3197da965a56835db30b149ef85ce2384f1.tar.bz2
Factorize the code a bit, and avoid calling the layoutProc twice when calling xview moveto|units|pages.
Diffstat (limited to 'generic/ttk/ttkScroll.c')
-rw-r--r--generic/ttk/ttkScroll.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index 84fbff2..47db6ac 100644
--- a/generic/ttk/ttkScroll.c
+++ b/generic/ttk/ttkScroll.c
@@ -181,6 +181,19 @@ void TtkScrollbarUpdateRequired(ScrollHandle h)
h->flags |= SCROLL_UPDATE_REQUIRED;
}
+/* TtkUpdateScrollInfo --
+ * Call the layoutProc to update the scroll info first, last, and total.
+ * Do it only if needed, that is when a redisplay is pending (which
+ * indicates scroll info are possibly out of date).
+ */
+
+void TtkUpdateScrollInfo(ScrollHandle h)
+{
+ if (h->corePtr->flags & REDISPLAY_PENDING) {
+ h->corePtr->widgetSpec->layoutProc(h->corePtr);
+ }
+}
+
/* TtkScrollviewCommand --
* Widget [xy]view command implementation.
*
@@ -193,19 +206,13 @@ int TtkScrollviewCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle h)
{
Scrollable *s = h->scrollPtr;
- int newFirst = s->first;
+ int newFirst;
+
+ TtkUpdateScrollInfo(h);
+ newFirst = s->first;
if (objc == 2) {
Tcl_Obj *result[2];
-
- /*
- * Update the scroll info (first, last, total) if needed.
- */
-
- if (h->corePtr->flags & REDISPLAY_PENDING) {
- h->corePtr->widgetSpec->layoutProc(h->corePtr);
- }
-
result[0] = Tcl_NewDoubleObj((double)s->first / s->total);
result[1] = Tcl_NewDoubleObj((double)s->last / s->total);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
@@ -218,14 +225,6 @@ int TtkScrollviewCommand(
double fraction;
int count;
- /*
- * Update the scroll info (first, last, total) if needed.
- */
-
- if (h->corePtr->flags & REDISPLAY_PENDING) {
- h->corePtr->widgetSpec->layoutProc(h->corePtr);
- }
-
switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count)) {
case TK_SCROLL_ERROR:
return TCL_ERROR;
@@ -243,21 +242,17 @@ int TtkScrollviewCommand(
}
}
- TtkScrollTo(h, newFirst);
+ TtkScrollTo(h, newFirst, 0);
return TCL_OK;
}
-void TtkScrollTo(ScrollHandle h, int newFirst)
+void TtkScrollTo(ScrollHandle h, int newFirst, int updateScrollInfo)
{
Scrollable *s = h->scrollPtr;
- /*
- * Update the scroll info (first, last, total) if needed.
- */
-
- if (h->corePtr->flags & REDISPLAY_PENDING) {
- h->corePtr->widgetSpec->layoutProc(h->corePtr);
+ if (updateScrollInfo) {
+ TtkUpdateScrollInfo(h);
}
if (newFirst >= s->total)