[Bf-blender-cvs] [8bd0bde012d] master: UI: Align Spreadsheet Reals and Integers to Right

Harley Acheson noreply at git.blender.org
Fri Apr 2 18:04:31 CEST 2021


Commit: 8bd0bde012d6924b2610cdeffa817def56844408
Author: Harley Acheson
Date:   Fri Apr 2 09:03:36 2021 -0700
Branches: master
https://developer.blender.org/rB8bd0bde012d6924b2610cdeffa817def56844408

UI: Align Spreadsheet Reals and Integers to Right

Aligning spreadsheet cell numbers to the right to aid readability.

Differential Revision: https://developer.blender.org/D10871

Reviewed by Hans Goudey

===================================================================

M	source/blender/editors/space_spreadsheet/spreadsheet_column_layout.cc

===================================================================

diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column_layout.cc
index 396767e96d9..57d329fa710 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_column_layout.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_column_layout.cc
@@ -121,42 +121,48 @@ class ColumnLayoutDrawer : public SpreadsheetDrawer {
     if (cell_value.value_int.has_value()) {
       const int value = *cell_value.value_int;
       const std::string value_str = std::to_string(value);
-      uiDefIconTextBut(params.block,
-                       UI_BTYPE_LABEL,
-                       0,
-                       ICON_NONE,
-                       value_str.c_str(),
-                       params.xmin,
-                       params.ymin,
-                       params.width,
-                       params.height,
-                       nullptr,
-                       0,
-                       0,
-                       0,
-                       0,
-                       nullptr);
+      uiBut *but = uiDefIconTextBut(params.block,
+                                    UI_BTYPE_LABEL,
+                                    0,
+                                    ICON_NONE,
+                                    value_str.c_str(),
+                                    params.xmin,
+                                    params.ymin,
+                                    params.width,
+                                    params.height,
+                                    nullptr,
+                                    0,
+                                    0,
+                                    0,
+                                    0,
+                                    nullptr);
+      /* Right-align Integers. */
+      UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
+      UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
     }
     else if (cell_value.value_float.has_value()) {
       const float value = *cell_value.value_float;
       std::stringstream ss;
       ss << std::fixed << std::setprecision(3) << value;
       const std::string value_str = ss.str();
-      uiDefIconTextBut(params.block,
-                       UI_BTYPE_LABEL,
-                       0,
-                       ICON_NONE,
-                       value_str.c_str(),
-                       params.xmin,
-                       params.ymin,
-                       params.width,
-                       params.height,
-                       nullptr,
-                       0,
-                       0,
-                       0,
-                       0,
-                       nullptr);
+      uiBut *but = uiDefIconTextBut(params.block,
+                                    UI_BTYPE_LABEL,
+                                    0,
+                                    ICON_NONE,
+                                    value_str.c_str(),
+                                    params.xmin,
+                                    params.ymin,
+                                    params.width,
+                                    params.height,
+                                    nullptr,
+                                    0,
+                                    0,
+                                    0,
+                                    0,
+                                    nullptr);
+      /* Right-align Floats. */
+      UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
+      UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
     }
     else if (cell_value.value_bool.has_value()) {
       const bool value = *cell_value.value_bool;



More information about the Bf-blender-cvs mailing list