Skip to content

Commit

Permalink
gui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Apr 23, 2020
1 parent 2dd80de commit 2f87095
Show file tree
Hide file tree
Showing 16 changed files with 43,920 additions and 41,123 deletions.
2,641 changes: 2,210 additions & 431 deletions modular-psu-firmware.eez-project

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/eez/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ void action_edit() {
edit_mode::enter();
}

void action_set_focus() {
#if OPTION_ENCODER
setFocusCursor(getFoundWidgetAtDown().cursor, getFoundWidgetAtDown().widget->data);
#endif
}

void action_edit_no_focus() {
edit_mode::enter(-1, false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/eez/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void UINT32_value_to_text(const Value &value, char *text, int count) {
}

bool compare_FLOAT_value(const Value &a, const Value &b) {
return a.getUnit() == b.getUnit() && a.getFloat() == b.getFloat();
return a.getUnit() == b.getUnit() && a.getFloat() == b.getFloat() && a.getOptions() == b.getOptions();
}

void FLOAT_value_to_text(const Value &value, char *text, int count) {
Expand Down
48,794 changes: 24,635 additions & 24,159 deletions src/eez/gui/document_simulator.cpp

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions src/eez/gui/document_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,8 @@ enum ActionsEnum {
ACTION_ID_FILE_MANAGER_SELECT_LIST_VIEW = 220,
ACTION_ID_SHOW_SYS_SETTINGS_RAMP_AND_DELAY = 221,
ACTION_ID_CHANNEL_TOGGLE_RAMP_STATE = 222,
ACTION_ID_DLOG_VIEW_SELECT_LEGEND_VIEW_OPTION = 223
ACTION_ID_DLOG_VIEW_SELECT_LEGEND_VIEW_OPTION = 223,
ACTION_ID_SET_FOCUS = 224
};

void action_channel_toggle_output();
Expand Down Expand Up @@ -1304,21 +1305,23 @@ void action_file_manager_select_list_view();
void action_show_sys_settings_ramp_and_delay();
void action_channel_toggle_ramp_state();
void action_dlog_view_select_legend_view_option();
void action_set_focus();

extern ActionExecFunc g_actionExecFunctions[];

enum FontsEnum {
FONT_ID_NONE = 0,
FONT_ID_SHADOW = 1,
FONT_ID_OSWALD24 = 2,
FONT_ID_OSWALD17 = 3,
FONT_ID_OSWALD14 = 4,
FONT_ID_HEYDINGS14 = 5,
FONT_ID_ROBOTO_CONDENSED_REGULAR = 6,
FONT_ID_WEB_HOSTING_HUB24 = 7,
FONT_ID_OSWALD48 = 8,
FONT_ID_OSWALD20 = 9,
FONT_ID_OSWALD38 = 10
FONT_ID_OSWALD12 = 1,
FONT_ID_SHADOW = 2,
FONT_ID_OSWALD24 = 3,
FONT_ID_OSWALD17 = 4,
FONT_ID_OSWALD14 = 5,
FONT_ID_HEYDINGS14 = 6,
FONT_ID_ROBOTO_CONDENSED_REGULAR = 7,
FONT_ID_WEB_HOSTING_HUB24 = 8,
FONT_ID_OSWALD48 = 9,
FONT_ID_OSWALD20 = 10,
FONT_ID_OSWALD38 = 11
};

enum BitmapsEnum {
Expand Down Expand Up @@ -1582,12 +1585,12 @@ enum StylesEnum {
STYLE_ID_INLINE235 = 235,
STYLE_ID_INLINE236 = 236,
STYLE_ID_INLINE237 = 237,
STYLE_ID_INLINE238 = 238,
STYLE_ID_INLINE239 = 239,
STYLE_ID_INLINE240 = 240,
STYLE_ID_STATUS_LINE_SMALL_TITLE = 241,
STYLE_ID_EDIT_VALUE_S_CENTERED_STATUS_LINE = 242,
STYLE_ID_SCROLLBAR_TRACK = 243,
STYLE_ID_STATUS_LINE_SMALL_TITLE = 238,
STYLE_ID_EDIT_VALUE_S_CENTERED_STATUS_LINE = 239,
STYLE_ID_SCROLLBAR_TRACK = 240,
STYLE_ID_INLINE241 = 241,
STYLE_ID_INLINE242 = 242,
STYLE_ID_INLINE243 = 243,
STYLE_ID_INLINE244 = 244,
STYLE_ID_INLINE245 = 245,
STYLE_ID_INLINE246 = 246,
Expand Down Expand Up @@ -1891,4 +1894,4 @@ enum PagesEnum {
PAGE_ID_DEBUG_POWER_CHANNELS = 170
};

extern const uint8_t assets[437007];
extern const uint8_t assets[444605];
33,446 changes: 16,960 additions & 16,486 deletions src/eez/gui/document_stm32.cpp

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions src/eez/gui/document_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,8 @@ enum ActionsEnum {
ACTION_ID_FILE_MANAGER_SELECT_LIST_VIEW = 216,
ACTION_ID_SHOW_SYS_SETTINGS_RAMP_AND_DELAY = 217,
ACTION_ID_CHANNEL_TOGGLE_RAMP_STATE = 218,
ACTION_ID_DLOG_VIEW_SELECT_LEGEND_VIEW_OPTION = 219
ACTION_ID_DLOG_VIEW_SELECT_LEGEND_VIEW_OPTION = 219,
ACTION_ID_SET_FOCUS = 220
};

void action_channel_toggle_output();
Expand Down Expand Up @@ -1280,21 +1281,23 @@ void action_file_manager_select_list_view();
void action_show_sys_settings_ramp_and_delay();
void action_channel_toggle_ramp_state();
void action_dlog_view_select_legend_view_option();
void action_set_focus();

extern ActionExecFunc g_actionExecFunctions[];

enum FontsEnum {
FONT_ID_NONE = 0,
FONT_ID_SHADOW = 1,
FONT_ID_OSWALD24 = 2,
FONT_ID_OSWALD17 = 3,
FONT_ID_OSWALD14 = 4,
FONT_ID_HEYDINGS14 = 5,
FONT_ID_ROBOTO_CONDENSED_REGULAR = 6,
FONT_ID_WEB_HOSTING_HUB24 = 7,
FONT_ID_OSWALD48 = 8,
FONT_ID_OSWALD20 = 9,
FONT_ID_OSWALD38 = 10
FONT_ID_OSWALD12 = 1,
FONT_ID_SHADOW = 2,
FONT_ID_OSWALD24 = 3,
FONT_ID_OSWALD17 = 4,
FONT_ID_OSWALD14 = 5,
FONT_ID_HEYDINGS14 = 6,
FONT_ID_ROBOTO_CONDENSED_REGULAR = 7,
FONT_ID_WEB_HOSTING_HUB24 = 8,
FONT_ID_OSWALD48 = 9,
FONT_ID_OSWALD20 = 10,
FONT_ID_OSWALD38 = 11
};

enum BitmapsEnum {
Expand Down Expand Up @@ -1553,12 +1556,12 @@ enum StylesEnum {
STYLE_ID_INLINE235 = 235,
STYLE_ID_INLINE236 = 236,
STYLE_ID_INLINE237 = 237,
STYLE_ID_INLINE238 = 238,
STYLE_ID_INLINE239 = 239,
STYLE_ID_INLINE240 = 240,
STYLE_ID_STATUS_LINE_SMALL_TITLE = 241,
STYLE_ID_EDIT_VALUE_S_CENTERED_STATUS_LINE = 242,
STYLE_ID_SCROLLBAR_TRACK = 243,
STYLE_ID_STATUS_LINE_SMALL_TITLE = 238,
STYLE_ID_EDIT_VALUE_S_CENTERED_STATUS_LINE = 239,
STYLE_ID_SCROLLBAR_TRACK = 240,
STYLE_ID_INLINE241 = 241,
STYLE_ID_INLINE242 = 242,
STYLE_ID_INLINE243 = 243,
STYLE_ID_INLINE244 = 244,
STYLE_ID_INLINE245 = 245,
STYLE_ID_INLINE246 = 246,
Expand Down Expand Up @@ -1842,4 +1845,4 @@ enum PagesEnum {
PAGE_ID_DEBUG_POWER_CHANNELS = 164
};

extern const uint8_t assets[301463];
extern const uint8_t assets[309033];
27 changes: 26 additions & 1 deletion src/eez/gui/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ font::Font styleGetFont(const Style *style) {
return font::Font(getFontData(style->font));
}

bool styleGetSmallerFont(font::Font &font) {
if (font.fontData == getFontData(FONT_ID_OSWALD48)) {
font.fontData = getFontData(FONT_ID_OSWALD38);
} else if (font.fontData == getFontData(FONT_ID_OSWALD38)) {
font.fontData = getFontData(FONT_ID_OSWALD24);
} else if (font.fontData == getFontData(FONT_ID_OSWALD24)) {
font.fontData = getFontData(FONT_ID_OSWALD20);
} else if (font.fontData == getFontData(FONT_ID_OSWALD20)) {
font.fontData = getFontData(FONT_ID_OSWALD17);
} else if (font.fontData == getFontData(FONT_ID_OSWALD17)) {
font.fontData = getFontData(FONT_ID_OSWALD14);
} else if (font.fontData == getFontData(FONT_ID_OSWALD14)) {
font.fontData = getFontData(FONT_ID_OSWALD12);
} else if (font.fontData == getFontData(FONT_ID_OSWALD12)) {
font.fontData = getFontData(FONT_ID_ROBOTO_CONDENSED_REGULAR);
} else {
return false;
}
return true;
}

bool styleIsBlink(const Style *style) {
return style->flags & STYLE_FLAGS_BLINK ? true : false;
}
Expand All @@ -64,7 +85,8 @@ bool styleIsBlink(const Style *style) {
void drawText(const char *text, int textLength, int x, int y, int w, int h, const Style *style,
bool active, bool blink, bool ignoreLuminocity,
uint16_t *overrideColor, uint16_t *overrideBackgroundColor,
uint16_t *overrideActiveColor, uint16_t *overrideActiveBackgroundColor) {
uint16_t *overrideActiveColor, uint16_t *overrideActiveBackgroundColor,
bool useSmallerFontIfDoesNotFit) {
int x1 = x;
int y1 = y;
int x2 = x + w - 1;
Expand All @@ -88,6 +110,9 @@ void drawText(const char *text, int textLength, int x, int y, int w, int h, cons
font::Font font = styleGetFont(style);

int width = display::measureStr(text, textLength, font, 0);
while (useSmallerFontIfDoesNotFit && width > x2 - x1 + 1 && styleGetSmallerFont(font)) {
width = display::measureStr(text, textLength, font, 0);
}
int height = font.getHeight();

bool horizontallyFits = width <= (x2 - x1 + 1);
Expand Down
2 changes: 1 addition & 1 deletion src/eez/gui/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace gui {
font::Font styleGetFont(const Style *style);
bool styleIsBlink(const Style *style);

void drawText(const char *text, int textLength, int x, int y, int w, int h, const Style *style, bool active, bool blink, bool ignoreLuminocity, uint16_t *overrideColor, uint16_t *overrideBackgroundColor, uint16_t *overrideActiveColor, uint16_t *overrideActiveBackgroundColor);
void drawText(const char *text, int textLength, int x, int y, int w, int h, const Style *style, bool active, bool blink, bool ignoreLuminocity, uint16_t *overrideColor, uint16_t *overrideBackgroundColor, uint16_t *overrideActiveColor, uint16_t *overrideActiveBackgroundColor, bool useSmallerFontIfDoesNotFit = false);
void drawMultilineText(const char *text, int x, int y, int w, int h, const Style *style, bool active, int firstLineIndent, int hangingIndent);
int measureMultilineText(const char *text, int x, int y, int w, int h, const Style *style, int firstLineIndent, int hangingIndent);
void drawBitmap(Image *image, int x, int y, int w, int h, const Style *style, bool active);
Expand Down
6 changes: 6 additions & 0 deletions src/eez/gui/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Overlay *getOverlay(const WidgetCursor &widgetCursor) {
void getOverlayOffset(WidgetCursor &widgetCursor, int &xOffset, int &yOffset) {
Overlay *overlay = getOverlay(widgetCursor);
if (overlay) {
if (!overlay->moved && overlay->state) {
overlay->xOffset = overlay->x - widgetCursor.widget->x;
overlay->yOffset = overlay->y - widgetCursor.widget->y;
}

int x = widgetCursor.x + overlay->xOffset;
if (x < widgetCursor.appContext->rect.x) {
x = widgetCursor.appContext->rect.x;
Expand Down Expand Up @@ -81,6 +86,7 @@ void dragOverlay(Event &touchEvent) {
overlay->xOffsetOnTouchDown = overlay->xOffset;
overlay->yOffsetOnTouchDown = overlay->yOffset;
} else if (touchEvent.type == EVENT_TYPE_TOUCH_MOVE) {
overlay->moved = true;
overlay->xOffset = overlay->xOffsetOnTouchDown + touchEvent.x - overlay->xOnTouchDown;
overlay->yOffset = overlay->yOffsetOnTouchDown + touchEvent.y - overlay->yOnTouchDown;
}
Expand Down
4 changes: 4 additions & 0 deletions src/eez/gui/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ struct WidgetOverride {
};

struct Overlay {
int x;
int y;
int width;
int height;

int state; // if 0 then overlay is not visible
WidgetOverride *widgetOverrides;

bool moved = false;

int xOffset;
int yOffset;

Expand Down
20 changes: 16 additions & 4 deletions src/eez/gui/widgets/display_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ EnumFunctionType DISPLAY_DATA_enum = nullptr;

int findStartOfFraction(char *text) {
int i;
for (i = 0; text[i] && (text[i] == '-' || (text[i] >= '0' && text[i] <= '9')); i++);
for (i = 0; text[i] && (text[i] == '<' || text[i] == ' ' || text[i] == '-' || (text[i] >= '0' && text[i] <= '9')); i++);
return i;
}

int findStartOfUnit(char *text, int i) {
for (i = 0; text[i] && (text[i] == '-' || (text[i] >= '0' && text[i] <= '9') || text[i] == '.'); i++);
for (i = 0; text[i] && (text[i] == '<' || text[i] == ' ' || text[i] == '-' || (text[i] >= '0' && text[i] <= '9') || text[i] == '.'); i++);
return i;
}

Expand Down Expand Up @@ -143,10 +143,22 @@ DrawFunctionType DISPLAY_DATA_draw = [](const WidgetCursor &widgetCursor) {
text[i] = 0;
}

drawText(start, -1, widgetCursor.x, widgetCursor.y, (int)widget->w, (int)widget->h,
// trim left
while (*start && *start == ' ') {
start++;
}

// trim right
int length = strlen(start);
if (length > 0 && start[length - 1] == ' ') {
length--;
}

drawText(start, length, widgetCursor.x, widgetCursor.y, (int)widget->w, (int)widget->h,
style, widgetCursor.currentState->flags.active,
widgetCursor.currentState->flags.blinking, false,
&currentState->color, &currentState->backgroundColor, &currentState->activeColor, &currentState->activeBackgroundColor);
&currentState->color, &currentState->backgroundColor, &currentState->activeColor, &currentState->activeBackgroundColor,
widgetCursor.currentState->data.getType() == VALUE_TYPE_FLOAT);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/eez/gui/widgets/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ DrawFunctionType TEXT_draw = [](const WidgetCursor &widgetCursor) {
drawText(text, -1, widgetCursor.x, widgetCursor.y, (int)widget->w, (int)widget->h,
style, widgetCursor.currentState->flags.active,
widgetCursor.currentState->flags.blinking,
ignoreLuminosity, &overrideColor, &overrideBackgroundColor, &overrideActiveColor, nullptr);
ignoreLuminosity, &overrideColor, &overrideBackgroundColor, &overrideActiveColor, nullptr,
widgetCursor.currentState->data.getType() == VALUE_TYPE_FLOAT);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/eez/modules/dcm220/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,7 @@ struct Channel : ChannelInterface {

void setDacCurrentFloat(int subchannelIndex, float value) {
#if defined(EEZ_PLATFORM_STM32)
psu::Channel &channel = psu::Channel::getBySlotIndex(slotIndex, subchannelIndex);
value = remap(value, channel.params.I_MIN, (float)DAC_MIN, /*channel.params.I_MAX*/ I_MAX_FOR_REMAP, (float)DAC_MAX);
value = remap(value, /*channel.params.I_MIN*/ 0, (float)DAC_MIN, /*channel.params.I_MAX*/ I_MAX_FOR_REMAP, (float)DAC_MAX);
iSet[subchannelIndex] = (uint16_t)clamp(round(value), DAC_MIN, DAC_MAX);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/eez/modules/dcpX05/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct Channel : ChannelInterface {
params.I_DEF = 0.0f;
params.I_MAX = 5.0f;

params.I_MON_MIN = 0.0f;
params.I_MON_MIN = -5.0f;

params.I_MIN_STEP = 0.01f;
params.I_DEF_STEP = 0.01f;
Expand Down
9 changes: 9 additions & 0 deletions src/eez/modules/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4928,6 +4928,9 @@ void data_overlay(DataOperationEnum operation, Cursor cursor, Value &value) {
widgetOverrides[SCRIPT_INFO_WIDGET].isVisible = false;
overlay.height -= scriptInfoWidget->h;
}

overlay.x = 480 - overlay.width;
overlay.y = 240 - overlay.height;
}
}

Expand Down Expand Up @@ -5318,6 +5321,9 @@ void data_dlog_multiple_values_overlay(DataOperationEnum operation, Cursor curso

overlay.width = widgetCursor.widget->w;
overlay.height = widgetOverrides[LABELS_CONTAINER_WIDGET].h + widgetOverrides[DLOG_VALUES_LIST_WIDGET].h;

overlay.x = 40;
overlay.y = 8;
}
}

Expand All @@ -5338,6 +5344,9 @@ void data_dlog_single_value_overlay(DataOperationEnum operation, Cursor cursor,
overlay.width = widgetCursor.widget->w;
overlay.height = widgetCursor.widget->h;

overlay.x = 40;
overlay.y = 8;

value = Value(&overlay, VALUE_TYPE_POINTER);
}
}
Expand Down

0 comments on commit 2f87095

Please sign in to comment.