Skip to content

Commit eaa105c

Browse files
committed
FComboBox mouse click behavior corrected + Fixed display of NewFont with vertical scrollbar
1 parent 6201388 commit eaa105c

16 files changed

+156
-48
lines changed

doc/first-steps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ class dialogWidget : public FDialog
10431043
}
10441044

10451045
int t = 20;
1046-
FLabel label{FString() << t << "°C", this};
1046+
FLabel label{std::move(FString() << t << "°C"), this};
10471047
FButton plus {"&+", this};
10481048
FButton minus {"&-", this};
10491049
};
@@ -1422,7 +1422,7 @@ class dialogWidget : public FDialog
14221422
<< std::get<3>(b) << std::get<0>(b);
14231423
auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview);
14241424
edit->setGeometry(std::get<2>(b) + FPoint{1, 1}, FSize{17, 1});
1425-
auto btn = new FButton(std::get<0>(b), this);
1425+
auto btn = new FButton(std::move(std::get<0>(b)), this);
14261426
btn->setGeometry(std::get<1>(b), FSize{4, 1});
14271427
btn->unsetShadow();
14281428
btn->addCallback

final/dialog/fdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ void FDialog::drawTextBar()
12541254
const auto zoom_btn = getZoomButtonWidth();
12551255
const auto minimize_btn = getMinimizeButtonWidth();
12561256
const auto tb_width = width - menu_btn - minimize_btn - zoom_btn;
1257-
const auto text_width = getColumnWidth(tb_text);
1257+
auto text_width = getColumnWidth(tb_text);
12581258
std::size_t leading_space{0};
12591259

12601260
if ( width > text_width + menu_btn + minimize_btn + zoom_btn )
@@ -1274,6 +1274,7 @@ void FDialog::drawTextBar()
12741274
const auto len = getLengthFromColumnWidth (tb_text, tb_width - 2);
12751275
print (tb_text.left(len));
12761276
print ("..");
1277+
text_width = len + 2;
12771278
}
12781279
}
12791280

final/fapplication.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ void FApplication::mouseEvent (const FMouseData& md)
740740
{
741741
determineClickedWidget (md);
742742

743-
if ( FWidget::getClickedWidget() )
744-
{
745-
unsetMoveSizeMode();
746-
closeDropDown (md);
747-
unselectMenubarItems (md);
748-
sendMouseEvent (md);
749-
}
743+
if ( ! FWidget::getClickedWidget() )
744+
return;
745+
746+
unsetMoveSizeMode();
747+
closeDropDown (md);
748+
unselectMenubarItems (md);
749+
sendMouseEvent (md);
750750
}
751751

752752
//----------------------------------------------------------------------

