I'm building a model to display a UI using SDL2 on Rebol3.
So far, I'd like to do something like this:
gui: copy []
append gui context [style: 'h1 at: 10x30 text: "Hello World!" font: arial]
but should I use Object! when I only need a Block! like this:
gui: copy []
append/only gui reduce/no-set [style: 'h1 at: 10x30 text: "Hello World!" font: arial]
What's your opinion on this? What is best to use? Any other suggestion?
Why not dialect?
[h1 10x30 "Hello World!" font arial]
Internally I would store it as an object!, because it provides you with an easier manipulation.
Related
Background
I'm using tiptap-vuetify to implement a message/chat UI where users see an editable Tiptap instance for creating new messages as well as several uneditable Tiptap instances (one for each already-sent message in the thread the user is viewing).
I have the editable instance output data in JSON format, which I store in my database in a JSONB field.
Problem
When I load the JSON for sent messages from the database, only plaintext messages show up; if I applied any kind of styling (bold, italics, lists, etc.), nothing at all shows up.
The code I'm using for the uneditable Tiptap instances is this:
<tiptap-vuetify
v-model="message.content"
:editor-properties="{ editable: false }"
output-format="json"
/>
Here's a screenshot of the message object (and message.content) for the "bold asdf" example above:
When i was looking in the documentation -> Get started
I see that the content is HTML.
As it usually is inside any tiptap.
Your content data is an object with alot of nested data. I don't think the plugin/component can handle that type of format.
Try save your data as HTML to your .json and there for also fetch the data as HTML from your .json.
Example:
{
messages: [
{
"id": 1,
"content": "<p>foo bar</p>"
},
{
"id": 2,
"content": "<p>hello world</p>"
},
]
}
(New to answer questions on stackoverflow)
I figured out the fix:
I didn't realize I needed to include the :extensions prop for all of the HTML features I wanted to use (bold, italic, etc.) in the editor that would render the HTML. I thought those extensions were just used to add the toolbar buttons, but they are also used to render the JSON that those buttons produce.
To then hide the toolbar, I just used the example toolbar-slot code from the readme, and the toolbar was gone.
Here's the working code:
<tiptap-vuetify
v-model="message.content"
:extensions="extensions"
:editor-properties="{ editable: false }"
>
<template #toolbar="{ buttons }">
<pre>{{ buttons }}</pre>
</template>
</tiptap-vuetify>
Pharo 9, Spec 2 -- I have a Spec 2 presenter with a text widget:
initializePresenters
text := self newText.
super initializePresenters
As I understand its type is SpTextPresenter. How to change the font of this text? Font face, size of the all shown text in this widget... For example, to "Courier New", 9.
EDIT 1:
Also I tried:
text addStyle: { SpStyleSTONReader fromString:
'
Font {
#name: "Source Sans Pro",
#size: 12,
#bold: false,
#italic: true
}' }.
but it does not work, the error is: Improper store into indexable object.
EDIT 2:
Also I found this documentation. It seems that the scenario must be:
Read styles as STON
Set styles somwhere (where?) for the all application. They are described under its names in the STON so they can be referred under its names in the application.
Call addStyle: 'the-name' so the widget with a name the-name will refer own styles from the loaded STON.
The problem is in 2. - I have not application, just one presenter which I open with openWithSpec.
I didn't notice this 'till now.
Spec "styles" cannot be added directly to the component but they need to be part of a stylesheet.
Stylesheets are defined in your application (in particular in your application configuration).
You can take a look at StPharoApplication>>resetConfiguration, StPharoMorphicConfiguration>>styleSheet and StPharoMorphicConfiguration>>styleSheetCommon as examples (you will also see there than using STON to declare your styles is just a convenience way, not mandatory).
Here a simplified version of what you will find there:
StPharoApplication >> resetConfiguration
self useBackend: #Morphic with: StPharoMorphicConfiguration new
StPharoMorphicConfiguration >> styleSheet
^ SpStyle defaultStyleSheet, self styleSheetCommon
StPharoMorphicConfiguration >> styleSheetCommon
"Just an example on how to build styles programatically ;)"
^ SpStyleSTONReader fromString: '
.application [
.searchInputField [
Font { #size: 12 }
]
]
'
Then you can add the style to your component:
text addStyle: 'searchInputField'
When developing a QML application I think it can sometime be useful if I was able to set some setting to outline all visual elements boundaries. For instance a control in Qt Quick Controls 2.x might consist of several parts like background, contentItem, indicators etc. When tweaking on the size of these I would like to see the boundaries of each of these parts.
Is there any functionality like this in Qt/QML?
Three years later, and folks (specifically: me) are still doing web searches about this :)
Just like commenter #DuKes0mE suggested, I have "made do" by adding borders to things on-the-fly and then removing them from the final code.
Like the OP, I am now tired of doing that.
A tactic I arrived at recently is to add a DebugRectangle.qml custom element to my project:
import QtQuick 2.12
Rectangle {
property var toFill: parent // instantiation site "can" (optionally) override
property color customColor: 'yellow' // instantiation site "can" (optionally) override
property int customThickness: 1 // instantiation site "can" (optionally) override
anchors.fill: toFill
z: 200
color: 'transparent'
border.color: customColor
border.width: customThickness
}
Then I can add it to existing elements like so, to debug them:
Label {
text: 'Lorem ipsum dolor sit amet'
}
Label {
text: 'quis nostrud exercitation'
DebugRectangle {} // Adds "debug border" to this Label
}
And when I am finished, I can even leave the nested DebugRectangle in the code, but toggle its visibility like so:
Label {
text: 'quis nostrud exercitation'
DebugRectangle {
visible: false
}
}
Complete sample project shared on GitHub.
There's a tool called GammaRay which (amongst other things) allows investigating QtQuick 2 applications, see:
http://doc.qt.io/GammaRay/gammaray-qtquick2-inspector.html
Setup instructions are here:
https://github.com/KDAB/GammaRay
If you're running Linux, it is quite likely your distribution already ships a GammaRay package.
I am building a GUI app using Smalltalk Pharo version 4.0. I am using the following UITheme builder code to create labels since Morphic TextMorphs/LabelMorphs do not implement Observer pattern to update them dynamically on GUI when their value changes through program logic:
UITheme builder
newLabelFor: self
getLabel: #labelValue
getEnabled: nil
I need to change the fonts and text color for the above label. I tried using the following and other similar options but it does not work for me:
newLabelGroup: labelsAndControls font: aFont labelColor: aColor
Is there any way to achieve this?
You can send the messages #color: and #font: to the object returned by #newLabelFor:getLabel:getEnabled. For example the code below creates a big red text:
(UITheme builder
newLabelFor: 'Text'
getLabel: #asString
getEnabled: nil)
color: Color red;
font: (LogicalFont familyName: 'Source Sans Pro' pointSize: 30);
openInWorld
Depending on your image and setup this will not work with all fonts.
On the WebStorm for example and I believe in any Intellij product.
You can easily refeactor the code and style it as you like from the setting 'Code Style'.
But, the styling and refactoring actually change the binaries of the file.
for example if you decide you want new line after { it will add \n in each place.
I want to know if it possible to only visually display those different to the coder.
If I'm coding like this:
var func = function()
{
// Blah
}
And another programmer on the team code like this:
var func = function() {
// Blah
}
and also if I code like this:
var text = "";
and the other like this:
var text = '';
The thing is that I don't really care how it would actually be like in the saved file. I only care how it would be displayed to the programmer.
It is possible to achieve this ?
Simple answer: No. That's because coding rules exist and besides things like changed binaries you have the problem of version control as well. which style of your code should be versioned? While VCS' are able to deal with different line endings, what you ask for isn't supported anywhere.