/* * Part of LaGUI demonstration programs * Copyright (C) 2022-2023 Wu Yiming * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "la_5.h" #define SHOW_FLAG(what) \ laShowSeparator(uil,c); laShowLabel(uil,cl, #what ,0,0)->Flags|=LA_TEXT_MONO; #define BR b=laBeginRow(uil,cr,0,0); #define ER laEndRow(uil,b); void Widgets(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){ laColumn* c=laFirstColumn(uil); laColumn* cl,*cr;laSplitColumn(uil,c,0.3);cl=laLeftColumn(c,0);cr=laRightColumn(c,0); laUiItem* b; laShowColumnAdjuster(uil,c); laShowLabel(uil,cl,"UI Flags",0,0); laShowLabel(uil,cr,"Description",0,0); SHOW_FLAG(LA_UI_FLAGS_EXPAND); laShowLabel(uil,cr,"Enum properties are shown with a menu.",0,0); BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample"); ER laShowLabel(uil,cr,"You can expand the enum selections by using this flag.",0,0); BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_EXPAND; ER SHOW_FLAG(LA_UI_FLAGS_TRANSPOSE); laShowLabel(uil,cr,"And you can also make the expansion vertical.",0,0); laShowLabel(uil,cr,"This also applies to array values.",0,0); BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND; ER SHOW_FLAG(LA_UI_FLAGS_ICON); laShowLabel(uil,cr,"Buttons/Selectors typically show an icon and a name.",0,0); BR laShowItem(uil,cr,0,"LA_pure_yes_no"); ER laShowLabel(uil,cr,"You could choose to only show icons.",0,0); BR laShowItem(uil,cr,0,"LA_pure_yes_no")->Flags|=LA_UI_FLAGS_ICON; ER SHOW_FLAG(LA_UI_FLAGS_NO_DECAL); laShowLabel(uil,cr,"This stops the UI from drawing background box.",0,0); laShowLabel(uil,cr,"The UI will still accept user inputs.",0,0); BR laShowItem(uil,cr,0,"la.user_preferences.interface_size"); laShowItem(uil,cr,0,"la.user_preferences.interface_size")->Flags|=LA_UI_FLAGS_NO_DECAL; ER BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample"); laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_NO_DECAL; ER SHOW_FLAG(LA_UI_FLAGS_NO_EVENT); laShowLabel(uil,cr,"This stops the UI from accepting user inputs.",0,0); BR laShowItem(uil,cr,0,"la.user_preferences.interface_size")->Flags|=LA_UI_FLAGS_NO_EVENT; ER BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_NO_EVENT; ER SHOW_FLAG(LA_UI_FLAGS_NO_CONFIRM); laShowLabel(uil,cr,"This stops widgets from generating a confirm event when executed or values changed.",0,0)->Flags|=LA_TEXT_LINE_WRAP; SHOW_FLAG(LA_TEXT_ALIGN_LEFT); laShowLabel(uil,cr,"A lot of widgets supports text aligning flags, not just labels.",0,0); laShowLabel(uil,cr,"Align left",0,0)->Flags|=LA_TEXT_ALIGN_LEFT; SHOW_FLAG(LA_TEXT_ALIGN_CENTER); laShowLabel(uil,cr,"Align center",0,0)->Flags|=LA_TEXT_ALIGN_CENTER; SHOW_FLAG(LA_TEXT_ALIGN_RIGHT); laShowLabel(uil,cr,"Align right",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; SHOW_FLAG(LA_TEXT_ALIGN_AUTO); laShowLabel(uil,cr,"Align auto",0,0)->Flags|=LA_TEXT_ALIGN_AUTO; SHOW_FLAG(LA_TEXT_USE_NEWLINE); laShowLabel(uil,cr,"Will use '\\n' in string properties and switch to a new line.",0,0); SHOW_FLAG(LA_TEXT_LINE_WRAP); laShowLabel(uil,cr,"Will use '\\n' in labels\n as well as wrapping the line.",0,0)->Flags|=LA_TEXT_LINE_WRAP; SHOW_FLAG(LA_TEXT_REVERT_Y); laShowLabel(uil,cr,"Text would be drawn up-size-down, convenient in different coordinate systems.",0,0)->Flags|=LA_TEXT_LINE_WRAP; laShowLabel(uil,cr," ",0,0); laShowLabel(uil,cr,"Just like this",0,0)->Flags|=LA_TEXT_REVERT_Y; SHOW_FLAG(LA_TEXT_MONO); laShowLabel(uil,cr,"Text would be in monospace font.",0,0); SHOW_FLAG(LA_UI_FLAGS_PREFER_BOTTOM); laShowLabel(uil,cr,"UI list would prefer to stay at the bottom.",0,0); laShowLabel(uil,cr,"Resize the terminal window and see the effect.",0,0); BR laShowItemFull(uil,cr,0,"LA_panel_activator",0,"panel_id=LAUI_terminal;text=Show Terminal",0,0); ER SHOW_FLAG(LA_UI_FLAGS_NO_GAP); laShowLabel(uil,cr,"Draw UI as if there's no gap between itself and its adjacent UI items.",0,0); BR laShowItem(uil,cr,0,"LA_pure_yes_no"); ER BR laShowItem(uil,cr,0,"LA_pure_yes_no")->Flags|=LA_UI_FLAGS_NO_GAP; laShowLabel(uil,cr," <-- Like this one",0,0); ER SHOW_FLAG(LA_UI_FLAGS_UNDERNEATH); laShowLabel(uil,cr,"Show this UI item as if it's underneath the next one.",0,0); laShowLabel(uil,cr,"Under",0,0)->Flags|=LA_UI_FLAGS_UNDERNEATH; laShowLabel(uil,cr,"--------- Over",0,0); SHOW_FLAG(LA_UI_FLAGS_NO_HEIGHT); laShowLabel(uil,cr,"Same as above, but also removes margins etc.",0,0); SHOW_FLAG(LA_UI_FLAGS_NO_OVERLAY); laShowLabel(uil,cr,"Hide UI overlays on top of a canvas widget",0,0); SHOW_FLAG(LA_TEXT_OVERFLOW_ARROW); laShowLabel(uil,cr,"Show an arrow in long string box",0,0); BR laShowItem(uil,cr,0,"la.example_string")->Flags|=LA_TEXT_ONE_LINE|LA_TEXT_OVERFLOW_ARROW; ER SHOW_FLAG(LA_UI_FLAGS_DISABLED); laShowLabel(uil,cr,"Like this, also used on other widgets",0,0)->Flags|=LA_UI_FLAGS_DISABLED; SHOW_FLAG(LA_UI_FLAGS_HIGHLIGHT); laShowLabel(uil,cr,"Like this, also used on other widgets",0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT; SHOW_FLAG(LA_UI_FLAGS_NODE_CONTAINER); laShowLabel(uil,cr,"Set this UI as the node container",0,0); SHOW_FLAG(LA_UI_COLLECTION_NO_HIGHLIGHT); laShowLabel(uil,cr,"If this is a collection UI, then this stops it from showing the background of active element.",0,0)->Flags|=LA_TEXT_LINE_WRAP; SHOW_FLAG(LA_TEXT_ONE_LINE); laShowLabel(uil,cr,"Show string property values in one line, even if there's a '\\n'.",0,0)->Flags|=LA_TEXT_LINE_WRAP; SHOW_FLAG(LA_UI_FLAGS_INT_ICON); laShowLabel(uil,cr,"Show an int property as if its value is a unicode codepoint and display its corresponding glyph.'.",0,0)->Flags|=LA_TEXT_LINE_WRAP; SHOW_FLAG(LA_UI_FLAGS_PLAIN); laShowLabel(uil,cr,"LA_UI_FLAGS_NO_DECAL|LA_UI_FLAGS_NO_EVENT",0,0)->Flags|=LA_TEXT_MONO; SHOW_FLAG(LA_UI_SOCKET_LABEL_N); laShowLabel(uil,cr,"Set node socket label to north. Default not shown.",0,0); SHOW_FLAG(LA_UI_SOCKET_LABEL_S); SHOW_FLAG(LA_UI_SOCKET_LABEL_W); SHOW_FLAG(LA_UI_SOCKET_LABEL_E); } int main(int argc, char *argv[]){ laGetReady(); laRegisterUiTemplate("my_widget_flags","Widget Flags", Widgets,0,0,"Demonstration", 0,0,0); laWindow* w = laDesignWindow(-1,-1,1000,600); laLayout* l = laDesignLayout(w,"My Layout"); laCreatePanel(l->FirstBlock,"my_widget_flags"); laStartWindow(w); laMainLoop(); }