final/input/fmouse.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
namespace finalcut
4242
{
4343

44+
// static class attributes
45+
FMouseData* FMouseControl::current_mouse_event{nullptr};
46+
4447
//----------------------------------------------------------------------
4548
// class FMouseData
4649
//----------------------------------------------------------------------
@@ -1543,8 +1546,12 @@ void FMouseControl::processQueuedInput()
15431546
FMouseDataPtr md(std::move(fmousedata_queue.front()));
15441547
fmousedata_queue.pop();
15451548

1546-
if ( md.get() )
1549+
if ( md )
1550+
{
1551+
current_mouse_event = md.get();
15471552
event_cmd.execute(*md);
1553+
current_mouse_event = nullptr;
1554+
}
15481555

15491556
if ( FApplication::isQuit() )
15501557
return;

final/input/fmouse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ class FMouseControl
526526
virtual FString getClassName() const;
527527
static auto getInstance() -> FMouseControl&;
528528
const FPoint& getPos() &;
529+
FMouseData* getCurrentMouseEvent() const;
529530
void clearEvent();
530531

531532
// Mutators
@@ -584,6 +585,7 @@ class FMouseControl
584585
// Data member
585586
FMouseProtocol mouse_protocol{};
586587
FMouseCommand event_cmd{};
588+
static FMouseData* current_mouse_event;
587589
std::queue<FMouseDataPtr> fmousedata_queue{};
588590
FPoint zero_point{0, 0};
589591
bool use_gpm_mouse{false};
@@ -595,6 +597,10 @@ class FMouseControl
595597
inline FString FMouseControl::getClassName() const
596598
{ return "FMouseControl"; }
597599

600+
//----------------------------------------------------------------------
601+
inline FMouseData* FMouseControl::getCurrentMouseEvent() const
602+
{ return current_mouse_event; }
603+
598604
//----------------------------------------------------------------------
599605
inline void FMouseControl::setEventCommand (const FMouseCommand& cmd)
600606
{ event_cmd = cmd; }

final/widget/fcombobox.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,9 @@ void FComboBox::cb_closeComboBox()
597597
void FComboBox::cb_inputFieldSwitch()
598598
{
599599
auto& mouse = FMouseControl::getInstance();
600+
auto mouse_event = mouse.getCurrentMouseEvent();
600601

601-
if ( ! mouse.isLeftButtonPressed() )
602+
if ( ! mouse_event || ! mouse_event->isLeftButtonPressed() )
602603
return;
603604

604605
if ( list_window.isShown() )

final/widget/flabel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ FLabel::FLabel(FWidget* parent)
4646
}
4747

4848
//----------------------------------------------------------------------
49-
FLabel::FLabel (FString&& txt, FWidget* parent)
49+
FLabel::FLabel (const FString& txt, FWidget* parent)
5050
: FWidget{parent}
51-
, text{std::move(txt)}
5251
{
5352
init();
5453
setText(txt);

final/widget/flabel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class FLabel : public FWidget
6767

6868
// Constructor
6969
explicit FLabel (FWidget* = nullptr);
70-
explicit FLabel (FString&&, FWidget* = nullptr);
70+
explicit FLabel (const FString&, FWidget* = nullptr);
7171

7272
// Disable copy constructor
7373
FLabel (const FLabel&) = delete;

final/widget/flistbox.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,16 @@ void FListBox::onFocusOut (FFocusEvent*)
528528

529529

530530
// protected methods of FListBox
531+
//----------------------------------------------------------------------
532+
void FListBox::initLayout()
533+
{
534+
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
535+
setTopPadding(1);
536+
setLeftPadding(1);
537+
setBottomPadding(1);
538+
setRightPadding(1);
539+
}
540+
531541
//----------------------------------------------------------------------
532542
void FListBox::adjustYOffset (std::size_t element_count)
533543
{
@@ -602,11 +612,6 @@ void FListBox::init()
602612
initScrollbar (vbar, Orientation::Vertical, this, &FListBox::cb_vbarChange);
603613
initScrollbar (hbar, Orientation::Horizontal, this, &FListBox::cb_hbarChange);
604614
FListBox::setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
605-
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
606-
setTopPadding(1);
607-
setLeftPadding(1);
608-
setBottomPadding(1);
609-
setRightPadding(1);
610615
mapKeyFunctions();
611616
}
612617

final/widget/flistbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ class FListBox : public FWidget
297297

298298
protected:
299299
// Methods
300+
void initLayout() override;
300301
void adjustYOffset (std::size_t);
301302
void adjustSize() override;
302303

final/widget/flistview.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,16 @@ void FListView::onFocusOut (FFocusEvent*)
12961296

12971297

12981298
// protected methods of FListView
1299+
//----------------------------------------------------------------------
1300+
void FListView::initLayout()
1301+
{
1302+
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
1303+
setTopPadding(1);
1304+
setLeftPadding(1);
1305+
setBottomPadding(1);
1306+
setRightPadding(1);
1307+
}
1308+
12991309
//----------------------------------------------------------------------
13001310
void FListView::adjustViewport (const int element_count)
13011311
{
@@ -1403,11 +1413,6 @@ void FListView::init()
14031413
root = selflist.begin();
14041414
getNullIterator() = selflist.end();
14051415
FListView::setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
1406-
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
1407-
setTopPadding(1);
1408-
setLeftPadding(1);
1409-
setBottomPadding(1);
1410-
setRightPadding(1);
14111416
mapKeyFunctions();
14121417
}
14131418

final/widget/flistview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ class FListView : public FWidget
404404

405405
protected:
406406
// Methods
407+
void initLayout() override;
407408
void adjustViewport (const int);
408409
void adjustScrollbars (const std::size_t) const;
409410
void adjustSize() override;

final/widget/fscrollview.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,19 @@ FVTerm::FTermArea* FScrollView::getPrintArea()
613613
return viewport;
614614
}
615615

616+
//----------------------------------------------------------------------
617+
void FScrollView::initLayout()
618+
{
619+
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
620+
const auto xoffset_end = int(getScrollWidth() - getViewportWidth());
621+
const auto yoffset_end = int(getScrollHeight() - getViewportHeight());
622+
setTopPadding (1 - getScrollY());
623+
setLeftPadding (1 - getScrollX());
624+
setBottomPadding (1 - (yoffset_end - getScrollY()));
625+
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
626+
calculateScrollbarPos();
627+
}
628+
616629
//----------------------------------------------------------------------
617630
void FScrollView::adjustSize()
618631
{
@@ -621,7 +634,6 @@ void FScrollView::adjustSize()
621634
const std::size_t height = getHeight();
622635
const int xoffset = viewport_geometry.getX();
623636
const int yoffset = viewport_geometry.getY();
624-
625637
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
626638
, getTermY() + getTopPadding() - 1 );
627639

@@ -631,22 +643,22 @@ void FScrollView::adjustSize()
631643
viewport->offset_top = scroll_geometry.getY();
632644
}
633645

