Subversion Repositories Kolibri OS

Rev

Rev 3478 | Blame | Last modification | View Log | Download | RSS feed

  1. macro use_progressbar
  2. {
  3. pb equ [esp + 4 + 8*4]
  4. align 16
  5. progressbar_draw:
  6.         pushad
  7. ; draw frame
  8.         mov    eax, pb
  9.         mov    edx, [eax + PB_FRAME_COLOR]
  10.         mov    ebx, [eax + PB_LEFT]
  11.         mov    edi, [eax + PB_TOP]
  12.         mov    ebp, [eax + PB_WIDTH]
  13.         mov    esi, [eax + PB_HEIGHT]
  14.         add    ebp, ebx
  15.         add    esi, edi
  16.         dec    ebp
  17.         dec    esi
  18.         mov    eax, 38
  19.         shl    ebx, 16
  20.         mov    bx, bp
  21.         shrd   ecx, edi, 16
  22.         mov    cx, di
  23.         int    64
  24.         shrd   ecx, esi, 16
  25.         mov    cx, si
  26.         int    64
  27.         shld   esi, ebx, 16
  28.         mov    bx, si
  29.         shrd   ecx, edi, 16
  30.         int    64
  31.         shrd   ebx, ebp, 16
  32.         mov    bx, bp
  33.         int    64
  34. ; if min > max then .skip
  35.         mov    eax, pb
  36.         mov    edx, [eax + PB_MAX]
  37.         mov    ecx, [eax + PB_MIN]
  38.         cmp    ecx, edx
  39.         ; jg     .skip
  40.         jne    .min_no_eq_max
  41.         dec    edx
  42. .min_no_eq_max:
  43. ; draw all progress rectangle
  44.         call   get_progress_width
  45.         mov    edi, eax
  46.         mov    eax, pb
  47.         mov    ebx, [eax + PB_LEFT]
  48.         mov    ecx, [eax + PB_TOP]
  49.         mov    edx, [eax + PB_PROGRESS_COLOR]
  50.         inc    ebx
  51.         inc    ecx
  52.         shl    ebx, 16
  53.         shl    ecx, 16
  54.         add    ebx, edi
  55.         add    ecx, [eax + PB_HEIGHT]
  56.         dec    ecx
  57.         mov    eax, 13
  58.         dec    ecx
  59.         int    64
  60. ; draw last part of non-progress rectangle
  61. ; edi = pW, esi = W - 2
  62.         sub    esi, edi ; width
  63.         shr    ebx, 16
  64.         add    ebx, edi
  65.         shl    ebx, 16
  66.         add    ebx, esi
  67.         mov    esi, pb
  68.         mov    edx, [esi + PB_BACK_COLOR]
  69.         int    64
  70. ; .skip:
  71.         popad
  72.         ret    4
  73.  
  74. align 16
  75. get_progress_width:
  76. ; pW = (W-2)(value - min) / (max - min)
  77.         mov    esi, [eax + PB_WIDTH]
  78.         mov    eax, [eax + PB_VALUE]
  79.         dec    esi
  80.         sub    eax, ecx
  81.         dec    esi
  82.         imul   eax, esi
  83.         neg    ecx
  84.         add    ecx, edx
  85.         xor    edx, edx
  86.         div    ecx
  87.         ret
  88.  
  89. align 16
  90. progressbar_progress:
  91.         pushad
  92. ; if min > max then .skip
  93.         mov    eax, pb
  94.         mov    edx, [eax + PB_MAX]
  95.         mov    ecx, [eax + PB_MIN]
  96.         cmp    ecx, edx
  97.         ; jg     .skip
  98.         jne    .min_no_eq_max1
  99.         dec    edx
  100. .min_no_eq_max1:
  101.         call   get_progress_width
  102.         mov    edi, eax
  103. ; increase value
  104.         mov    eax, pb
  105.         mov    ecx, [eax + PB_VALUE]
  106.         mov    edx, [eax + PB_MAX]
  107.         inc    ecx
  108. ; if value > max then value = max
  109.         cmp    ecx, edx
  110.         jng    .next
  111.         mov    ecx, edx
  112. .next:
  113.         mov    [eax + PB_VALUE], ecx
  114. ; draw new part of progress rectangle
  115.         mov    eax, pb
  116.         mov    ecx, [eax + PB_MIN]
  117.         cmp    ecx, edx
  118.         jne    .min_no_eq_max2
  119.         dec    edx
  120. .min_no_eq_max2:
  121.         call   get_progress_width
  122.         mov    esi, eax
  123. ; edi = last pW, esi = new pW
  124.         mov    eax, pb
  125.         mov    ebx, [eax + PB_LEFT]
  126.         mov    ecx, [eax + PB_TOP]
  127.         mov    edx, [eax + PB_PROGRESS_COLOR]
  128.         inc    ebx
  129.         inc    ecx
  130.         add    ebx, edi
  131.         shl    ecx, 16
  132.         shl    ebx, 16
  133.         add    ecx, [eax + PB_HEIGHT]
  134.         add    ebx, esi
  135.         dec    ecx
  136.         sub    ebx, edi
  137.         mov    eax, 13
  138.         dec    ecx
  139.         int    64
  140. ; .skip:
  141.         popad
  142.         ret    4
  143. restore pb
  144. }