Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tinyui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
};

static constexpr char *SeverityToken[] = {
"",

Check warning on line 45 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGsc&open=AZzym1sJHwkPxaWmgGsc&pullRequest=21
"*TRACE*",

Check warning on line 46 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGsd&open=AZzym1sJHwkPxaWmgGsd&pullRequest=21
"*DEBUG*",

Check warning on line 47 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGse&open=AZzym1sJHwkPxaWmgGse&pullRequest=21
"*INFO* ",

Check warning on line 48 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGsf&open=AZzym1sJHwkPxaWmgGsf&pullRequest=21
"*WARN* ",

Check warning on line 49 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGsg&open=AZzym1sJHwkPxaWmgGsg&pullRequest=21
"*ERROR*"

Check warning on line 50 in src/tinyui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This string literal is assigned to a mutable pointer. Change the type of the array's elements to "char const *" or copy the literal if mutability is needed.

See more on https://sonarcloud.io/project/issues?id=kimkulling_tiny_ui&issues=AZzym1sJHwkPxaWmgGsh&open=AZzym1sJHwkPxaWmgGsh&pullRequest=21
};

void log_message(LogSeverity severity, const char *message) {
Expand All @@ -57,7 +57,7 @@

Context *gCtx = nullptr;

Context *Context::create(const char *title, Style &style) {
Context *Context::create(const char *title, const Style &style) {
Context *ctx = new Context;
ctx->mLogger = log_message;
ctx->mAppTitle = title;
Expand All @@ -71,7 +71,7 @@
delete ctx;
}

bool TinyUi::createContext(const char *title, Style &style) {
bool TinyUi::createContext(const char *title, const Style &style) {
if (gCtx != nullptr) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/tinyui.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ struct CallbackI {
/// @param callbackFunc The callback function.
/// @param instance The instance to use.
/// @param eventType The event type to use.
CallbackI(funcCallback callbackFunc, void *instance, size_t eventType = Events::MouseButtonDownEvent) :
CallbackI(funcCallback callbackFunc, void *instance, size_t eventType = Events::MouseButtonDownEvent) :
mfuncCallback{ nullptr }, mInstance(instance) {
clear();
mfuncCallback[eventType] = callbackFunc;
Expand Down Expand Up @@ -401,7 +401,7 @@ struct Context {
/// @param title The title of the context.
/// @param style The style to use.
/// @return The created context.
static Context *create(const char *title, Style &style);
static Context *create(const char *title, const Style &style);

/// @brief Will destroy a valid tinyui context.
/// @param ctx The context to destroy.
Expand All @@ -421,7 +421,7 @@ struct TinyUi {
/// @param title The app title.
/// @param style The style to use.
/// @return true if successful.
static bool createContext(const char *title, Style &style);
static bool createContext(const char *title, const Style &style);

/// @brief Will destroy the context.
/// @return true if successful.
Expand Down
11 changes: 10 additions & 1 deletion src/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ ret_code Widgets::imageBox(Id id, Id parentId, const char* image, const Rect& re
if (ctx.mRoot == nullptr) {
return InvalidRenderHandle;
}
Widget *child = createWidget(ctx, id, parentId, rect, WidgetType::Box);
Widget *child = createWidget(ctx, id, parentId, rect, WidgetType::ImageBox);
if (child == nullptr) {
return ErrorCode;
}
Expand Down Expand Up @@ -568,6 +568,15 @@ static void render(Context &ctx, Widget *currentWidget) {
Renderer::drawRect(ctx, r.top.x, r.top.y, r.width, r.height, currentWidget->mFilledRect, ctx.mStyle.mBorder);
}
break;

case WidgetType::ImageBox:
{
Renderer::drawRect(ctx, r.top.x, r.top.y, r.width, r.height, currentWidget->mFilledRect, ctx.mStyle.mBorder);
if (currentWidget->mImage != nullptr) {
Renderer::drawImage(ctx, r.top.x, r.top.y, r.width, r.height, currentWidget->mImage);
}
}
break;
}

for (auto &child : currentWidget->mChildren) {
Expand Down
5 changes: 3 additions & 2 deletions src/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ enum class WidgetType {
Container = 0, ///< A container widget
Button, ///< A button widget
Label, ///< A label widget
InputField, ///<
InputField, ///< An input field widget
Panel, ///< A panel widget
Box, ///< A box widget
TreeView, ///< A treeeview widget
ImageBox, ///< An image box widget
TreeView, ///< A treeview widget
ProgressBar, ///< A status bar widget
Count ///< The number of widgets
};
Expand Down
Loading