634-
hbar->setMaximum (int(getScrollWidth() - getViewportWidth()));
635-
hbar->setPageSize (int(getScrollWidth()), int(getViewportWidth()));
636-
hbar->setY (int(height));
637-
hbar->setWidth (width - 2, false);
638-
hbar->setValue (xoffset);
639-
hbar->resize();
640-
641646
vbar->setMaximum (int(getScrollHeight() - getViewportHeight()));
642647
vbar->setPageSize (int(getScrollHeight()), int(getViewportHeight()));
643648
vbar->setX (int(width));
644649
vbar->setHeight (height - 2, false);
645650
vbar->setValue (yoffset);
646651
vbar->resize();
647652

648-
setHorizontalScrollBarVisibility();
653+
hbar->setMaximum (int(getScrollWidth() - getViewportWidth()));
654+
hbar->setPageSize (int(getScrollWidth()), int(getViewportWidth()));
655+
hbar->setY (int(height));
656+
hbar->setWidth (width - 2, false);
657+
hbar->setValue (xoffset);
658+
hbar->resize();
659+
649660
setVerticalScrollBarVisibility();
661+
setHorizontalScrollBarVisibility();
650662
}
651663

652664
//----------------------------------------------------------------------
@@ -733,13 +745,6 @@ void FScrollView::init()
733745
FScrollView::resetColors();
734746
FScrollView::setGeometry (FPoint{1, 1}, FSize{4, 4});
735747
setMinimumSize (FSize{4, 4});
736-
const auto xoffset_end = int(getScrollWidth() - getViewportWidth());
737-
const auto yoffset_end = int(getScrollHeight() - getViewportHeight());
738-
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
739-
setTopPadding (1 - getScrollY());
740-
setLeftPadding (1 - getScrollX());
741-
setBottomPadding (1 - (yoffset_end - getScrollY()));
742-
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
743748
const FSize no_shadow{0, 0};
744749
std::size_t w = getViewportWidth();
745750
std::size_t h = getViewportHeight();
@@ -785,7 +790,7 @@ void FScrollView::calculateScrollbarPos() const
785790
const std::size_t width = getWidth();
786791
const std::size_t height = getHeight();
787792

788-
if ( FVTerm::getFOutput()->isNewFont() )
793+
if ( nf_offset )
789794
{
790795
vbar->setGeometry (FPoint{int(width), 2}, FSize{2, height - 2});
791796
hbar->setGeometry (FPoint{1, int(height)}, FSize{width - 2, 1});

final/widget/fscrollview.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class FScrollView : public FWidget
149149
FTermArea* getPrintArea() override;
150150

151151
// Methods
152+
void initLayout() override;
152153
void adjustSize() override;
153154
void copy2area();
154155

@@ -200,7 +201,11 @@ inline FString FScrollView::getClassName() const
200201

201202
//----------------------------------------------------------------------
202203
inline std::size_t FScrollView::getViewportWidth() const
203-
{ return getWidth() - vertical_border_spacing - std::size_t(nf_offset); }
204+
{
205+
return ( getScrollHeight() > getViewportHeight() )
206+
? getWidth() - vertical_border_spacing - std::size_t(nf_offset)
207+
: getWidth() - vertical_border_spacing;
208+
}
204209

205210
//----------------------------------------------------------------------
206211
inline std::size_t FScrollView::getViewportHeight() const

final/widget/ftextview.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ void FTextView::onFocusOut (FFocusEvent*)
468468
//----------------------------------------------------------------------
469469
void FTextView::initLayout()
470470
{
471+
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
472+
setTopPadding(1);
473+
setLeftPadding(1);
474+
setBottomPadding(1);
475+
setRightPadding(1 + nf_offset);
476+
471477
if ( data.empty() )
472478
return;
473479

@@ -558,11 +564,6 @@ void FTextView::init()
558564
initScrollbar (vbar, Orientation::Vertical, this, &FTextView::cb_vbarChange);
559565
initScrollbar (hbar, Orientation::Horizontal, this, &FTextView::cb_hbarChange);
560566
FTextView::resetColors();
561-
nf_offset = FVTerm::getFOutput()->isNewFont() ? 1 : 0;
562-
setTopPadding(1);
563-
setLeftPadding(1);
564-
setBottomPadding(1);
565-
setRightPadding(1 + nf_offset);
566567
mapKeyFunctions();
567568
}
568569

0 commit comments

Comments
 (0)